Merge branch 'master' into independent-login
This commit is contained in:
@@ -65,6 +65,12 @@ class Bot(AbstractUser):
|
|||||||
except (ChannelPrivateError, ChannelInvalidError):
|
except (ChannelPrivateError, ChannelInvalidError):
|
||||||
self.remove_chat(id.channel_id)
|
self.remove_chat(id.channel_id)
|
||||||
|
|
||||||
|
def register_portal(self, portal):
|
||||||
|
self.add_chat(portal.tgid, portal.peer_type)
|
||||||
|
|
||||||
|
def unregister_portal(self, portal):
|
||||||
|
self.remove_chat(portal.tgid)
|
||||||
|
|
||||||
def add_chat(self, id, type):
|
def add_chat(self, id, type):
|
||||||
if id not in self.chats:
|
if id not in self.chats:
|
||||||
self.chats[id] = type
|
self.chats[id] = type
|
||||||
|
|||||||
@@ -112,7 +112,7 @@ class TelegramFile(Base):
|
|||||||
mxc = Column(String)
|
mxc = Column(String)
|
||||||
mime_type = Column(String)
|
mime_type = Column(String)
|
||||||
was_converted = Column(Boolean)
|
was_converted = Column(Boolean)
|
||||||
timestamp = Column(BigInteger, primary_key=True)
|
timestamp = Column(BigInteger)
|
||||||
|
|
||||||
|
|
||||||
def init(db_session):
|
def init(db_session):
|
||||||
|
|||||||
@@ -491,8 +491,11 @@ class Portal:
|
|||||||
if self.peer_type == "user":
|
if self.peer_type == "user":
|
||||||
await self.main_intent.leave_room(self.mxid)
|
await self.main_intent.leave_room(self.mxid)
|
||||||
self.delete()
|
self.delete()
|
||||||
del self.by_tgid[self.tgid_full]
|
try:
|
||||||
del self.by_mxid[self.mxid]
|
del self.by_tgid[self.tgid_full]
|
||||||
|
del self.by_mxid[self.mxid]
|
||||||
|
except KeyError:
|
||||||
|
pass
|
||||||
elif source and source.tgid != user.tgid:
|
elif source and source.tgid != user.tgid:
|
||||||
if self.peer_type == "chat":
|
if self.peer_type == "chat":
|
||||||
await source.client(DeleteChatUserRequest(chat_id=self.tgid, user_id=user.tgid))
|
await source.client(DeleteChatUserRequest(chat_id=self.tgid, user_id=user.tgid))
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ def _convert_webp(file, to="png"):
|
|||||||
async def transfer_file_to_matrix(db, client, intent, location):
|
async def transfer_file_to_matrix(db, client, intent, location):
|
||||||
if isinstance(location, (Document, InputDocumentFileLocation)):
|
if isinstance(location, (Document, InputDocumentFileLocation)):
|
||||||
id = f"{location.id}-{location.version}"
|
id = f"{location.id}-{location.version}"
|
||||||
elif not isinstance(location, (FileLocation, InputFileLocation)):
|
elif isinstance(location, (FileLocation, InputFileLocation)):
|
||||||
id = f"{location.volume_id}-{location.local_id}"
|
id = f"{location.volume_id}-{location.local_id}"
|
||||||
else:
|
else:
|
||||||
return None
|
return None
|
||||||
|
|||||||
Reference in New Issue
Block a user