From 01a89508f6758fcd81bbed0afd66e36d9c24cfe0 Mon Sep 17 00:00:00 2001 From: Andrew Ferrazzutti Date: Sat, 9 Apr 2022 03:45:29 -0400 Subject: [PATCH] Remove outbound typing listeners Since KakaoTalk doesn't support typing notifications --- matrix_appservice_kakaotalk/matrix.py | 26 ++------------------------ matrix_appservice_kakaotalk/portal.py | 12 ------------ 2 files changed, 2 insertions(+), 36 deletions(-) diff --git a/matrix_appservice_kakaotalk/matrix.py b/matrix_appservice_kakaotalk/matrix.py index b336a13..b3374ad 100644 --- a/matrix_appservice_kakaotalk/matrix.py +++ b/matrix_appservice_kakaotalk/matrix.py @@ -15,29 +15,23 @@ # along with this program. If not, see . from __future__ import annotations -from typing import TYPE_CHECKING, Union +from typing import TYPE_CHECKING from mautrix.bridge import BaseMatrixHandler -from mautrix.errors import MatrixError from mautrix.types import ( Event, EventID, EventType, - MessageType, - PresenceEvent, ReactionEvent, ReactionEventContent, - ReceiptEvent, RedactionEvent, RelationType, RoomID, SingleReceiptEventContent, - TextMessageEventContent, - TypingEvent, UserID, ) -from . import portal as po, puppet as pu, user as u +from . import portal as po, user as u if TYPE_CHECKING: from .__main__ import KakaoTalkBridge @@ -147,14 +141,6 @@ class MatrixHandler(BaseMatrixHandler): user, event_id, content.relates_to.event_id, content.relates_to.key ) - @staticmethod - async def handle_typing(room_id: RoomID, typing: list[UserID]) -> None: - portal = await po.Portal.get_by_mxid(room_id) - if not portal or not portal.is_direct: - return - - await portal.handle_matrix_typing(set(typing)) - async def handle_read_receipt( self, user: u.User, @@ -176,14 +162,6 @@ class MatrixHandler(BaseMatrixHandler): ) """ - async def handle_ephemeral_event( - self, evt: Union[ReceiptEvent, PresenceEvent, TypingEvent] - ) -> None: - if evt.type == EventType.TYPING: - await self.handle_typing(evt.room_id, evt.content.user_ids) - elif evt.type == EventType.RECEIPT: - await self.handle_receipt(evt) - async def handle_event(self, evt: Event) -> None: if evt.type == EventType.ROOM_REDACTION: evt: RedactionEvent diff --git a/matrix_appservice_kakaotalk/portal.py b/matrix_appservice_kakaotalk/portal.py index 815046c..6c798ee 100644 --- a/matrix_appservice_kakaotalk/portal.py +++ b/matrix_appservice_kakaotalk/portal.py @@ -127,7 +127,6 @@ class Portal(DBPortal, BasePortal): _create_room_lock: asyncio.Lock _send_locks: dict[int, asyncio.Lock] _noop_lock: FakeLock = FakeLock() - _typing: set[UserID] backfill_lock: SimpleLock _backfill_leave: set[IntentAPI] | None _sleeping_to_resync: bool @@ -167,7 +166,6 @@ class Portal(DBPortal, BasePortal): self._kt_sender = None self._create_room_lock = asyncio.Lock() self._send_locks = {} - self._typing = set() self._sleeping_to_resync = False self._scheduled_resync = None self._resync_targets = {} @@ -916,16 +914,6 @@ class Portal(DBPortal, BasePortal): else: self.log.debug(f"{user.mxid} left portal to {self.ktid}") - async def _set_typing(self, users: set[UserID], typing: bool) -> None: - self.log.info("TODO: _set_typing") - - async def handle_matrix_typing(self, users: set[UserID]) -> None: - await asyncio.gather( - self._set_typing(users - self._typing, typing=True), - self._set_typing(self._typing - users, typing=False), - ) - self._typing = users - # endregion # region KakaoTalk event handling