mirror of
https://github.com/samuelclay/NewsBlur.git
synced 2025-11-01 09:09:51 +00:00
Adding a sandbox designator for ios tokens so notifications can be received by testers. Has to be manually turned on for now.
This commit is contained in:
parent
0c19aec2a3
commit
a2f4215e40
2 changed files with 8 additions and 5 deletions
2
Makefile
2
Makefile
|
|
@ -71,7 +71,7 @@ build_web:
|
|||
build_node:
|
||||
- docker image build . --file=docker/node/Dockerfile --tag=newsblur/newsblur_node
|
||||
build: build_web build_node
|
||||
web_image:
|
||||
web_image: build_web
|
||||
- docker push newsblur/newsblur_python3
|
||||
node_image: build_node
|
||||
- docker push newsblur/newsblur_node
|
||||
|
|
|
|||
|
|
@ -35,6 +35,7 @@ class MUserNotificationTokens(mongo.Document):
|
|||
'''A user's push notification tokens'''
|
||||
user_id = mongo.IntField()
|
||||
ios_tokens = mongo.ListField(mongo.StringField(max_length=1024))
|
||||
use_sandbox = mongo.BooleanField(default=False)
|
||||
|
||||
meta = {
|
||||
'collection': 'notification_tokens',
|
||||
|
|
@ -239,9 +240,9 @@ class MUserFeedNotification(mongo.Document):
|
|||
def send_ios(self, story, user, usersub):
|
||||
if not self.is_ios: return
|
||||
|
||||
apns = APNsClient('/srv/newsblur/config/certificates/aps.pem', use_sandbox=False)
|
||||
|
||||
tokens = MUserNotificationTokens.get_tokens_for_user(self.user_id)
|
||||
apns = APNsClient('/srv/newsblur/config/certificates/aps.p12.pem', use_sandbox=tokens.use_sandbox)
|
||||
|
||||
notification_title_only = is_true(user.profile.preference_value('notification_title_only'))
|
||||
title, subtitle, body = self.title_and_body(story, usersub, notification_title_only)
|
||||
image_url = None
|
||||
|
|
@ -263,11 +264,13 @@ class MUserFeedNotification(mongo.Document):
|
|||
'image_url': image_url,
|
||||
})
|
||||
try:
|
||||
apns.send_notification(token, payload)
|
||||
apns.send_notification(token, payload, topic="com.newsblur.NewsBlur")
|
||||
except BadDeviceToken:
|
||||
logging.user(user, '~BMiOS token expired: ~FR~SB%s' % (token[:50]))
|
||||
else:
|
||||
confirmed_ios_tokens += token
|
||||
confirmed_ios_tokens.append(token)
|
||||
if settings.DEBUG:
|
||||
logging.user(user, '~BMiOS token good: ~FB~SB%s / %s' % (token[:50], len(confirmed_ios_tokens)))
|
||||
|
||||
if len(confirmed_ios_tokens) < len(tokens.ios_tokens):
|
||||
tokens.ios_tokens = confirmed_ios_tokens
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue