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

Commit

Permalink
Add un-partial-stated events stream
Browse files Browse the repository at this point in the history
  • Loading branch information
reivilibre committed Nov 24, 2022
1 parent 1de8222 commit 6768a6a
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 1 deletion.
6 changes: 5 additions & 1 deletion synapse/replication/tcp/streams/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,10 @@
)
from synapse.replication.tcp.streams.events import EventsStream
from synapse.replication.tcp.streams.federation import FederationStream
from synapse.replication.tcp.streams.partial_state import UnPartialStatedRoomStream
from synapse.replication.tcp.streams.partial_state import (
UnPartialStatedEventStream,
UnPartialStatedRoomStream,
)

STREAMS_MAP = {
stream.NAME: stream
Expand All @@ -63,6 +66,7 @@
AccountDataStream,
UserSignatureStream,
UnPartialStatedRoomStream,
UnPartialStatedEventStream,
)
}

Expand Down
28 changes: 28 additions & 0 deletions synapse/replication/tcp/streams/partial_state.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,31 @@ def __init__(self, hs: "HomeServer"):
current_token_without_instance(store.get_un_partial_stated_rooms_token),
store.get_un_partial_stated_rooms_from_stream,
)


@attr.s(slots=True, frozen=True, auto_attribs=True)
class UnPartialStatedEventStreamRow:
# ID of the event that has been un-partial-stated.
event_id: str

# True iff the rejection status of the event changed as a result of being
# un-partial-stated.
rejection_status_changed: bool


class UnPartialStatedEventStream(Stream):
"""
Stream to notify about events becoming un-partial-stated.
"""

NAME = "un_partial_stated_event"
ROW_TYPE = UnPartialStatedEventStreamRow

def __init__(self, hs: "HomeServer"):
store = hs.get_datastores().main
super().__init__(
hs.get_instance_name(),
# TODO(multiple writers): we need to account for instance names
current_token_without_instance(store.get_un_partial_stated_events_token),
store.get_un_partial_stated_events_from_stream,
)

0 comments on commit 6768a6a

Please sign in to comment.