Send "delivery" receipt for messages bridged from Telegram

This commit is contained in:
Tulir Asokan
2020-06-11 19:09:01 +03:00
parent 4b57be3917
commit ba13c5cae1
4 changed files with 13 additions and 8 deletions
+4
View File
@@ -519,6 +519,10 @@ class BasePortal(ABC):
def backfill(self, source: 'AbstractUser') -> Awaitable[None]:
pass
@abstractmethod
async def _send_delivery_receipt(self, event_id: EventID) -> None:
pass
# endregion
-7
View File
@@ -229,13 +229,6 @@ class PortalMatrix(BasePortal, MautrixBasePortal, ABC):
message, entities = None, None
return message, entities
async def _send_delivery_receipt(self, event_id: EventID) -> None:
if event_id and config["bridge.delivery_receipts"]:
try:
await self.az.intent.mark_read(self.mxid, event_id)
except Exception:
self.log.exception("Failed to send delivery receipt for %s", event_id)
async def _handle_matrix_text(self, sender_id: TelegramID, event_id: EventID,
space: TelegramID, client: 'MautrixTelegramClient',
content: TextMessageEventContent, reply_to: TelegramID) -> None:
+8 -1
View File
@@ -32,7 +32,7 @@ from mautrix.errors import MForbidden
from mautrix.types import (RoomID, UserID, RoomCreatePreset, EventType, Membership, Member,
PowerLevelStateEventContent, RoomTopicStateEventContent,
RoomNameStateEventContent, RoomAvatarStateEventContent,
StateEventContent)
StateEventContent, EventID)
from ..types import TelegramID
from ..context import Context
@@ -762,6 +762,13 @@ class PortalMetadata(BasePortal, ABC):
# endregion
async def _send_delivery_receipt(self, event_id: EventID) -> None:
if event_id and config["bridge.delivery_receipts"]:
try:
await self.az.intent.mark_read(self.mxid, event_id)
except Exception:
self.log.exception("Failed to send delivery receipt for %s", event_id)
def init(context: Context) -> None:
global config
+1
View File
@@ -531,6 +531,7 @@ class PortalTelegram(BasePortal, ABC):
"dedup cache queue. You can try enabling bridge.deduplication."
"pre_db_check in the config.")
await intent.redact(self.mxid, event_id)
await self._send_delivery_receipt(event_id)
async def _create_room_on_action(self, source: 'AbstractUser',
action: TypeMessageAction) -> bool: