Merge branch 'develop' into push_badge_counts

This commit is contained in:
David Baker 2016-01-19 18:17:23 +00:00
commit afb7b377f2
35 changed files with 1043 additions and 1246 deletions

View file

@ -37,14 +37,14 @@ class PusherPool:
self._start_pushers(pushers)
@defer.inlineCallbacks
def add_pusher(self, user_name, access_token, profile_tag, kind, app_id,
def add_pusher(self, user_id, access_token, profile_tag, kind, app_id,
app_display_name, device_display_name, pushkey, lang, data):
# we try to create the pusher just to validate the config: it
# will then get pulled out of the database,
# recreated, added and started: this means we have only one
# code path adding pushers.
self._create_pusher({
"user_name": user_name,
"user_name": user_id,
"kind": kind,
"profile_tag": profile_tag,
"app_id": app_id,
@ -59,7 +59,7 @@ class PusherPool:
"failing_since": None
})
yield self._add_pusher_to_store(
user_name, access_token, profile_tag, kind, app_id,
user_id, access_token, profile_tag, kind, app_id,
app_display_name, device_display_name,
pushkey, lang, data
)
@ -94,11 +94,11 @@ class PusherPool:
self.remove_pusher(p['app_id'], p['pushkey'], p['user_name'])
@defer.inlineCallbacks
def _add_pusher_to_store(self, user_name, access_token, profile_tag, kind,
def _add_pusher_to_store(self, user_id, access_token, profile_tag, kind,
app_id, app_display_name, device_display_name,
pushkey, lang, data):
yield self.store.add_pusher(
user_name=user_name,
user_id=user_id,
access_token=access_token,
profile_tag=profile_tag,
kind=kind,
@ -110,14 +110,14 @@ class PusherPool:
lang=lang,
data=data,
)
self._refresh_pusher(app_id, pushkey, user_name)
self._refresh_pusher(app_id, pushkey, user_id)
def _create_pusher(self, pusherdict):
if pusherdict['kind'] == 'http':
return HttpPusher(
self.hs,
profile_tag=pusherdict['profile_tag'],
user_name=pusherdict['user_name'],
user_id=pusherdict['user_name'],
app_id=pusherdict['app_id'],
app_display_name=pusherdict['app_display_name'],
device_display_name=pusherdict['device_display_name'],
@ -135,14 +135,14 @@ class PusherPool:
)
@defer.inlineCallbacks
def _refresh_pusher(self, app_id, pushkey, user_name):
def _refresh_pusher(self, app_id, pushkey, user_id):
resultlist = yield self.store.get_pushers_by_app_id_and_pushkey(
app_id, pushkey
)
p = None
for r in resultlist:
if r['user_name'] == user_name:
if r['user_name'] == user_id:
p = r
if p:
@ -171,12 +171,12 @@ class PusherPool:
logger.info("Started pushers")
@defer.inlineCallbacks
def remove_pusher(self, app_id, pushkey, user_name):
fullid = "%s:%s:%s" % (app_id, pushkey, user_name)
def remove_pusher(self, app_id, pushkey, user_id):
fullid = "%s:%s:%s" % (app_id, pushkey, user_id)
if fullid in self.pushers:
logger.info("Stopping pusher %s", fullid)
self.pushers[fullid].stop()
del self.pushers[fullid]
yield self.store.delete_pusher_by_app_id_pushkey_user_name(
app_id, pushkey, user_name
yield self.store.delete_pusher_by_app_id_pushkey_user_id(
app_id, pushkey, user_id
)