Even even more migrations to mautrix-python

This commit is contained in:
Tulir Asokan
2019-08-04 01:41:10 +03:00
parent d521bbc0fa
commit d8653961af
34 changed files with 475 additions and 946 deletions
+2 -2
View File
@@ -26,7 +26,7 @@ from telethon.errors import *
from mautrix.bridge import OnlyLoginSelf, InvalidAccessToken
from ...commands.telegram.auth import enter_password
from ...util import format_duration, ignore_coro
from ...util import format_duration
from ...puppet import Puppet
from ...user import User
@@ -119,7 +119,7 @@ class AuthAPI(abc.ABC):
existing_user = User.get_by_tgid(user_info.id)
if existing_user and existing_user != user:
await existing_user.log_out()
ignore_coro(asyncio.ensure_future(user.post_login(user_info), loop=self.loop))
asyncio.ensure_future(user.post_login(user_info), loop=self.loop)
if user.command_status and user.command_status["action"] == "Login":
user.command_status = None
@@ -30,7 +30,6 @@ from mautrix.types import UserID
from ...types import TelegramID
from ...user import User
from ...portal import Portal
from ...util import ignore_coro
from ...commands.portal.util import user_has_power_level, get_initial_state
from ..common import AuthAPI
@@ -188,9 +187,8 @@ class ProvisioningAPI(AuthAPI):
portal.photo_id = ""
portal.save()
ignore_coro(asyncio.ensure_future(portal.update_matrix_room(user, entity, direct,
levels=levels),
loop=self.loop))
asyncio.ensure_future(portal.update_matrix_room(user, entity, direct, levels=levels),
loop=self.loop)
return web.Response(status=202, body="{}")
@@ -269,7 +267,8 @@ class ProvisioningAPI(AuthAPI):
require_puppeting=False, require_user=False)
if err is not None:
return err
elif user and not await user_has_power_level(portal.mxid, self.az.intent, user, "unbridge"):
elif user and not await user_has_power_level(portal.mxid, self.az.intent, user,
"unbridge"):
return self.get_error_response(403, "not_enough_permissions",
"You do not have the permissions to unbridge that room.")
@@ -284,7 +283,7 @@ class ProvisioningAPI(AuthAPI):
self.log.exception("Failed to disconnect chat")
return self.get_error_response(500, "exception", "Failed to disconnect chat")
else:
ignore_coro(asyncio.ensure_future(coro, loop=self.loop))
asyncio.ensure_future(coro, loop=self.loop)
return web.json_response({}, status=200 if sync else 202)
async def get_user_info(self, request: web.Request) -> web.Response: