Change case of new types

This commit is contained in:
Kai A. Hiller
2018-08-09 14:11:41 +02:00
parent 0f8009b1e9
commit e751d140f2
13 changed files with 118 additions and 118 deletions
@@ -24,7 +24,7 @@ from telethon.utils import get_peer_id, resolve_id
from telethon.tl.types import ChatForbidden, ChannelForbidden, TypeChat
from mautrix_appservice import AppService, MatrixRequestError, IntentError
from ...types import MatrixUserId
from ...types import MatrixUserID, TelegramID
from ...user import User
from ...portal import Portal
from ...commands.portal import user_has_power_level, get_initial_state
@@ -119,10 +119,10 @@ class ProvisioningAPI(AuthAPI):
chat_id = request.match_info["chat_id"]
if chat_id.startswith("-100"):
tgid = int(chat_id[4:])
tgid = TelegramID(int(chat_id[4:]))
peer_type = "channel"
elif chat_id.startswith("-"):
tgid = -int(chat_id)
tgid = TelegramID(-int(chat_id))
peer_type = "chat"
else:
return self.get_error_response(400, "tgid_invalid", "Invalid Telegram chat ID.")
@@ -154,14 +154,14 @@ class ProvisioningAPI(AuthAPI):
"Matrix room.")
is_logged_in = user is not None and await user.is_logged_in()
user = user if is_logged_in else self.context.bot
if not user:
acting_user = user if is_logged_in else self.context.bot
if not acting_user:
return self.get_login_response(status=403, errcode="not_logged_in",
error="You are not logged in and there is no relay bot.")
entity = None # type: Optional[TypeChat]
try:
entity = await user.client.get_entity(portal.peer)
entity = await acting_user.client.get_entity(portal.peer)
except Exception:
self.log.exception("Failed to get_entity(%s) for manual bridging.", portal.peer)
@@ -412,7 +412,7 @@ class ProvisioningAPI(AuthAPI):
except json.JSONDecodeError:
return None
async def get_user(self, mxid: MatrixUserId, expect_logged_in: Optional[bool] = False,
async def get_user(self, mxid: MatrixUserID, expect_logged_in: Optional[bool] = False,
require_puppeting: bool = True, require_user: bool = True
) -> Tuple[Optional[User], Optional[web.Response]]:
if not mxid: