This repository has been archived by the owner on Apr 26, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Verify ?chunk_id actually corresponds to an insertion event that exists
Part of #10737 Part of [MSC2716](matrix-org/matrix-spec-proposals#2716)
- Loading branch information
1 parent
857b000
commit 0fe8e5d
Showing
3 changed files
with
54 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
# Copyright 2021 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. | ||
|
||
from typing import Optional | ||
|
||
from synapse.storage._base import SQLBaseStore | ||
from synapse.storage.database import DatabasePool | ||
|
||
|
||
class RoomBatchStore(SQLBaseStore): | ||
def __init__(self, database: DatabasePool, db_conn, hs): | ||
super().__init__(database, db_conn, hs) | ||
|
||
async def get_insertion_event_by_chunk_id(self, chunk_id: str) -> Optional[str]: | ||
"""Retrieve a insertion event ID. | ||
Args: | ||
chunk_id: The chunk ID of the insertion event to retrieve. | ||
Returns: | ||
The event_id of an insertion event, or None if there is no known | ||
insertion event for the given insertion event. | ||
""" | ||
return await self.db_pool.simple_select_one_onecol( | ||
table="insertion_events", | ||
keyvalues={"next_chunk_id": chunk_id}, | ||
retcol="event_id", | ||
allow_none=True, | ||
) |