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 #200

Merged
merged 8 commits into from
Sep 30, 2022
Merged

Notifications #200

merged 8 commits into from
Sep 30, 2022

Conversation

dholms
Copy link
Collaborator

@dholms dholms commented Sep 29, 2022

Notifications 🔔

Adds a notifications table that maintains a list of all notifications relevant to a user.

Adds views for

  • listing notifications
  • getting unread notification count
  • telling the server that the user has seen notifications after a certain time.

Handles notification reasons similarly to entity types: it's an unconstrained field, but there is a comment in the schema suggesting what expected values are.

For each notification, returns:

  • uri of the object that caused the notif
  • the author of the object
  • the record that caused the notif
  • the reason (like, repost, mention, etc)
  • the reasonSubject if applicable (for instance the uri of the post that was liked)
  • if the notif has been read
  • indexed time of the object that caused the notif

@@ -36,6 +36,7 @@ export default function (server: Server) {
)
.leftJoin(User, 'author', 'author.did = post.creator')
.where('user.did = :did', { did: requester })
.andWhere('post.creator != :requester', { requester })
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

we weren't returning a user's posts in their feed, but we were returning them if they were reposted, so this strips those out as well. can change this if we like

Copy link
Collaborator

Choose a reason for hiding this comment

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

Actually I think we need user's posts in their feed, but not the retweets? It can be confusing not to see your own posts

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Made an issue. i'll get to it soonish: #201


export default function (server: Server) {
server.todo.social.postNotificationsSeen(async (_params, input, req, res) => {
const { seenAt } = input.body
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

this allows any time to be set as seenAt i thought maybe doing the Max of seenAt & the currently registered time in the DB, but then thought there might be a usecase for "rewinding" notifications 🤔

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yeah probably no concern about auditing it

await Promise.all([
table.delete(uri),
recordTable.delete(uri.toString()),
this.notifications.deleteForRecord(uri),
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

removes notifications for deleted objects

@dholms dholms marked this pull request as ready for review September 30, 2022 00:24
Copy link
Collaborator

@pfrazee pfrazee left a comment

Choose a reason for hiding this comment

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

Looking good. Can merge as is, but I wonder if the reason token ought to be an NSID-based constant? Like app.bsky.likeEvent. Would need a new Lexicon doc type probably.

@dholms dholms merged commit 8b0884a into main Sep 30, 2022
@dholms dholms deleted the notifications branch September 30, 2022 16:09
mloar pushed a commit to mloar/atproto that referenced this pull request Nov 15, 2023
* notification methods on tables

* process notifs

* last seen

* notifs xrpc methods

* seen notifs route

* register route

* notifications tests

* rm unused db method
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