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

Re-add sent review request email data into the email log #9991

Closed
Vitaliy-1 opened this issue May 28, 2024 · 10 comments
Closed

Re-add sent review request email data into the email log #9991

Vitaliy-1 opened this issue May 28, 2024 · 10 comments
Assignees
Labels
Bug:1:Low A bug that does not have a severe consequence or affects a small number of users. Try Me This issue might be good for a new contributor. Can you help us?
Milestone

Comments

@Vitaliy-1
Copy link
Collaborator

Describe the bug
Described on the forum https://forum.pkp.sfu.ca/t/review-request-emails-no-longer-logged-in-ojs-3-4-intentionally/88499

In 3.3, when sending a review request email, the email information was recorded in the email_log table. It didn't have a specific event_type for that action.

To Reproduce
Steps to reproduce the behavior:

  1. Go to the submission on the review stage
  2. Click on Add Reviewer
  3. Fill the form and send email
  4. See the email data wasn't logged in the email_log table

What application are you using?
OJS 3.4, OJS main

Additional information

  1. Create a submission event type constant, i.e., SUBMISSION_EMAIL_REVIEW_REQUEST and SUBMISSION_EMAIL_REVIEW_REQUEST_SUBSEQUENT
  2. The actual email sending is performed in PKP\submission\action\EditorAction::addReviewer(), use PKP\log\SubmissionEmailLogDAO::logMailable() to record the data.
@Vitaliy-1 Vitaliy-1 added Bug:1:Low A bug that does not have a severe consequence or affects a small number of users. Try Me This issue might be good for a new contributor. Can you help us? labels May 28, 2024
@Vitaliy-1 Vitaliy-1 added this to the 3.4.0-x milestone May 28, 2024
@jim13731
Copy link

jim13731 commented Jul 5, 2024

@Vitaliy-1 Thank you for the sharing the files path.

I have added functionality to log email data for the "Add Reviewer" action in OJS 3.4. Below are the changes made:

Files Modified
lib/pkp/classes/log/event/PKPSubmissionEventLogEntry.php
lib/pkp/classes/submission/action/EditorAction.php

Changes

  1. lib/pkp/classes/log/event/PKPSubmissionEventLogEntry.php

Added new constants for email events:

`class PKPSubmissionEventLogEntry extends EventLogEntry
{
// ... existing constants ...

public const SUBMISSION_EMAIL_REVIEW_REQUEST = 0x50000001;
public const SUBMISSION_EMAIL_REVIEW_REQUEST_SUBSEQUENT = 0x50000002;

// ... existing methods ...

}
`
2. lib/pkp/classes/submission/action/EditorAction.php

Modified the addReviewer method to include email logging:

`public function addReviewer($request, $submission, $reviewerId, &$reviewRound, $reviewDueDate, $responseDueDate, $reviewMethod = null)
{
// ... existing code ...

if (!$assigned && isset($reviewer) && !Hook::call('EditorAction::addReviewer', [&$submission, $reviewerId])) {
    // ... existing code ...

    // Send mail
    if (!$request->getUserVar('skipEmail')) {
        $context = PKPServices::get('context')->get($submission->getData('contextId'));
        $emailTemplate = Repo::emailTemplate()->getByKey($submission->getData('contextId'), $request->getUserVar('template'));
        $emailBody = $request->getUserVar('personalMessage');
        $emailSubject = $emailTemplate->getLocalizedData('subject');
        $mailable = $this->createMail($submission, $reviewAssignment, $reviewer, $user, $emailBody, $emailSubject, $context);

        try {
            Mail::send($mailable);

            // Log email
            $eventType = ($reviewRound->getRound() == 1) ? PKPSubmissionEventLogEntry::SUBMISSION_EMAIL_REVIEW_REQUEST : PKPSubmissionEventLogEntry::SUBMISSION_EMAIL_REVIEW_REQUEST_SUBSEQUENT;
            $submissionEmailLogDao = DAORegistry::getDAO('SubmissionEmailLogDAO');
            $submissionEmailLogDao->logMailable($eventType, $mailable, $submission, $user);

        } catch (TransportException $e) {
            $notificationMgr = new PKPNotificationManager();
            $notificationMgr->createTrivialNotification(
                $user->getId(),
                PKPNotification::NOTIFICATION_TYPE_ERROR,
                ['contents' => __('email.compose.error')]
            );
            trigger_error('Failed to send email: ' . $e->getMessage(), E_USER_WARNING);
        }
    }
}

}

Summary

These changes ensure that email data is logged whenever a reviewer is added.`

image

image

taslangraham added a commit to taslangraham/pkp-lib that referenced this issue Jul 19, 2024
taslangraham added a commit to taslangraham/pkp-lib that referenced this issue Jul 19, 2024
taslangraham added a commit to taslangraham/pkp-lib that referenced this issue Jul 19, 2024
taslangraham added a commit to taslangraham/pkp-lib that referenced this issue Jul 19, 2024
@taslangraham
Copy link
Contributor

taslangraham commented Jul 20, 2024

@Vitaliy-1 I've created PRs for this. Please take a look.

PRs:
pkp-lib (main) - #10229
pkp lib (stable 3.4) - #10230

ojs (main) - pkp/ojs#4373
ojs (stable 3.4) - pkp/ojs#4374

omp (main) - pkp/omp#1651
omp (stable 3.4) - pkp/omp#1652

ops(stable 3.4) - pkp/ops#770
ops(main) - pkp/ops#769

taslangraham added a commit to taslangraham/pkp-lib that referenced this issue Jul 22, 2024
@asmecher
Copy link
Member

asmecher commented Sep 6, 2024

@taslangraham, I've had a report (SciELO) that this is also happening for review reminders, i.e. they are being sent but not logged in the email log. Can you verify and add to the fix as needed?

@taslangraham
Copy link
Contributor

@asmecher I'll look into it

taslangraham added a commit to taslangraham/pkp-lib that referenced this issue Sep 11, 2024
taslangraham added a commit to taslangraham/pkp-lib that referenced this issue Sep 12, 2024
taslangraham added a commit to taslangraham/pkp-lib that referenced this issue Sep 12, 2024
taslangraham added a commit to taslangraham/pkp-lib that referenced this issue Sep 12, 2024
This was referenced Sep 12, 2024
@taslangraham
Copy link
Contributor

@asmecher I've identified and applied a fix for the issue you mentioned above

@asmecher
Copy link
Member

Thanks, @taslangraham! Since a couple of templates were missing logging, could you take a bit of a survey of other review related emails to see if it's a wider spread problem? Look in registry/emailTemplate.xml for a list of email templates; the relevant ones start with REVIEW_.

@asmecher asmecher removed this from the 3.4.0-x milestone Sep 13, 2024
@asmecher asmecher added this to the 3.4.0-8 milestone Sep 13, 2024
taslangraham added a commit to taslangraham/pkp-lib that referenced this issue Sep 20, 2024
taslangraham added a commit to taslangraham/pkp-lib that referenced this issue Sep 20, 2024
@taslangraham
Copy link
Contributor

@asmecher Sorry for the delay. I found a few other reviewer-related emails that were missing logging. I've added logging for them on the pr for main(see commit). If those all make sense then I'll port it over to 3.4

@asmecher
Copy link
Member

Sounds good, thanks, @taslangraham! In general it's best to code against the stablest branch you're targeting first, then forward-port from there -- that way you're less likely to introduce regressions. But let me know when it's ready for a look.

taslangraham added a commit to taslangraham/pkp-lib that referenced this issue Sep 23, 2024
taslangraham added a commit to taslangraham/pkp-lib that referenced this issue Sep 23, 2024
taslangraham added a commit to taslangraham/pkp-lib that referenced this issue Sep 23, 2024
taslangraham added a commit to taslangraham/pkp-lib that referenced this issue Sep 23, 2024
taslangraham added a commit to taslangraham/pkp-lib that referenced this issue Sep 23, 2024
taslangraham added a commit to taslangraham/pkp-lib that referenced this issue Sep 23, 2024
taslangraham added a commit to taslangraham/pkp-lib that referenced this issue Sep 25, 2024
taslangraham added a commit to taslangraham/pkp-lib that referenced this issue Sep 26, 2024
taslangraham added a commit to taslangraham/pkp-lib that referenced this issue Sep 26, 2024
@taslangraham
Copy link
Contributor

Ready for review @asmecher. PRs listed here

asmecher pushed a commit that referenced this issue Sep 26, 2024
* #9991 log review request/reminder emails

* #9991 additional logs for reviewer emails
asmecher pushed a commit that referenced this issue Sep 26, 2024
* #9991 log review request/reminder emails

* #9991 additional logs for reviewer emails
@asmecher
Copy link
Member

Excellent work, @taslangraham! All merged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug:1:Low A bug that does not have a severe consequence or affects a small number of users. Try Me This issue might be good for a new contributor. Can you help us?
Projects
None yet
Development

No branches or pull requests

5 participants