diff --git a/api/serverless.yml b/api/serverless.yml index 15f333e04..4baa08a37 100644 --- a/api/serverless.yml +++ b/api/serverless.yml @@ -289,7 +289,7 @@ functions: handler: src/components/coauthor/routes.sendApprovalReminder events: - http: - path: ${self:custom.versions.v1}/publications/{publicationId}/coauthors/{authorId}/approval-reminder + path: ${self:custom.versions.v1}/publications/{id}/coauthors/{coauthor}/approval-reminder method: POST cors: true getFlag: diff --git a/api/src/components/coauthor/controller.ts b/api/src/components/coauthor/controller.ts index 0fedb61ec..36e94c686 100644 --- a/api/src/components/coauthor/controller.ts +++ b/api/src/components/coauthor/controller.ts @@ -13,6 +13,7 @@ export const get = async ( return response.json(200, coAuthors); } catch (err) { console.log(err); + return response.json(500, { message: 'Unknown server error.' }); } }; @@ -147,6 +148,7 @@ export const remove = async ( return response.json(200, { message: 'Co-author deleted from this publication' }); } catch (err) { console.log(err); + return response.json(500, { message: 'Unknown server error.' }); } }; @@ -242,6 +244,7 @@ export const link = async ( return response.json(200, 'Linked user account'); } catch (err) { console.log(err); + return response.json(500, { message: 'Unknown server error.' }); } }; @@ -307,6 +310,7 @@ export const updateConfirmation = async ( return response.json(200, { message: 'This co-author has changed their confirmation status.' }); } catch (err) { console.log(err); + return response.json(500, { message: 'Unknown server error.' }); } }; @@ -344,6 +348,7 @@ export const requestApproval = async ( return response.json(200, coAuthors); } catch (err) { console.log(err); + return response.json(500, { message: 'Unknown server error.' }); } }; @@ -351,7 +356,7 @@ export const requestApproval = async ( export const sendApprovalReminder = async ( event: I.AuthenticatedAPIRequest ): Promise => { - const { authorId, publicationId } = event.pathParameters; + const { coauthor: authorId, id: publicationId } = event.pathParameters; const publication = await publicationService.get(publicationId); const author = await coAuthorService.get(authorId); @@ -419,6 +424,7 @@ export const sendApprovalReminder = async ( await coAuthorService.update(authorId, { reminderDate: new Date() }); } catch (error) { console.log(error); + return response.json(500, { message: 'Unknown server error' }); } diff --git a/api/src/components/coauthor/schema/sendApprovalReminder.ts b/api/src/components/coauthor/schema/sendApprovalReminder.ts index befc0f06d..d59ab3571 100644 --- a/api/src/components/coauthor/schema/sendApprovalReminder.ts +++ b/api/src/components/coauthor/schema/sendApprovalReminder.ts @@ -3,14 +3,14 @@ import * as I from 'interface'; const sendApprovalReminder: I.JSONSchemaType = { type: 'object', properties: { - authorId: { + coauthor: { type: 'string' }, - publicationId: { + id: { type: 'string' } }, - required: ['authorId', 'publicationId'] + required: ['coauthor', 'id'] }; export default sendApprovalReminder; diff --git a/api/src/lib/email.ts b/api/src/lib/email.ts index 9c9d92b88..f54ba6a77 100644 --- a/api/src/lib/email.ts +++ b/api/src/lib/email.ts @@ -588,7 +588,7 @@ type SendApprovalReminder = { }; }; -export const sendApprovalReminder = async (options: SendApprovalReminder) => { +export const sendApprovalReminder = async (options: SendApprovalReminder): Promise => { const html = `

${options.publication.creator} has sent you a reminder to confirm or deny your involvement as an author of the following publication on Octopus:


diff --git a/api/src/lib/interface.ts b/api/src/lib/interface.ts index bf1b0ce84..5c5a363c6 100644 --- a/api/src/lib/interface.ts +++ b/api/src/lib/interface.ts @@ -558,6 +558,6 @@ export interface UserPublicationsFilters { } export interface SendApprovalReminderPathParams { - publicationId: string; - authorId: string; + id: string; + coauthor: string; }