Skip to content

Commit

Permalink
OCT-317 Email notifications - Co-Author Reminders - FIXED AWS DEPLOY …
Browse files Browse the repository at this point in the history
…ISSUE (#347)

* fixed wrong date/time due to timezones

* fixed PR comments

* changed route params to avoid deploy issues

* fixed eslint errors

---------

Co-authored-by: Florin H <florin.holhos@wingravity.com>
  • Loading branch information
florin-holhos and Florin H authored Mar 1, 2023
1 parent e769504 commit be119c5
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 8 deletions.
2 changes: 1 addition & 1 deletion api/serverless.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
8 changes: 7 additions & 1 deletion api/src/components/coauthor/controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.' });
}
};
Expand Down Expand Up @@ -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.' });
}
};
Expand Down Expand Up @@ -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.' });
}
};
Expand Down Expand Up @@ -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.' });
}
};
Expand Down Expand Up @@ -344,14 +348,15 @@ export const requestApproval = async (
return response.json(200, coAuthors);
} catch (err) {
console.log(err);

return response.json(500, { message: 'Unknown server error.' });
}
};

export const sendApprovalReminder = async (
event: I.AuthenticatedAPIRequest<undefined, undefined, I.SendApprovalReminderPathParams>
): Promise<I.JSONResponse> => {
const { authorId, publicationId } = event.pathParameters;
const { coauthor: authorId, id: publicationId } = event.pathParameters;

const publication = await publicationService.get(publicationId);
const author = await coAuthorService.get(authorId);
Expand Down Expand Up @@ -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' });
}

Expand Down
6 changes: 3 additions & 3 deletions api/src/components/coauthor/schema/sendApprovalReminder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ import * as I from 'interface';
const sendApprovalReminder: I.JSONSchemaType<I.SendApprovalReminderPathParams> = {
type: 'object',
properties: {
authorId: {
coauthor: {
type: 'string'
},
publicationId: {
id: {
type: 'string'
}
},
required: ['authorId', 'publicationId']
required: ['coauthor', 'id']
};

export default sendApprovalReminder;
2 changes: 1 addition & 1 deletion api/src/lib/email.ts
Original file line number Diff line number Diff line change
Expand Up @@ -588,7 +588,7 @@ type SendApprovalReminder = {
};
};

export const sendApprovalReminder = async (options: SendApprovalReminder) => {
export const sendApprovalReminder = async (options: SendApprovalReminder): Promise<void> => {
const html = `
<p>${options.publication.creator} has sent you a reminder to confirm or deny your involvement as an author of the following publication on Octopus:</p>
<br>
Expand Down
4 changes: 2 additions & 2 deletions api/src/lib/interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -558,6 +558,6 @@ export interface UserPublicationsFilters {
}

export interface SendApprovalReminderPathParams {
publicationId: string;
authorId: string;
id: string;
coauthor: string;
}

0 comments on commit be119c5

Please sign in to comment.