mirror of
https://git.anonymousland.org/anonymousland/synapse.git
synced 2025-05-04 01:04:48 -04:00
Verify ?chunk_id
actually corresponds to an insertion event that exists (MSC2716) (#10776)
This commit is contained in:
parent
1c555527b3
commit
145c006ef7
4 changed files with 51 additions and 1 deletions
36
synapse/storage/databases/main/room_batch.py
Normal file
36
synapse/storage/databases/main/room_batch.py
Normal file
|
@ -0,0 +1,36 @@
|
|||
# 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
|
||||
|
||||
|
||||
class RoomBatchStore(SQLBaseStore):
|
||||
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,
|
||||
)
|
Loading…
Add table
Add a link
Reference in a new issue