-
Notifications
You must be signed in to change notification settings - Fork 355
[ENG-10083] Add type and is_digest "relation" and update subscription #11558
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
base: feature/notifications-refactor-post-release
Are you sure you want to change the base?
Conversation
|
LGTM! |
There was a problem hiding this 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.
cslzchen
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
⭐
cslzchen
left a comment
There was a problem hiding this 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(): |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
| 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']) |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ditto
There was a problem hiding this comment.
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(): |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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, |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Correct
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