mirror of
https://git.anonymousland.org/anonymousland/synapse-product.git
synced 2025-04-25 09:19:09 -04:00
Allow sending custom data in /read_markers too
This commit is contained in:
parent
360f254c6d
commit
9c9cdae578
@ -13,9 +13,10 @@
|
||||
# limitations under the License.
|
||||
|
||||
import logging
|
||||
from typing import TYPE_CHECKING
|
||||
from typing import TYPE_CHECKING, Optional
|
||||
|
||||
from synapse.util.async_helpers import Linearizer
|
||||
from synapse.types import JsonDict
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from synapse.server import HomeServer
|
||||
@ -31,7 +32,7 @@ class ReadMarkerHandler:
|
||||
self.read_marker_linearizer = Linearizer(name="read_marker")
|
||||
|
||||
async def received_client_read_marker(
|
||||
self, room_id: str, user_id: str, event_id: str
|
||||
self, room_id: str, user_id: str, event_id: str, extra_content: Optional[JsonDict] = None
|
||||
) -> None:
|
||||
"""Updates the read marker for a given user in a given room if the event ID given
|
||||
is ahead in the stream relative to the current read marker.
|
||||
@ -54,7 +55,7 @@ class ReadMarkerHandler:
|
||||
)
|
||||
|
||||
if should_update:
|
||||
content = {"event_id": event_id}
|
||||
content = {"event_id": event_id, **(extra_content or {})}
|
||||
await self.account_data_handler.add_account_data_to_room(
|
||||
user_id, room_id, "m.fully_read", content
|
||||
)
|
||||
|
@ -49,6 +49,7 @@ class ReadMarkerRestServlet(RestServlet):
|
||||
|
||||
body = parse_json_object_from_request(request)
|
||||
read_event_id = body.get("m.read", None)
|
||||
read_extra = body.get("com.beeper.read.extra", None)
|
||||
hidden = body.get(ReadReceiptEventFields.MSC2285_HIDDEN, False)
|
||||
|
||||
if not isinstance(hidden, bool):
|
||||
@ -66,14 +67,17 @@ class ReadMarkerRestServlet(RestServlet):
|
||||
user_id=requester.user.to_string(),
|
||||
event_id=read_event_id,
|
||||
hidden=hidden,
|
||||
extra_content=read_extra,
|
||||
)
|
||||
|
||||
read_marker_event_id = body.get("m.fully_read", None)
|
||||
read_marker_extra = body.get("com.beeper.fully_read.extra", None)
|
||||
if read_marker_event_id:
|
||||
await self.read_marker_handler.received_client_read_marker(
|
||||
room_id,
|
||||
user_id=requester.user.to_string(),
|
||||
event_id=read_marker_event_id,
|
||||
extra_content=read_marker_extra,
|
||||
)
|
||||
|
||||
return 200, {}
|
||||
|
Loading…
x
Reference in New Issue
Block a user