0
0
mirror of https://github.com/naturalcrit/homebrewery.git synced 2025-12-27 15:52:39 +00:00

Merge branch 'naturalcrit:master' into experimentalNotificationDB

This commit is contained in:
G.Ambatte
2023-01-15 13:55:25 +13:00
committed by GitHub
3 changed files with 26 additions and 25 deletions

30
package-lock.json generated
View File

@@ -33,7 +33,7 @@
"marked-extended-tables": "^1.0.5",
"markedLegacy": "npm:marked@^0.3.19",
"moment": "^2.29.4",
"mongoose": "^6.8.2",
"mongoose": "^6.8.3",
"nanoid": "3.3.4",
"nconf": "^0.12.0",
"npm": "^8.10.0",
@@ -9863,9 +9863,9 @@
}
},
"node_modules/kareem": {
"version": "2.5.0",
"resolved": "https://registry.npmjs.org/kareem/-/kareem-2.5.0.tgz",
"integrity": "sha512-rVBUGGwvqg130iwYu8k7lutHuDBFj1yGRdnlE44wEhxAmFBad1zcL66PdWC1raw3tIObY6XWhtv3VL04xQb/cg==",
"version": "2.5.1",
"resolved": "https://registry.npmjs.org/kareem/-/kareem-2.5.1.tgz",
"integrity": "sha512-7jFxRVm+jD+rkq3kY0iZDJfsO2/t4BBPeEb2qKn2lR/9KhuksYk5hxzfRYWMPV8P/x2d0kHD306YyWLzjjH+uA==",
"engines": {
"node": ">=12.0.0"
}
@@ -10395,12 +10395,12 @@
}
},
"node_modules/mongoose": {
"version": "6.8.2",
"resolved": "https://registry.npmjs.org/mongoose/-/mongoose-6.8.2.tgz",
"integrity": "sha512-cIato5N2w/QuJkkh0w4nyf7ty7DqmmP/W8/6PFSM0DrzbxIMlr6VN15LBIceTSJIxbznNl2Mlbh9Rm4sokMw+A==",
"version": "6.8.3",
"resolved": "https://registry.npmjs.org/mongoose/-/mongoose-6.8.3.tgz",
"integrity": "sha512-qrVWefJK+wFNBH0ALV+oiyJ+FN42O/BqvHFmlFJJ2LKuNmQEOE0JV8FCxnZqtanwbHs4i+k/SkjhtC+C01haaw==",
"dependencies": {
"bson": "^4.7.0",
"kareem": "2.5.0",
"kareem": "2.5.1",
"mongodb": "4.12.1",
"mpath": "0.9.0",
"mquery": "4.0.3",
@@ -24120,9 +24120,9 @@
"integrity": "sha512-40aUybvhH9t2h71ncA1/1SbtTNCVZHgsTsTgqPUxGWDmUDrXyDf2wMNQKEbdBjbf4AI+fQhbECNTV6lWxQKUzg=="
},
"kareem": {
"version": "2.5.0",
"resolved": "https://registry.npmjs.org/kareem/-/kareem-2.5.0.tgz",
"integrity": "sha512-rVBUGGwvqg130iwYu8k7lutHuDBFj1yGRdnlE44wEhxAmFBad1zcL66PdWC1raw3tIObY6XWhtv3VL04xQb/cg=="
"version": "2.5.1",
"resolved": "https://registry.npmjs.org/kareem/-/kareem-2.5.1.tgz",
"integrity": "sha512-7jFxRVm+jD+rkq3kY0iZDJfsO2/t4BBPeEb2qKn2lR/9KhuksYk5hxzfRYWMPV8P/x2d0kHD306YyWLzjjH+uA=="
},
"kind-of": {
"version": "4.0.0",
@@ -24533,12 +24533,12 @@
}
},
"mongoose": {
"version": "6.8.2",
"resolved": "https://registry.npmjs.org/mongoose/-/mongoose-6.8.2.tgz",
"integrity": "sha512-cIato5N2w/QuJkkh0w4nyf7ty7DqmmP/W8/6PFSM0DrzbxIMlr6VN15LBIceTSJIxbznNl2Mlbh9Rm4sokMw+A==",
"version": "6.8.3",
"resolved": "https://registry.npmjs.org/mongoose/-/mongoose-6.8.3.tgz",
"integrity": "sha512-qrVWefJK+wFNBH0ALV+oiyJ+FN42O/BqvHFmlFJJ2LKuNmQEOE0JV8FCxnZqtanwbHs4i+k/SkjhtC+C01haaw==",
"requires": {
"bson": "^4.7.0",
"kareem": "2.5.0",
"kareem": "2.5.1",
"mongodb": "4.12.1",
"mpath": "0.9.0",
"mquery": "4.0.3",

View File

@@ -90,7 +90,7 @@
"marked-extended-tables": "^1.0.5",
"markedLegacy": "npm:marked@^0.3.19",
"moment": "^2.29.4",
"mongoose": "^6.8.2",
"mongoose": "^6.8.3",
"nanoid": "3.3.4",
"nconf": "^0.12.0",
"npm": "^8.10.0",

View File

@@ -54,11 +54,10 @@ const api = {
let googleError;
const googleBrew = await GoogleActions.getGoogleBrew(googleId || stub?.googleId, id, accessType)
.catch((err)=>{
console.warn(err);
googleError = err;
});
// If we can't find the google brew and there is a google id for the brew, throw an error.
if(!googleBrew) throw googleError;
// Throw any error caught while attempting to retrieve Google brew.
if(googleError) throw googleError;
// Combine the Homebrewery stub with the google brew, or if the stub doesn't exist just use the google brew
stub = stub ? _.assign({ ...api.excludeStubProps(stub), stubbed: true }, api.excludeGoogleProps(googleBrew)) : googleBrew;
}
@@ -77,11 +76,13 @@ If you believe you should have access to this brew, ask the file owner to invite
}
// Clean up brew: fill in missing fields with defaults / fix old invalid values
stub.tags = stub.tags || undefined; // Clear empty strings
stub.renderer = stub.renderer || undefined; // Clear empty strings
stub = _.defaults(stub, DEFAULT_BREW_LOAD); // Fill in blank fields
if(stub) {
stub.tags = stub.tags || undefined; // Clear empty strings
stub.renderer = stub.renderer || undefined; // Clear empty strings
stub = _.defaults(stub, DEFAULT_BREW_LOAD); // Fill in blank fields
}
req.brew = stub;
req.brew = stub ?? {};
next();
};
},
@@ -192,8 +193,8 @@ If you believe you should have access to this brew, ask the file owner to invite
const brewFromClient = api.excludePropsFromUpdate(req.body);
if(req.brew.version && brewFromClient.version && req.brew.version > brewFromClient.version) {
console.log(`Version mismatch on brew ${req.body.editId}`);
// res.setHeader('Content-Type', 'application/json');
// return res.status(409).send(JSON.stringify({ message: `The brew has been changed on a different device. Please save your changes elsewhere, refresh, and try again.` }));
res.setHeader('Content-Type', 'application/json');
return res.status(409).send(JSON.stringify({ message: `The brew has been changed on a different device. Please save your changes elsewhere, refresh, and try again.` }));
}
let brew = _.assign(req.brew, brewFromClient);