Ignore incoming messages in private chats sent by the receiver if no matrix puppeting
This commit is contained in:
@@ -127,6 +127,14 @@ class PortalMatrix(BasePortal, MautrixBasePortal, ABC):
|
||||
async def kick_matrix(self, user: Union['u.User', 'p.Puppet'], source: 'u.User') -> None:
|
||||
if user.tgid == source.tgid:
|
||||
return
|
||||
if self.peer_type == "user" and user.tgid == self.tgid:
|
||||
self.delete()
|
||||
try:
|
||||
del self.by_tgid[self.tgid_full]
|
||||
del self.by_mxid[self.mxid]
|
||||
except KeyError:
|
||||
pass
|
||||
return
|
||||
if isinstance(user, u.User) and await user.needs_relaybot(self):
|
||||
if not self.bot:
|
||||
return
|
||||
|
||||
@@ -375,6 +375,12 @@ class PortalTelegram(BasePortal, ABC):
|
||||
if not self.mxid:
|
||||
await self.create_matrix_room(source, invites=[source.mxid], update_if_exists=False)
|
||||
|
||||
if (self.peer_type == "user" and sender.tgid == self.tg_receiver
|
||||
and not sender.is_real_user and not self.az.state_store.is_joined(self.mxid,
|
||||
sender.mxid)):
|
||||
self.log.debug(f"Ignoring private chat message {evt.id}@{source.tgid} as receiver does"
|
||||
" not have matrix puppeting and their default puppet isn't in the room")
|
||||
|
||||
async with self.send_lock(sender.tgid if sender else None, required=False):
|
||||
tg_space = self.tgid if self.peer_type == "channel" else source.tgid
|
||||
|
||||
@@ -489,7 +495,8 @@ class PortalTelegram(BasePortal, ABC):
|
||||
elif isinstance(action, MessageActionChatMigrateTo):
|
||||
self.peer_type = "channel"
|
||||
self._migrate_and_save_telegram(TelegramID(action.channel_id))
|
||||
await sender.intent_for(self).send_emote(self.mxid, "upgraded this group to a supergroup.")
|
||||
await sender.intent_for(self).send_emote(self.mxid,
|
||||
"upgraded this group to a supergroup.")
|
||||
elif isinstance(action, MessageActionPinMessage):
|
||||
await self.receive_telegram_pin_sender(sender)
|
||||
elif isinstance(action, MessageActionGameScore):
|
||||
|
||||
Reference in New Issue
Block a user