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

notifications: add user preferences filter #65

Conversation

rekt-hard
Copy link
Contributor

schemas: add notifications schema

❤️ Thank you for your contribution!

Description

closes inveniosoftware/invenio-notifications#3

Add notification schema to be used in invenio-app-rdm
Add notification recipient filter for user preferences

Checklist

Ticks in all boxes and 🟢 on all GitHub actions status checks are required to merge:

Third-party code

If you've added third-party code (copy/pasted or new dependencies), please reach out to an architect.

Reminder

By using GitHub, you have already agreed to the GitHub’s Terms of Service including that:

  1. You license your contribution under the same terms as the current repository’s license.
  2. You agree that you have the right to license your contribution under the current repository’s license.

invenio_users_resources/notifications.py Outdated Show resolved Hide resolved
invenio_users_resources/notifications.py Outdated Show resolved Hide resolved
@rekt-hard rekt-hard force-pushed the 3-introduce-a-new-userpreferencesnotifications-configuration branch 2 times, most recently from f854d4d to f4c0d44 Compare April 19, 2023 14:12
@rekt-hard rekt-hard force-pushed the 3-introduce-a-new-userpreferencesnotifications-configuration branch from f4c0d44 to 2d60ff5 Compare April 25, 2023 13:06
Copy link
Member

@slint slint left a comment

Choose a reason for hiding this comment

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

LGTM, some styling/alignment comments.

In general, I have a feeling though that we might need to flesh-out the Recipient schema fields a bit more... Right now there's this very fluffy data field, which makes it a bit hard for a Backend e.g. to know for sure where to fetch from email, full_name, etc. Definitely not to be addressed right now in this PR, but I'll open an issue in invenio-notifications so we can keep track of it there better.

invenio_users_resources/notifications.py Outdated Show resolved Hide resolved
invenio_users_resources/notifications.py Outdated Show resolved Hide resolved
Comment on lines 45 to 46
if user.get("preferences", {}).get("notifications", {}).get("enabled", True):
recipients[user["id"]] = Recipient(data=user)
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
if user.get("preferences", {}).get("notifications", {}).get("enabled", True):
recipients[user["id"]] = Recipient(data=user)
recipients[user["id"]] = Recipient(data=user)

minor: since we have also the equivalent separate filter above

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Do we want to apply some filtering here as well or leave it to the specified RecipientFilters of the NotificationBuilder completely? So should the filters be responsible for all the filtering or just extra filtering?

invenio_users_resources/notifications.py Outdated Show resolved Hide resolved
schemas: add notifications schema
notifications: update UserPreferencesFilter to work with dict
tests: add test for UserPreferencesFilter
@rekt-hard rekt-hard force-pushed the 3-introduce-a-new-userpreferencesnotifications-configuration branch from 2d60ff5 to 2dcc0c4 Compare April 27, 2023 15:13
This class did not provide any additional implementation details and could be easily reconstructed.
Copy link
Member

@slint slint left a comment

Choose a reason for hiding this comment

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

LGTM, a comment on testing/integration and moving one of the notifications-related classes.

u = UserAggregate.from_user(user_pub.user).dumps()

user_notifications_enabled = deepcopy(u)
user_notifications_enabled["preferences"]["notifications"] = {"enabled": True}
Copy link
Member

Choose a reason for hiding this comment

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

minor: could we maybe override the ACCOUNTS_USER_PREFERENCES_SCHEMA in conftest.py to integrate NotificationPreferences to test this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

adapted conftest.py to use a preferences schema with NotificationPreferences.

invenio_users_resources/notifications.py Outdated Show resolved Hide resolved
@rekt-hard rekt-hard force-pushed the 3-introduce-a-new-userpreferencesnotifications-configuration branch from 29d1d91 to d21fd1d Compare May 4, 2023 12:20
@@ -85,6 +85,13 @@
"timezone": {
"type": "keyword",
"index":"false"
},
"notifications": {
Copy link
Contributor

Choose a reason for hiding this comment

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

could you add this index name to the changelog inveniosoftware/docs-invenio-rdm#536 ? we need to remember to add this to the migration recipe

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.

Introduce a new User.preferences.notifications configuration
5 participants