mirror of
https://git.anonymousland.org/anonymousland/synapse.git
synced 2025-05-02 09:56:05 -04:00
Honour the 'rejected' return from push gateways
Add a timestamp to push tokens so we know the last time they we got them from the device. Send it to the push gateways so it can determine whether its failure is more recent than the token. Stop and remove pushers that have been rejected.
This commit is contained in:
parent
c06a9063e1
commit
2cb30767fa
6 changed files with 81 additions and 19 deletions
|
@ -25,8 +25,8 @@ logger = logging.getLogger(__name__)
|
|||
|
||||
class HttpPusher(Pusher):
|
||||
def __init__(self, _hs, user_name, app_id,
|
||||
app_display_name, device_display_name, pushkey, data,
|
||||
last_token, last_success, failing_since):
|
||||
app_display_name, device_display_name, pushkey, pushkey_ts,
|
||||
data, last_token, last_success, failing_since):
|
||||
super(HttpPusher, self).__init__(
|
||||
_hs,
|
||||
user_name,
|
||||
|
@ -34,6 +34,7 @@ class HttpPusher(Pusher):
|
|||
app_display_name,
|
||||
device_display_name,
|
||||
pushkey,
|
||||
pushkey_ts,
|
||||
data,
|
||||
last_token,
|
||||
last_success,
|
||||
|
@ -77,6 +78,7 @@ class HttpPusher(Pusher):
|
|||
{
|
||||
'app_id': self.app_id,
|
||||
'pushkey': self.pushkey,
|
||||
'pushkeyTs': long(self.pushkey_ts / 1000),
|
||||
'data': self.data_minus_url
|
||||
}
|
||||
]
|
||||
|
@ -87,10 +89,13 @@ class HttpPusher(Pusher):
|
|||
def dispatch_push(self, event):
|
||||
notification_dict = self._build_notification_dict(event)
|
||||
if not notification_dict:
|
||||
defer.returnValue(True)
|
||||
defer.returnValue([])
|
||||
try:
|
||||
yield self.httpCli.post_json_get_json(self.url, notification_dict)
|
||||
resp = yield self.httpCli.post_json_get_json(self.url, notification_dict)
|
||||
except:
|
||||
logger.exception("Failed to push %s ", self.url)
|
||||
defer.returnValue(False)
|
||||
defer.returnValue(True)
|
||||
rejected = []
|
||||
if 'rejected' in resp:
|
||||
rejected = resp['rejected']
|
||||
defer.returnValue(rejected)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue