Skip to content

Conversation

@Ostap-Zherebetskyi
Copy link
Collaborator

Ticket

https://openscience.atlassian.net/browse/ENG-10083

Purpose

Add type and is_digest "relation" and update subscription

Changes

Side Effects

QE Notes

CE Notes

Documentation

@Ostap-Zherebetskyi Ostap-Zherebetskyi marked this pull request as ready for review January 20, 2026 12:35
@bodintsov
Copy link
Contributor

LGTM!

Copy link
Collaborator

@cslzchen cslzchen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, just need to re-order the types and add comments.

Update: let's also add a sanity check in emit() to make sure the is_digest param matches the type's is_digest.

Copy link
Collaborator

@cslzchen cslzchen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Collaborator

@cslzchen cslzchen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have a few questions on the unit test fixes. Let's take a look together tomorrow.

is_published=True,
set_doi=False
)
with capture_notifications():
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm, so creating a new version of preprint did not send notifications before our digest change?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, this notification was sent as a digest before.


messages = get_mailhog_messages()
assert messages['count'] == len(notifications['emits'])
assert_emails(messages, notifications)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Curious why assert_emails(messages, notifications) fix the test failure?

And I see send_users_instant_digest_email.delay() no longer being called and tested?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

assert_emails does not fix the test, it is more suitable here because it compares emails rather than just counting them, and it can distinguish between digest and non-digest emails.

The send_users_instant_digest_email was removed because PROVIDER_REVIEWS_SUBMISSION_CONFIRMATION emails are not sent as a digest, so we don't need to trigger it to receive them.

Comment on lines -52 to -56
assert not messages['items']
with capture_notifications(passthrough=True) as notifications:
send_users_instant_digest_email.delay()
massages = get_mailhog_messages()
assert massages['count'] == len(notifications['emits'])
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similarly, what was the issue that leads us to remove this part of the test.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto

messages = get_mailhog_messages()
assert messages['count'] == 1
assert messages['items'][0]['Content']['Headers']['To'][0] == registration.creator.username
assert_emails(messages, notifications)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto

def test_save_published_called(self, mock_share_responses, preprint, user, auth):
with expect_preprint_ingest_request(mock_share_responses, preprint):
preprint.set_published(True, auth=auth, save=True)
with capture_notifications():
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also curious on why our _is_digest change has triggered extra notifications to be sent in many tests here. Should we verify what notifications are sent and are they sent correctly?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now, the PROVIDER_REVIEWS_SUBMISSION_CONFIRMATION email is sent immediately, rather than as part of a digest. This change caused the tests to fail.

user=user,
event_context=context
event_context=context,
is_digest=True,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With our change, I would think whether having is_digest=True or not shouldn't make a difference.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, but if we don't set the correct value, Sentry will log it each time an email is sent.

'document_type': self.provider.preprint_word,
'notify_comment': not self.provider.reviews_comments_private
},
is_digest=True
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, I see. So this one was digest but is actually non-digest now. Is this (part of) the reason why we have so many changes in the test files?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct

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