pkp / pkp-lib

The library used by PKP's applications OJS, OMP and OPS, open source software for scholarly publishing.
https://pkp.sfu.ca
GNU General Public License v3.0
307 stars 448 forks source link

API for emailLogEntry #10412

Closed jardakotesovec closed 1 month ago

jardakotesovec commented 2 months ago

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.

Screenshot 2024-09-13 at 10 48 48

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.

Screenshot 2024-09-13 at 18 46 42

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

taslangraham commented 2 months ago

I'd like to work on this

jardakotesovec commented 2 months ago

@taslangraham Thanks Taslan, much appreciated.

taslangraham commented 2 months ago

I've opened PRs for this. Please take a look @ewhanson

PKP-LIB

Submodule updates

ewhanson commented 2 months ago

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.

taslangraham commented 2 months ago

@ewhanson Thanks for the review. I've made the necessary changes based on your feedback.

ewhanson commented 1 month ago

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.

taslangraham commented 1 month ago

All merged @ewhanson! Thanks