Send "delivery" receipt for messages bridged from Telegram
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user