mirror of
https://mau.dev/maunium/synapse.git
synced 2024-12-15 01:44:02 +01:00
Tidy up get_pusher functions
Decodes pushers rows on the main thread rather than the db thread and uses _simple_select_list. Also do the same to the function I copied and factor out the duplication into a helper function.
This commit is contained in:
parent
7b39bcdaae
commit
44891b4a0a
1 changed files with 29 additions and 31 deletions
|
@ -56,43 +56,41 @@ class PusherStore(SQLBaseStore):
|
||||||
)
|
)
|
||||||
defer.returnValue(ret is not None)
|
defer.returnValue(ret is not None)
|
||||||
|
|
||||||
@defer.inlineCallbacks
|
|
||||||
def get_pushers_by_app_id_and_pushkey(self, app_id, pushkey):
|
def get_pushers_by_app_id_and_pushkey(self, app_id, pushkey):
|
||||||
def r(txn):
|
return self.get_pushers_by({
|
||||||
sql = (
|
"app_id": app_id,
|
||||||
"SELECT * FROM pushers"
|
"pushkey": pushkey,
|
||||||
" WHERE app_id = ? AND pushkey = ?"
|
})
|
||||||
)
|
|
||||||
|
|
||||||
txn.execute(sql, (app_id, pushkey,))
|
def get_pushers_by_user_id(self, user_id):
|
||||||
rows = self.cursor_to_dict(txn)
|
return self.get_pushers_by({
|
||||||
|
"user_name": user_id,
|
||||||
return self._decode_pushers_rows(rows)
|
})
|
||||||
|
|
||||||
rows = yield self.runInteraction(
|
|
||||||
"get_pushers_by_app_id_and_pushkey", r
|
|
||||||
)
|
|
||||||
|
|
||||||
defer.returnValue(rows)
|
|
||||||
|
|
||||||
@defer.inlineCallbacks
|
@defer.inlineCallbacks
|
||||||
def get_pushers_by_user_id(self, user_id):
|
def get_pushers_by(self, keyvalues):
|
||||||
def r(txn):
|
ret = yield self._simple_select_list(
|
||||||
sql = (
|
"pushers", keyvalues,
|
||||||
"SELECT * FROM pushers"
|
[
|
||||||
" WHERE user_name = ?"
|
"id",
|
||||||
)
|
"user_name",
|
||||||
|
"access_token",
|
||||||
|
"profile_tag",
|
||||||
|
"kind",
|
||||||
|
"app_id",
|
||||||
|
"app_display_name",
|
||||||
|
"device_display_name",
|
||||||
|
"pushkey",
|
||||||
|
"ts",
|
||||||
|
"lang",
|
||||||
|
"data",
|
||||||
|
"last_stream_ordering",
|
||||||
|
"last_success",
|
||||||
|
"failing_since",
|
||||||
|
|
||||||
txn.execute(sql, (user_id,))
|
]
|
||||||
rows = self.cursor_to_dict(txn)
|
|
||||||
|
|
||||||
return self._decode_pushers_rows(rows)
|
|
||||||
|
|
||||||
result = yield self.runInteraction(
|
|
||||||
"get_pushers_by_user_id", r
|
|
||||||
)
|
)
|
||||||
|
defer.returnValue(self._decode_pushers_rows(ret))
|
||||||
defer.returnValue(result)
|
|
||||||
|
|
||||||
@defer.inlineCallbacks
|
@defer.inlineCallbacks
|
||||||
def get_all_pushers(self):
|
def get_all_pushers(self):
|
||||||
|
|
Loading…
Reference in a new issue