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

pkp/pkp-lib#10468 resolve: co authors receive several e-mails when a … #10479

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

forgive38
Copy link
Contributor

…decision is notified
#10468

@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.


simon seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account.
You have signed the CLA already but the status is still pending? Let us recheck it.

@nwoodward
Copy link

I tested this PR, and the authors are still getting several emails. I wonder if it's because there are two sections of the sendAuthorEmails() function that seem to be doing the same thing. The function Mail::send() is called in both of them. Is only once necessary?

$recipients = array_map(function ($userId) {
return Repo::user()->get($userId);
}, $this->getAssignedAuthorIds($submission));
$mailable = $this->addEmailDataToMailable($mailable, $editor, $email);
Mail::send($mailable->recipients($recipients, $email->locale));

and

if ($context->getData('notifyAllAuthors')) {
$authors = $submission->getCurrentPublication()->getData('authors');
$assignedAuthorEmails = array_map(function (User $user) {
return $user->getEmail();
}, $recipients);
$assignedAuthorIds = array_unique($this->getAssignedAuthorIds($submission), SORT_NUMERIC);
$assignedAuthors = Repo::user()->getCollector()->filterByUserIds($assignedAuthorIds)->getMany()->toArray();
$mailable = new DecisionNotifyOtherAuthors($context, $submission, $assignedAuthors);
$emailTemplate = Repo::emailTemplate()->getByKey($context->getId(), $mailable::getEmailTemplateKey());
$mailable
->sender($editor)
->subject($email->subject)
->body($emailTemplate->getLocalizedData('body'))
->addData([
$mailable::MESSAGE_TO_SUBMITTING_AUTHOR => $email->body,
]);
foreach ($authors as $author) {
if (!$author->getEmail() || in_array($author->getEmail(), $assignedAuthorEmails)) {
continue;
}
$mailable->to($author->getEmail(), $author->getFullName());
}
if ( sizeof($mailable->to) > 0 ) {
Mail::send($mailable);
}
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants