0
0
mirror of https://github.com/naturalcrit/homebrewery.git synced 2026-01-11 04:42:42 +00:00

Fetch Google Brew if only stub requested but nothing found

/update/ requests only the stub for updating. But if no stub exists, we should fetch the full brew so we return *something*.
This commit is contained in:
Trevor Buckner
2024-12-18 23:00:01 -05:00
parent 5f14f656ef
commit 57467701d0

View File

@@ -122,10 +122,10 @@ const api = {
throw { HBErrorCode: '51', code: stub?.lock.code, message: stub?.lock.shareMessage, brewId: stub?.shareId, brewTitle: stub?.title }; throw { HBErrorCode: '51', code: stub?.lock.code, message: stub?.lock.shareMessage, brewId: stub?.shareId, brewTitle: stub?.title };
} }
// If there is a google id, try to find the google brew // If there's a google id, get it if requesting the full brew or if no stub found yet
if(!stubOnly && googleId) { if(googleId && (!stubOnly || !stub)) {
const oAuth2Client = isOwner ? GoogleActions.authCheck(req.account, res) : undefined; const oAuth2Client = isOwner ? GoogleActions.authCheck(req.account, res) : undefined;
console.log(`user ${req.account?.username} attempting to get googlebrew ${googleId} as ${isOwner ? 'owner' : 'visitor'}`);
const googleBrew = await GoogleActions.getGoogleBrew(oAuth2Client, googleId, id, accessType) const googleBrew = await GoogleActions.getGoogleBrew(oAuth2Client, googleId, id, accessType)
.catch((googleError)=>{ .catch((googleError)=>{
const reason = googleError.errors?.[0].reason; const reason = googleError.errors?.[0].reason;