Require device language when adding a pusher.

Because this seems like it might be useful to do sooner rather
than later.
pull/4/merge
David Baker 10 years ago
parent 2ca2dbc821
commit 2d2953cf5f
  1. 8
      synapse/push/pusherpool.py
  2. 3
      synapse/rest/pusher.py
  3. 3
      synapse/storage/pusher.py
  4. 1
      synapse/storage/schema/delta/v10.sql
  5. 1
      synapse/storage/schema/pusher.sql

@ -41,7 +41,7 @@ class PusherPool:
@defer.inlineCallbacks @defer.inlineCallbacks
def add_pusher(self, user_name, kind, app_id, def add_pusher(self, user_name, kind, app_id,
app_display_name, device_display_name, pushkey, data): app_display_name, device_display_name, pushkey, lang, data):
# we try to create the pusher just to validate the config: it # we try to create the pusher just to validate the config: it
# will then get pulled out of the database, # will then get pulled out of the database,
# recreated, added and started: this means we have only one # recreated, added and started: this means we have only one
@ -54,6 +54,7 @@ class PusherPool:
"device_display_name": device_display_name, "device_display_name": device_display_name,
"pushkey": pushkey, "pushkey": pushkey,
"pushkey_ts": self.hs.get_clock().time_msec(), "pushkey_ts": self.hs.get_clock().time_msec(),
"lang": lang,
"data": data, "data": data,
"last_token": None, "last_token": None,
"last_success": None, "last_success": None,
@ -62,13 +63,13 @@ class PusherPool:
yield self._add_pusher_to_store( yield self._add_pusher_to_store(
user_name, kind, app_id, user_name, kind, app_id,
app_display_name, device_display_name, app_display_name, device_display_name,
pushkey, data pushkey, lang, data
) )
@defer.inlineCallbacks @defer.inlineCallbacks
def _add_pusher_to_store(self, user_name, kind, app_id, def _add_pusher_to_store(self, user_name, kind, app_id,
app_display_name, device_display_name, app_display_name, device_display_name,
pushkey, data): pushkey, lang, data):
yield self.store.add_pusher( yield self.store.add_pusher(
user_name=user_name, user_name=user_name,
kind=kind, kind=kind,
@ -77,6 +78,7 @@ class PusherPool:
device_display_name=device_display_name, device_display_name=device_display_name,
pushkey=pushkey, pushkey=pushkey,
pushkey_ts=self.hs.get_clock().time_msec(), pushkey_ts=self.hs.get_clock().time_msec(),
lang=lang,
data=json.dumps(data) data=json.dumps(data)
) )
self._refresh_pusher((app_id, pushkey)) self._refresh_pusher((app_id, pushkey))

@ -32,7 +32,7 @@ class PusherRestServlet(RestServlet):
content = _parse_json(request) content = _parse_json(request)
reqd = ['kind', 'app_id', 'app_display_name', reqd = ['kind', 'app_id', 'app_display_name',
'device_display_name', 'pushkey', 'data'] 'device_display_name', 'pushkey', 'lang', 'data']
missing = [] missing = []
for i in reqd: for i in reqd:
if i not in content: if i not in content:
@ -50,6 +50,7 @@ class PusherRestServlet(RestServlet):
app_display_name=content['app_display_name'], app_display_name=content['app_display_name'],
device_display_name=content['device_display_name'], device_display_name=content['device_display_name'],
pushkey=content['pushkey'], pushkey=content['pushkey'],
lang=content['lang'],
data=content['data'] data=content['data']
) )
except PusherConfigException as pce: except PusherConfigException as pce:

@ -94,7 +94,7 @@ class PusherStore(SQLBaseStore):
@defer.inlineCallbacks @defer.inlineCallbacks
def add_pusher(self, user_name, kind, app_id, def add_pusher(self, user_name, kind, app_id,
app_display_name, device_display_name, app_display_name, device_display_name,
pushkey, pushkey_ts, data): pushkey, pushkey_ts, lang, data):
try: try:
yield self._simple_upsert( yield self._simple_upsert(
PushersTable.table_name, PushersTable.table_name,
@ -108,6 +108,7 @@ class PusherStore(SQLBaseStore):
app_display_name=app_display_name, app_display_name=app_display_name,
device_display_name=device_display_name, device_display_name=device_display_name,
ts=pushkey_ts, ts=pushkey_ts,
lang=lang,
data=data data=data
)) ))
except Exception as e: except Exception as e:

@ -22,6 +22,7 @@ CREATE TABLE IF NOT EXISTS pushers (
device_display_name varchar(128) NOT NULL, device_display_name varchar(128) NOT NULL,
pushkey blob NOT NULL, pushkey blob NOT NULL,
ts BIGINT NOT NULL, ts BIGINT NOT NULL,
lang varchar(8),
data blob, data blob,
last_token TEXT, last_token TEXT,
last_success BIGINT, last_success BIGINT,

@ -22,6 +22,7 @@ CREATE TABLE IF NOT EXISTS pushers (
device_display_name varchar(128) NOT NULL, device_display_name varchar(128) NOT NULL,
pushkey blob NOT NULL, pushkey blob NOT NULL,
ts BIGINT NOT NULL, ts BIGINT NOT NULL,
lang varchar(8),
data blob, data blob,
last_token TEXT, last_token TEXT,
last_success BIGINT, last_success BIGINT,

Loading…
Cancel
Save