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

Commit

Permalink
Add database support for ephemeral messages
Browse files Browse the repository at this point in the history
  • Loading branch information
babolivier committed Nov 25, 2019
1 parent 9cc168e commit c982380
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 0 deletions.
26 changes: 26 additions & 0 deletions synapse/storage/data_stores/main/events.py
Original file line number Diff line number Diff line change
Expand Up @@ -1956,6 +1956,32 @@ def insert_labels_for_event_txn(
],
)

def insert_event_expiry(self, event_id, expiry_ts):
return self._simple_insert(
table="event_expiry",
values={
"event_id": event_id,
"expiry_ts": expiry_ts,
},
desc="insert_event_expiry",
)

def delete_event_expiry(self, event_id):
return self._simple_delete(
table="event_expiry",
keyvalues={"event_id": event_id},
desc="delete_event_expiry",
)

def get_events_to_expire(self):
return self._simple_select_list(
table="event_expiry",
keyvalues=None,
retcols=["event_id", "expiry_ts"],
desc="get_events_to_expire",
)



AllNewEventsResult = namedtuple(
"AllNewEventsResult",
Expand Down
19 changes: 19 additions & 0 deletions synapse/storage/data_stores/main/schema/delta/56/event_expiry.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/* Copyright 2019 The Matrix.org Foundation C.I.C.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

CREATE TABLE IF NOT EXISTS event_expiry (
event_id TEXT PRIMARY KEY,
expiry_ts BIGINT NOT NULL
);

0 comments on commit c982380

Please sign in to comment.