Outbound read receipts

This commit is contained in:
Andrew Ferrazzutti 2022-04-10 04:26:09 -04:00
parent 109e9bcc67
commit 4a68796fdf
3 changed files with 35 additions and 11 deletions

View File

@ -355,6 +355,17 @@ class Client:
chat_id=chat_id.serialize(), chat_id=chat_id.serialize(),
) )
async def mark_read(
self,
channel_props: ChannelProps,
read_until_chat_id: Long,
) -> None:
return await self._api_user_request_void(
"mark_read",
channel_props=channel_props.serialize(),
read_until_chat_id=read_until_chat_id.serialize(),
)
# TODO Combine these into one # TODO Combine these into one

View File

@ -24,6 +24,7 @@ from mautrix.types import (
EventType, EventType,
ReactionEvent, ReactionEvent,
ReactionEventContent, ReactionEventContent,
ReceiptEvent,
RedactionEvent, RedactionEvent,
RelationType, RelationType,
RoomID, RoomID,
@ -32,6 +33,7 @@ from mautrix.types import (
) )
from . import portal as po, user as u from . import portal as po, user as u
from .db import Message as DBMessage
if TYPE_CHECKING: if TYPE_CHECKING:
from .__main__ import KakaoTalkBridge from .__main__ import KakaoTalkBridge
@ -153,19 +155,16 @@ class MatrixHandler(BaseMatrixHandler):
event_id: EventID, event_id: EventID,
data: SingleReceiptEventContent, data: SingleReceiptEventContent,
) -> None: ) -> None:
self.log.info("TODO: handle_read_receipt") if not user.is_connected:
"""
if not user.mqtt:
return return
timestamp = data.get("ts", int(time.time() * 1000))
message = await DBMessage.get_by_mxid(event_id, portal.mxid) message = await DBMessage.get_by_mxid(event_id, portal.mxid)
await user.mqtt.mark_read( await user.client.mark_read(portal.channel_props, message.ktid)
portal.ktid,
True, # TODO async def handle_ephemeral_event(
#portal.fb_type != ThreadType.USER, self, evt: ReceiptEvent | Event
read_to=message.timestamp if message else timestamp, ) -> None:
) if evt.type == EventType.RECEIPT:
""" await self.handle_receipt(evt)
async def handle_event(self, evt: Event) -> None: async def handle_event(self, evt: Event) -> None:
if evt.type == EventType.ROOM_REDACTION: if evt.type == EventType.ROOM_REDACTION:

View File

@ -605,6 +605,20 @@ export default class PeerClient {
}) })
} }
/**
* @param {Object} req
* @param {string} req.mxid
* @param {ChannelProps} req.channel_props
* @param {Long} req.read_until_chat_id
*/
markRead = async (req) => {
const talkChannel = await this.#getUserChannel(req.mxid, req.channel_props)
return await talkChannel.markRead({
logId: req.read_until_chat_id,
})
}
#makeCommandResult(result) { #makeCommandResult(result) {
return { return {
success: true, success: true,