diff options
author | David Baker <dave@matrix.org> | 2016-04-19 14:24:36 +0100 |
---|---|---|
committer | David Baker <dave@matrix.org> | 2016-04-19 14:24:36 +0100 |
commit | 07d765209dea12229e70a09784e647611acabcda (patch) | |
tree | 08a6e675544322049e0e9ed014afed8a77aa4a78 /synapse/storage/pusher.py | |
parent | Merge pull request #735 from matrix-org/erikj/media_resource_cleanup (diff) | |
download | synapse-07d765209dea12229e70a09784e647611acabcda.tar.xz |
First bits of emailpusher
Mostly logic of when to send an email
Diffstat (limited to 'synapse/storage/pusher.py')
-rw-r--r-- | synapse/storage/pusher.py | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/synapse/storage/pusher.py b/synapse/storage/pusher.py index e5755c0aea..caef9b59a5 100644 --- a/synapse/storage/pusher.py +++ b/synapse/storage/pusher.py @@ -230,3 +230,30 @@ class PusherStore(SQLBaseStore): {'failing_since': failing_since}, desc="update_pusher_failing_since", ) + + @defer.inlineCallbacks + def get_throttle_params_by_room(self, pusher_id): + res = yield self._simple_select_list( + "pusher_throttle", + {"pusher": pusher_id}, + ["room_id", "last_sent_ts", "throttle_ms"], + desc="get_throttle_params_by_room" + ) + + params_by_room = {} + for row in res: + params_by_room[row["room_id"]] = { + "last_sent_ts": row["last_sent_ts"], + "throttle_ms": row["throttle_ms"] + } + + defer.returnValue(params_by_room) + + @defer.inlineCallbacks + def set_throttle_params(self, pusher_id, room_id, params): + yield self._simple_upsert( + "pusher_throttle", + {"pusher": pusher_id, "room_id": room_id}, + params, + desc="set_throttle_params" + ) \ No newline at end of file |