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

Create UnifiedPush UML diagrams #37

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added diagrams/unifiedPushMobile00.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
41 changes: 41 additions & 0 deletions diagrams/unifiedPushMobile00.puml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
@startuml unifiedPushMobile00
actor User
participant MobileApp
participant API
database Postgres
participant NtfyMobileApp
participant UPServer

User -> MobileApp : opens the app
MobileApp -> User : asks the user to accept notifications
User -> MobileApp : accepts notifications
MobileApp -> User : enables notifications
User -> MobileApp : tries to subscribe to notifications for a podcast
MobileApp -> User : prompts the user that notifications are a \npremium-only feature and to please login
User -> MobileApp : user logs in, and tries to subscribe \nto notifications for a podcast again
MobileApp -> User : shows the UnifiedPush setup modal
User -> MobileApp : inputs their UP endpoint hostname \nand presses the Register button

Choose a reason for hiding this comment

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

This is not User->MobileApp. The app calls the UnifiedPush library, UnifiedPush.registerApp() and the UnifiedPush library replies with the endpoint automatically in a call to onNewEndpoint() - https://unifiedpush.org/developers/android/#register-for-push

Copy link

Choose a reason for hiding this comment

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

User -> MobileApp : selects distributor if many are available on the device
MobileApp -> UPMobileApp : asks for an UP endpoint
UPMobileApp -> MobileApp : sends the UP endpoint
MobileApp -> API : sends the UP endpoint

MobileApp -> API : sends UP hostname in \nan authenticated request
API -> API : creates UP salted_topic_id
API -> Postgres : saves the UP hostname+salted_topic_id \nwith ManyToOne to User table \nin the unifiedPushToken table

Choose a reason for hiding this comment

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

And the API doesn't create the topic, the app receives it from the distributor, and it uses that topic. You have to treat the hostname+topic as one single URL, they're not separable.

Copy link
Member

Choose a reason for hiding this comment

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

@karmanyaahm (still learning)

Podverse would be required to each notifications to each and every hostname+topic

How would this properly scale?
What are the scaling limits?
Would/could we be blocked by a commonly used U.P. server?

Copy link

Choose a reason for hiding this comment

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

If you need to, you can use "instances" during (MobileApp -> Distributor) registration to have an endpoint per subject. You can also get a single endpoint for the app and push a content that will help to identify the podcast subject

Choose a reason for hiding this comment

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

How would this properly scale?
What are the scaling limits?
Would/could we be blocked by a commonly used U.P. server?

  1. Matrix servers send hundreds of messages per device per day, and we have fixed most rate limiting problems.
  2. Performance-wise, it shouldn't be a big deal because of connection reuse - as long as the requests are batched properly, node (or another runtime) should automatically send all the HTTP requests over one connection.
  3. Also, WebPush, the standard for push notifications to web browsers, uses the exact same model (unique endpoint for each device) and all services that push to web browsers use it.

Postgres -> API : success response
API -> MobileApp : returns the hostname+salted_topic_id
MobileApp -> NtfyMobileApp : registers hostname+salted_topic_id
NtfyMobileApp -> MobileApp : success response??
MobileApp -> User : shows UP notifications enabled message
User -> MobileApp : presses the Test button
MobileApp -> UPServer : posts Test notification body
UPServer -> NtfyMobileApp : receives Test notification
NtfyMobileApp -> User : presents Test notification to user
User -> MobileApp : presses the Unregister button
MobileApp -> API : sends authenticated remove unifiedPushToken request
API -> API : confirms the user has permission \nto remove it
API -> Postgres : sends delete unifiedPushToken \nrow request
Postgres -> Postgres : deletes the unifiedPushToken row
Postgres -> API : success response
API -> MobileApp : success response
MobileApp -> NtfyMobileApp : unregisters hostname+salted_topic_id
NtfyMobileApp -> MobileApp : success response??
MobileApp -> User : shows unregister successful message

@enduml
Binary file added diagrams/unifiedPushParser00.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
21 changes: 21 additions & 0 deletions diagrams/unifiedPushParser00.puml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
@startuml unifiedPushParser00
participant Parser
database Postgres
participant UPServer
participant NtfyMobileApp
participant MobileApp
actor User

Parser -> Parser : begins to parse a podcast RSS feed
Parser -> Parser : determines a notification \nshould be sent
Parser -> Postgres : queries for unifiedPushTokens \nthat should receive notifications
Postgres -> Parser : returns unifiedPushTokens
Parser -> Parser : groups the unifiedPushTokens \nby endpoint hostname
Parser -> UPServer : iterate over the groups\nto send unifiedPushTokens to \nbatch notify endpoints\nwith podcast and episode data\nin the request body
UPServer -> Parser : success response
UPServer -> NtfyMobileApp : pushes notification
NtfyMobileApp -> User : displays notification
User -> MobileApp : taps notification\nto open Podverse
Comment on lines +16 to +18

Choose a reason for hiding this comment

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

Suggested change
UPServer -> NtfyMobileApp : pushes notification
NtfyMobileApp -> User : displays notification
User -> MobileApp : taps notification\nto open Podverse
UPServer -> NtfyMobileApp : pushes notification
NtfyMobileApp -> MobileApp : forwards notification
MobileApp -> User: displays notification
User -> MobileApp : taps notification\nto open Podverse



@enduml