Skip to content

Commit

Permalink
Refactor based on comments
Browse files Browse the repository at this point in the history
Signed-off-by: jamshale <jamiehalebc@gmail.com>
  • Loading branch information
jamshale committed Mar 6, 2024
1 parent 64990d2 commit bb6d6b0
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 16 deletions.
20 changes: 10 additions & 10 deletions firebase_push_notifications/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@ participant Mobile
participant Mediator
Note left of Mobile: Logs In
Note left of Mobile: Checks if already registered
Mobile-->Mediator: Do you support firebase protocol?
Mediator-->Mobile: No
Mobile->>Mediator: Do you support firebase protocol?
Mediator->>Mobile: No
Note left of Mobile: Do Nothing
Mediator-->Mobile: Yes
Mediator->>Mobile: Yes
Note left of Mobile: Open notification Permission Modal
Mobile->Mobile: User says "not now"
Note left of Mobile: Close Modal and set user denied to true
Mobile->Mobile: User says "Allow"
Mobile-->Mediator: Send device token
Mobile->>Mediator: Send device token
Note right of Mediator: Save device token for conenction
Mobile->Mobile: OS permissions popup
Note left of Mobile: Approve or deny OS level permission
Expand All @@ -33,27 +33,27 @@ participant Mediator
participant Mobile (Alice)
participant Firebase
Note left of Agent (Faber): Wants to send message to Mobile (Alice)
Agent (Faber)-->Mediator: Message
Mediator-->Mobile (Alice): Message
Agent (Faber)->>Mediator: Message
Mediator->>Mobile (Alice): Message
Mediator->Mediator: Receives Forwarding event in aca-py
Note right of Mediator: Get device token for connection
Mediator->Mediator: token is blank or None
Note right of Mediator: Do nothing
Mediator->Mediator: message sent withing 'n' minutes
Note right of Mediator: Do nothing
Mediator->Mediator: Token exists
Mediator-->Firebase: Request: Send OS notification to token
Firebase-->Mobile (Alice): Sends OS notification
Mediator->>Firebase: Request: Send OS notification to token
Firebase->>Mobile (Alice): Sends OS notification
```

### Disable/Enable
``` mermaid
sequenceDiagram
participant Mobile
participant Mediator
Mobile-->Mediator: Sends blank token
Mobile->>Mediator: Sends blank token
Note right of Mediator: Saves blank token (disabled)
Mobile-->Mediator: Sends device token
Mobile->>Mediator: Sends device token
Note right of Mediator: Saves device token (enabled)
```

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,6 @@ async def send_message(profile, connection_id):
session, connection_id
)
except StorageNotFoundError as e:
LOGGER.debug(
f"Could not retrieve device token for connection {connection_id} : {e}"
)
return

""" Don't send token if it is blank. This is the same as being disabled """
Expand All @@ -68,12 +65,12 @@ async def send_message(profile, connection_id):
if record.sent_time is not None and parser.parse(
record.sent_time
) > datetime_now() - timedelta(minutes=MAX_SEND_RATE_MINUTES):
LOGGER.info(
LOGGER.debug(
f"Connection {connection_id} was sent a push notification within the last {MAX_SEND_RATE_MINUTES} minutes. Skipping." # noqa: E501
)
return

LOGGER.info(
LOGGER.debug(
f"Sending push notification to firebase from connection: {connection_id}"
)

Expand Down Expand Up @@ -109,7 +106,7 @@ async def send_message(profile, connection_id):
)

if resp.status_code == 200:
LOGGER.info(
LOGGER.debug(
f"Successfully sent message to firebase for delivery. response: {resp.text}" # noqa: E501
)
record.sent_time = time_now()
Expand Down

0 comments on commit bb6d6b0

Please sign in to comment.