You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

74 lines
2.2 KiB

  1. # Copyright 2022 The Matrix.org Foundation C.I.C.
  2. #
  3. # Licensed under the Apache License, Version 2.0 (the "License");
  4. # you may not use this file except in compliance with the License.
  5. # You may obtain a copy of the License at
  6. #
  7. # http://www.apache.org/licenses/LICENSE-2.0
  8. #
  9. # Unless required by applicable law or agreed to in writing, software
  10. # distributed under the License is distributed on an "AS IS" BASIS,
  11. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. # See the License for the specific language governing permissions and
  13. # limitations under the License.
  14. from typing import TYPE_CHECKING
  15. import attr
  16. from synapse.replication.tcp.streams import Stream
  17. if TYPE_CHECKING:
  18. from synapse.server import HomeServer
  19. @attr.s(slots=True, frozen=True, auto_attribs=True)
  20. class UnPartialStatedRoomStreamRow:
  21. # ID of the room that has been un-partial-stated.
  22. room_id: str
  23. class UnPartialStatedRoomStream(Stream):
  24. """
  25. Stream to notify about rooms becoming un-partial-stated;
  26. that is, when the background sync finishes such that we now have full state for
  27. the room.
  28. """
  29. NAME = "un_partial_stated_room"
  30. ROW_TYPE = UnPartialStatedRoomStreamRow
  31. def __init__(self, hs: "HomeServer"):
  32. store = hs.get_datastores().main
  33. super().__init__(
  34. hs.get_instance_name(),
  35. store.get_un_partial_stated_rooms_token,
  36. store.get_un_partial_stated_rooms_from_stream,
  37. )
  38. @attr.s(slots=True, frozen=True, auto_attribs=True)
  39. class UnPartialStatedEventStreamRow:
  40. # ID of the event that has been un-partial-stated.
  41. event_id: str
  42. # True iff the rejection status of the event changed as a result of being
  43. # un-partial-stated.
  44. rejection_status_changed: bool
  45. class UnPartialStatedEventStream(Stream):
  46. """
  47. Stream to notify about events becoming un-partial-stated.
  48. """
  49. NAME = "un_partial_stated_event"
  50. ROW_TYPE = UnPartialStatedEventStreamRow
  51. def __init__(self, hs: "HomeServer"):
  52. store = hs.get_datastores().main
  53. super().__init__(
  54. hs.get_instance_name(),
  55. store.get_un_partial_stated_events_token,
  56. store.get_un_partial_stated_events_from_stream,
  57. )