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

DSA Notifications #4376

Merged
merged 36 commits into from
Nov 9, 2023
Merged

DSA Notifications #4376

merged 36 commits into from
Nov 9, 2023

Conversation

nick-funk
Copy link
Contributor

What does this PR do?

Preliminarily adds notifications to the DSA epic branch.

These changes will impact:

  • commenters
  • moderators
  • admins
  • developers

What changes to the GraphQL/Database Schema does this PR introduce?

  • Adds a new Notification type and corresponding Connection types

Does this PR introduce any new environment variables or feature flags?

No.

If any indexes were added, were they added to INDEXES.md?

db.notifications.createIndex({ tenantID: 1, id: 1 }, { unique: true });

This index creates the uniqueness constraint for the tenantID and id fields on the notifications collection

db.notifications.createIndex({ tenantID: 1, ownerID: 1, createdAt: 1 });

This index speeds up the retrieval of notifications by tenantID, ownerID, and createdAt which is the most common way of retrieving notifications for pagination in the notifications tab on the stream.

How do I test this PR?

  • Enable the DSA features under Admin > Configure > General
  • Create some comments
  • Feature, approve, or reject the comments
  • Check Notifications for updates on these actions

Where any tests migrated to React Testing Library?

No

How do we deploy this PR?

  • Merge into the dsa-launchpad branch
  • Eventually merge the dsa-launchpad branch into develop
  • Release
  • Ensure appropriate indices (described above) are applied to any mongo instances using the notification features

Comment on lines +260 to +265
await ctx.notifications.create(ctx.tenant.id, ctx.tenant.locale, {
targetUserID: comment.authorID!,
comment,
type: NotificationType.COMMENT_FEATURED,
});

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@marcushaddon and @kabeaty, this is what it looks like to publish a notification for a user. All you need is access to the ctx.notifications which is available for every query and mutation in Coral's API.

The content of the notification is also malleable and has many optional fields. It can also be extended to provide new interface types for various kinds of notifications. It's all very flexible to whatever needs to be inside the notification.

As well, there is a convenient NotificationType to categorize the notifications and is infinite in how many kinds it can be, but adds a type that makes it easy to create/sort/filter notifications in the future.

This is what I mean by a one-liner to publish a notification anywhere. This isn't relevant for either of your DSA work, but it shows how minimal it will be to send new notifications throughout both of your's code.

Copy link
Contributor

@kabeaty kabeaty left a comment

Choose a reason for hiding this comment

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

Very nice initial framework for notifications to keep building on and extending!

client/src/core/client/stream/App/TabBar.tsx Outdated Show resolved Hide resolved
show active bell icon when new notifications are available
this allows us to clear the notifications red dot when
the user has viewed it and also in future, if we want to,
hook it into a websocket or similar live update-able value.
@nick-funk nick-funk force-pushed the feat/dsa-notifications branch from f872d90 to cd33c2b Compare October 25, 2023 22:55
Copy link
Contributor

@kabeaty kabeaty left a comment

Choose a reason for hiding this comment

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

Echoing my previous review, fantastic framework for notifications set up here! Just left a few small comments/questions throughout.

The `publicID` was changed to `referenceID` on the DSA report model.
Update the report details model on the notifications to match.
@nick-funk nick-funk marked this pull request as ready for review November 9, 2023 17:56
@nick-funk nick-funk merged commit 167cb14 into feat/dsa-launch-pad Nov 9, 2023
@nick-funk nick-funk deleted the feat/dsa-notifications branch November 9, 2023 17:56
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.

2 participants