2021-09-15 04:34:30 -04:00
|
|
|
# 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):
|
2021-11-08 22:21:10 -05:00
|
|
|
async def get_insertion_event_id_by_batch_id(
|
2021-09-28 22:23:16 -04:00
|
|
|
self, room_id: str, batch_id: str
|
|
|
|
) -> Optional[str]:
|
2021-09-15 04:34:30 -04:00
|
|
|
"""Retrieve a insertion event ID.
|
|
|
|
|
|
|
|
Args:
|
2021-09-21 16:06:28 -04:00
|
|
|
batch_id: The batch ID of the insertion event to retrieve.
|
2021-09-15 04:34:30 -04:00
|
|
|
|
|
|
|
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",
|
2021-09-28 22:23:16 -04:00
|
|
|
keyvalues={"room_id": room_id, "next_batch_id": batch_id},
|
2021-09-15 04:34:30 -04:00
|
|
|
retcol="event_id",
|
|
|
|
allow_none=True,
|
|
|
|
)
|
2021-10-13 18:44:00 -04:00
|
|
|
|
|
|
|
async def store_state_group_id_for_event_id(
|
|
|
|
self, event_id: str, state_group_id: int
|
2021-11-11 11:49:28 -05:00
|
|
|
) -> None:
|
|
|
|
await self.db_pool.simple_upsert(
|
|
|
|
table="event_to_state_groups",
|
|
|
|
keyvalues={"event_id": event_id},
|
|
|
|
values={"state_group": state_group_id, "event_id": event_id},
|
|
|
|
)
|