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

feat(notify): message idempotency/storage & webhook refactor #161

Open
wants to merge 11 commits into
base: main-lfs-DO-NOT-USE
Choose a base branch
from

Conversation

chris13524
Copy link
Member

@chris13524 chris13524 commented Oct 9, 2023

  • Add id to notifyMessage (ensures message ID can be used for client deduplication, and also provides method to acknowledge, send read receipts, etc.)
  • Add notificationId to /notify endpoint, which makes the endpoint idempotent
  • Allow sending multiple notifications in a single network request to enable use cases where each account may gets different notification content. Scaling should be unchanged.
  • Add webhook authentication & idempotency
  • Correct the current specs with <project-id> parameter
  • Add /v1 prefix

Send Notification and Notification Status APIs subject to change upon discovering real-world implementation scalability challenges. For example, it may make sense to respond with not-subscribed, wrong-scope, and rate-limited in the initial request, rather than requiring a second call to get this information.

Potential TODOs:

  • Add how rate limiting is implemented
  • How queueing is implemented

@chris13524 chris13524 self-assigned this Oct 9, 2023
@vercel
Copy link

vercel bot commented Oct 9, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
walletconnect-specs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Nov 8, 2023 3:03pm

@chris13524 chris13524 changed the title feat: messaging refactor feat(notify): notify server messages refactor Oct 9, 2023
@chris13524 chris13524 changed the title feat(notify): notify server messages refactor feat(notify): message storage & webhook refactor Oct 19, 2023
@chris13524 chris13524 marked this pull request as ready for review October 19, 2023 18:07
@chris13524 chris13524 changed the title feat(notify): message storage & webhook refactor feat(notify): message ID & webhook refactor Oct 19, 2023
@chris13524 chris13524 changed the title feat(notify): message ID & webhook refactor feat(notify): message idempotency/storage & webhook refactor Oct 19, 2023
Comment on lines 22 to 23
icon?: string | null,
url?: string | null,
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't be nullable

Copy link
Member Author

Choose a reason for hiding this comment

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

@Elyniss it should because this is the Notify API endpoint. null will be translated to "" by the Notify Server

"type": string,
type Body = [{
// Idempotency key and ID to track status
notificationId?: string | null,
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we really need to give the ability to provide the ID for a new notification? For me, server-generated IDs look more consistent, and does the client need this ability? cc @chris13524

Copy link
Member Author

@chris13524 chris13524 Oct 25, 2023

Choose a reason for hiding this comment

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

The primary purpose of this ID is actually for idempotency.

We can have an idempotencyKey field instead, and require the client to read the response in order to call the status endpoint. But I figured it's a slightly nicer API for the caller to be able to specify their own IDs in order to avoid storing the response to their database if they already have notification IDs on their end.

In my approach this notificationId would be dapp-facing only, unique key being separate per-dapp, and the pk of the database would still be a server-generated UUID. Happy with either approach really, but we need idempotency.

string
type Response = {
// IDs for the sent notifications returned in the same order as the body. If a `notificationId` wasn't specified in the request, one will be generated.
notifications: string[],
Copy link
Contributor

Choose a reason for hiding this comment

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

With the queuing behavior now, are consumers of this API expected to query all the messages they sent until they either get published or some of the error statuses?

Not sure if I missed something here

Copy link
Member Author

Choose a reason for hiding this comment

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

are consumers of this API expected to query all the messages they sent until they either get published or some of the error statuses?

Yes, but only if they want to know the status. However I suppose this is polling so would be good to have a webhook option for this as well.

Copy link
Contributor

Choose a reason for hiding this comment

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

yes - I think a webhook option would make sense. Polling would be absurd for all the different notification ids

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.

5 participants