diff options
author | David Baker <dave@matrix.org> | 2016-05-23 18:33:51 +0100 |
---|---|---|
committer | David Baker <dave@matrix.org> | 2016-05-23 18:33:51 +0100 |
commit | a24bc5b2dc3a5d81cdfbe7be367dbb461d85b999 (patch) | |
tree | 594f9f3756483fe33880e0aba9fadf6e023dd58e /synapse/storage/event_push_actions.py | |
parent | Remove debug logging (diff) | |
download | synapse-a24bc5b2dc3a5d81cdfbe7be367dbb461d85b999.tar.xz |
Add GET /notifications API
Diffstat (limited to 'synapse/storage/event_push_actions.py')
-rw-r--r-- | synapse/storage/event_push_actions.py | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/synapse/storage/event_push_actions.py b/synapse/storage/event_push_actions.py index 4dae51a172..a9cb042b5a 100644 --- a/synapse/storage/event_push_actions.py +++ b/synapse/storage/event_push_actions.py @@ -192,6 +192,34 @@ class EventPushActionsStore(SQLBaseStore): ]) @defer.inlineCallbacks + def get_push_actions_for_user(self, user_id, before=None, limit=50): + def f(txn): + before_clause = "" + if before: + before_clause = "AND stream_ordering < ?" + args = [user_id, before, limit] + else: + args = [user_id, limit] + sql = ( + "SELECT event_id, room_id, stream_ordering, topological_ordering," + " actions, profile_tag" + " FROM event_push_actions" + " WHERE user_id = ? %s" + " ORDER BY stream_ordering DESC" + " LIMIT ?" + % (before_clause,) + ) + txn.execute(sql, args) + return self.cursor_to_dict(txn) + + push_actions = yield self.runInteraction( + "get_push_actions_for_user", f + ) + for pa in push_actions: + pa["actions"] = json.loads(pa["actions"]) + defer.returnValue(push_actions) + + @defer.inlineCallbacks def get_time_of_last_push_action_before(self, stream_ordering): def f(txn): sql = ( |