From 2a523c4955d8d6b6dc30e811326fb16a0ba59cc7 Mon Sep 17 00:00:00 2001 From: Trevor Buckner Date: Sun, 6 Oct 2024 15:48:10 -0400 Subject: [PATCH] Fix links to google drive files in user page User page was not marking Google Brews as "stubbed" if the brew belongs to another users' Google Drive or your own credentials are expired (it searches the current user drive for google files and checks if those are stubbed) This now sets *every* file found on Mongo as "Stubbed", whether the Drive file belongs to the current user or not. --- server/app.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/server/app.js b/server/app.js index 04b3c3486..40ab193d9 100644 --- a/server/app.js +++ b/server/app.js @@ -242,6 +242,8 @@ app.get('/user/:username', async (req, res, next)=>{ console.log(err); }); + brews.forEach(brew => brew.stubbed = true); //All brews from MongoDB are "stubbed" + if(ownAccount && req?.account?.googleId){ const auth = await GoogleActions.authCheck(req.account, res); let googleBrews = await GoogleActions.listGoogleBrews(auth) @@ -249,12 +251,12 @@ app.get('/user/:username', async (req, res, next)=>{ console.error(err); }); + // If stub matches file from Google, use Google metadata over stub metadata if(googleBrews && googleBrews.length > 0) { for (const brew of brews.filter((brew)=>brew.googleId)) { const match = googleBrews.findIndex((b)=>b.editId === brew.editId); if(match !== -1) { brew.googleId = googleBrews[match].googleId; - brew.stubbed = true; brew.pageCount = googleBrews[match].pageCount; brew.renderer = googleBrews[match].renderer; brew.version = googleBrews[match].version; @@ -263,6 +265,7 @@ app.get('/user/:username', async (req, res, next)=>{ } } + //Remaining unstubbed google brews display current user as author googleBrews = googleBrews.map((brew)=>({ ...brew, authors: [req.account.username] })); brews = _.concat(brews, googleBrews); }