-
Notifications
You must be signed in to change notification settings - Fork 0
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
Add push messaging (+ other assorted improvements) #140
Draft
Rumperuu
wants to merge
369
commits into
development
Choose a base branch
from
ben/feature/push-notifications
base: development
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Release of category API and admin interface
Category budget view added with test
Updated data view
Placeholder medal and endpoint added
Added placeholder API for user points
Rumperuu
changed the title
Push Notifications
Add Push Messaging (+ other assorted improvements)
Mar 20, 2021
Rumperuu
changed the title
Add Push Messaging (+ other assorted improvements)
Add push messaging (+ other assorted improvements)
Mar 20, 2021
This was
linked to
issues
Mar 21, 2021
This was
linked to
issues
Mar 25, 2021
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
NB Travis fails because it can't find the file
./localspend-47012.json
, which contains the connection details for the Firebase Cloud Messaging service. This contains sensitive data and shouldn't be tracked, so I'm not sure how to handle this in Travis.This PR was originally intended to only add push notification functionality to the server. However, it has since expanded to into a bit of a monolith, which certainly isn't ideal and should be avoided in future, but I think I'm the only person working on this at the moment so it shouldn't cause any major issues.
This PR adds the following:
stern
level, though not without some strange issues that had to be suppressed—see ‘Subroutine name is a homonym for builtin function’ #152);Push Notifications
The message sending functionality uses Firebase Cloud Messaging (though I would like to look into alternatives to this in the future).
First, three new tables have been added to the database:
topics
, storing subscribable topics (and a ‘default’ topic is now created along with the test users);device_tokens
, storing the device tokens of users who have granted permission to send push notifications; anduser_topic_subscriptions
, tracking user topic subscriptions.Eight new API routes have been added to
lib/Pear/LocalLoop.pm
:/device-token/check
;/device-token/add
;/device-tokens
;/topic/add
;/topics
;/topics/subscriptions
;/topics/update
; and/send-message
.These lead to three new modules in
lib/Pear/LocalLoop/Controller/Api/
:Devices.pm
;Topic.pm
; andSendmessage.pm
.Devices.pm
provides the following subroutines:check_exists()
, which checks whether a device token already exists in the database or not;create()
, which saves a new device token to the database; andget_all()
, which returns a list of all device tokens and their associated users.Topic.pm
provides the following subroutines:create()
, which creates a new topic; andget_all()
, which returns a list of all topics and the number of users subscribed to each.get_all_and_subscriptions()
, which returns a list of all topics and whether a given user is subscribed to them or not; andupdate_subscriptions()
, which updates a user's topic subscriptions.Sendmessage.pm
provides the following subroutines:create_jwt_from_path_and_scopes()
, which generates a JSON Web Token for a provided path and set of scopes;post_message()
, which sends the message and topic to the Firebase Cloud Messaging endpoint to be distributed to all subscribers.See also Pear-Trading/LocalSpend-Tracker#12 & Pear-Trading/FoodLoop-Web#124
Closes #133 #138 #141 #143 #146 #148 #149 #150 #159 #160
Progresses #153 #154