Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OCT-317 Email notifications - Co-Author Reminders - FIXED AWS DEPLOY ISSUE #347

Merged
merged 4 commits into from
Mar 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;
}