Closed jardakotesovec closed 1 month ago
I'd like to work on this
@taslangraham Thanks Taslan, much appreciated.
I've opened PRs for this. Please take a look @ewhanson
Introduced new endpoint, api/v1/emails/authorEmails
, that allows authors to get their email
submissionId
and eventType
as query params to allow filtering.userId
param was not used since it would always be validated against the loggedIn user's ID and the eventual query for email will use the loggedIn user's ID.Introduced new endpoint, api/v1/emails/{emailId}
, which allows an author or editor to retrieve a single email by ID
Added schema file and class to map email object for API responses.
Update swagger documentation to include new endpoints.
Submodule updates
Thanks, @taslangraham! Just a few comments, then it should be good to go.
Additionally, both OPS and OMP will need the corresponding api/v1/emails/index.php
like you've added in OJS.
@ewhanson Thanks for the review. I've made the necessary changes based on your feedback.
Looks good @taslangraham! 👍 There's a conflict in pkp-lib (and probably a rebase needed in general), but after you fix that, feel free to merge.
All merged @ewhanson! Thanks
Describe the issue On Author workflow page, we additionally shows various emails that has been sent to the author, we present them as Notifications.
We don't have the API yet to be able to query these.
Examples how thats being queried from db are here, here and here.
Apart from the use case on author dashboard, where author sees the emails addressed to him. There is also use case where editors can open the email from the Activity Log and thats queried via grid function. So it would make sense to consider this as well for API.
Proposed Solution Introduce new GET endpoint /api/v1/emails With query params:
submissionId
,userId
,eventType
Introduce new GET endpoint endpoint /api/v1/emails/{emailId}, to receive the one email by the id. But if that would be just additional query param to previous endpoint that would work fine as well.
In terms of the what data to include. I think body is not too big, so I think it could be always full object, including both subject and body.
In terms of permissions - my understanding is that userId represents who is that email addressed to. Therefore if currentUserId is matching userId I think it should be able to retrieve them.
For editors being able to see other emails, I think best is probably to check https://github.com/pkp/pkp-lib/blob/main/controllers/grid/eventLog/SubmissionEventLogGridHandler.php#L238 , which has the viewEmail function to show the email to editors. And my understanding is that the authorise function there is ensuring correct access permissions.
What application are you using? OJS, OMP or OPS version 3.5