From e88e7f852c7fefd917946887ce51950538475cb4 Mon Sep 17 00:00:00 2001 From: "G.Ambatte" Date: Mon, 26 Jun 2023 20:40:11 +1200 Subject: [PATCH] Add account check to Google File not found error --- .../pages/errorPage/errors/errorIndex.js | 21 +++++++++++++------ server/homebrew.api.js | 2 +- server/homebrew.api.spec.js | 2 +- 3 files changed, 17 insertions(+), 8 deletions(-) diff --git a/client/homebrew/pages/errorPage/errors/errorIndex.js b/client/homebrew/pages/errorPage/errors/errorIndex.js index 1fdce66b9..ded15c99a 100644 --- a/client/homebrew/pages/errorPage/errors/errorIndex.js +++ b/client/homebrew/pages/errorPage/errors/errorIndex.js @@ -19,14 +19,23 @@ const errorIndex = (props)=>{ // Google Drive - 404 : brew deleted or access denied '02' : dedent` - ## We can't find this brew in your Google Drive! + ## We can't find this brew in Google Drive! - This error tells us your file was saved on your Google Drive, but the link - you tried to open doesn't work anymore. The Homebrewery cannot delete files - from your Google Drive on its own, so there are three most likely possibilities: + This error tells us the file was saved on Google Drive, but the link + you have tried to open doesn't work anymore. The Homebrewery cannot delete files + from Google Drive on its own, so there are three most likely possibilities: : - - **You may have accidentally deleted the Google Drive files.** Look on - ${props.brew.authors?.length > 0 ? `the Google Drive account associated with the **${props.brew.authors[0]}** Homebrewery account` : 'your Google Drive account'} + - **The Google Drive files may have been accidentally deleted.** Look in + ${props.brew.authors?.length > 0 + && + (props.brew.authors[0] == props.brew.account + ? 'your Google Drive account' + : dedent`the Google Drive account associated with the + **${props.brew.authors[0]}** Homebrewery account - you + are currently logged in with the **${props.brew.account}** + account -`) + || + 'your Google Drive account'} and make sure the Homebrewery folder is still there, and that it holds your brews as text files. - **You may have changed the sharing settings for your files.** If the files diff --git a/server/homebrew.api.js b/server/homebrew.api.js index 4c6961b5a..f82a9b642 100644 --- a/server/homebrew.api.js +++ b/server/homebrew.api.js @@ -59,7 +59,7 @@ const api = { // Throw any error caught while attempting to retrieve Google brew. if(googleError) { const reason = googleError.errors[0].reason; - throw { ...googleError, HBErrorCode: reason == 'notFound' ? '02' : '01', authors: stub?.authors }; + throw { ...googleError, HBErrorCode: reason == 'notFound' ? '02' : '01', authors: stub?.authors, account: req.account.username }; } // 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; diff --git a/server/homebrew.api.spec.js b/server/homebrew.api.spec.js index cc940f52b..214faccf9 100644 --- a/server/homebrew.api.spec.js +++ b/server/homebrew.api.spec.js @@ -543,7 +543,7 @@ brew`); describe('deleteBrew', ()=>{ it('should handle case where fetching the brew returns an error', async ()=>{ - api.getBrew = jest.fn(()=>async ()=>{ throw {message: 'err', HBErrorCode: '02' }; }); + api.getBrew = jest.fn(()=>async ()=>{ throw { message: 'err', HBErrorCode: '02' }; }); api.getId = jest.fn(()=>({ id: '1', googleId: '2' })); model.deleteOne = jest.fn(async ()=>{}); const next = jest.fn(()=>{});