Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Commit

Permalink
Require device language when adding a pusher.
Browse files Browse the repository at this point in the history
Because this seems like it might be useful to do sooner rather
than later.
  • Loading branch information
dbkr committed Jan 16, 2015
1 parent 2ca2dbc commit 2d2953c
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 5 deletions.
8 changes: 5 additions & 3 deletions synapse/push/pusherpool.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def start(self):

@defer.inlineCallbacks
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
# will then get pulled out of the database,
# recreated, added and started: this means we have only one
Expand All @@ -54,6 +54,7 @@ def add_pusher(self, user_name, kind, app_id,
"device_display_name": device_display_name,
"pushkey": pushkey,
"pushkey_ts": self.hs.get_clock().time_msec(),
"lang": lang,
"data": data,
"last_token": None,
"last_success": None,
Expand All @@ -62,13 +63,13 @@ def add_pusher(self, user_name, kind, app_id,
yield self._add_pusher_to_store(
user_name, kind, app_id,
app_display_name, device_display_name,
pushkey, data
pushkey, lang, data
)

@defer.inlineCallbacks
def _add_pusher_to_store(self, user_name, kind, app_id,
app_display_name, device_display_name,
pushkey, data):
pushkey, lang, data):
yield self.store.add_pusher(
user_name=user_name,
kind=kind,
Expand All @@ -77,6 +78,7 @@ def _add_pusher_to_store(self, user_name, kind, app_id,
device_display_name=device_display_name,
pushkey=pushkey,
pushkey_ts=self.hs.get_clock().time_msec(),
lang=lang,
data=json.dumps(data)
)
self._refresh_pusher((app_id, pushkey))
Expand Down
3 changes: 2 additions & 1 deletion synapse/rest/pusher.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def on_POST(self, request):
content = _parse_json(request)

reqd = ['kind', 'app_id', 'app_display_name',
'device_display_name', 'pushkey', 'data']
'device_display_name', 'pushkey', 'lang', 'data']
missing = []
for i in reqd:
if i not in content:
Expand All @@ -50,6 +50,7 @@ def on_POST(self, request):
app_display_name=content['app_display_name'],
device_display_name=content['device_display_name'],
pushkey=content['pushkey'],
lang=content['lang'],
data=content['data']
)
except PusherConfigException as pce:
Expand Down
3 changes: 2 additions & 1 deletion synapse/storage/pusher.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ def get_all_pushers(self):
@defer.inlineCallbacks
def add_pusher(self, user_name, kind, app_id,
app_display_name, device_display_name,
pushkey, pushkey_ts, data):
pushkey, pushkey_ts, lang, data):
try:
yield self._simple_upsert(
PushersTable.table_name,
Expand All @@ -108,6 +108,7 @@ def add_pusher(self, user_name, kind, app_id,
app_display_name=app_display_name,
device_display_name=device_display_name,
ts=pushkey_ts,
lang=lang,
data=data
))
except Exception as e:
Expand Down
1 change: 1 addition & 0 deletions synapse/storage/schema/delta/v10.sql
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ CREATE TABLE IF NOT EXISTS pushers (
device_display_name varchar(128) NOT NULL,
pushkey blob NOT NULL,
ts BIGINT NOT NULL,
lang varchar(8),
data blob,
last_token TEXT,
last_success BIGINT,
Expand Down
1 change: 1 addition & 0 deletions synapse/storage/schema/pusher.sql
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ CREATE TABLE IF NOT EXISTS pushers (
device_display_name varchar(128) NOT NULL,
pushkey blob NOT NULL,
ts BIGINT NOT NULL,
lang varchar(8),
data blob,
last_token TEXT,
last_success BIGINT,
Expand Down

0 comments on commit 2d2953c

Please sign in to comment.