Add a flag to indicate if the requesting user can unbridge the portal

This commit is contained in:
Travis Ralston
2018-09-16 15:43:10 -06:00
parent d4ea5f8b38
commit 23bb2871fd
3 changed files with 34 additions and 0 deletions
@@ -74,6 +74,8 @@ class ProvisioningAPI(AuthAPI):
if not portal:
return self.get_error_response(404, "portal_not_found",
"Portal with given Matrix ID not found.")
user, _ = await self.get_user(request.query.get("user_id", None), expect_logged_in=None,
require_puppeting=False)
return web.json_response({
"mxid": portal.mxid,
"chat_id": get_peer_id(portal.peer),
@@ -82,6 +84,7 @@ class ProvisioningAPI(AuthAPI):
"about": portal.about,
"username": portal.username,
"megagroup": portal.megagroup,
"can_unbridge": (await portal.can_user_perform(user, "unbridge")) if user else False,
})
async def get_portal_by_tgid(self, request: web.Request) -> web.Response:
@@ -98,6 +101,8 @@ class ProvisioningAPI(AuthAPI):
if not portal:
return self.get_error_response(404, "portal_not_found",
"Portal to given Telegram chat not found.")
user, _ = await self.get_user(request.query.get("user_id", None), expect_logged_in=None,
require_puppeting=False)
return web.json_response({
"mxid": portal.mxid,
"chat_id": get_peer_id(portal.peer),
@@ -106,6 +111,7 @@ class ProvisioningAPI(AuthAPI):
"about": portal.about,
"username": portal.username,
"megagroup": portal.megagroup,
"can_unbridge": (await portal.can_user_perform(user, "unbridge")) if user else False,
})
async def connect_chat(self, request: web.Request) -> web.Response:
@@ -57,6 +57,11 @@ paths:
required: true
type: string
pattern: "![^/]+"
- name: user_id
in: query
description: Optional Matrix user ID to check if the user has permissions to do bridging.
required: false
type: string
/portal/{chat_id}:
get:
operationId: get_portal_by_tgid
@@ -102,6 +107,11 @@ paths:
required: true
type: integer
pattern: "-[0-9]+"
- name: user_id
in: query
description: Optional Matrix user ID to check if the user has permissions to do bridging.
required: false
type: string
/portal/{room_id}/connect/{chat_id}:
post:
operationId: connect_portal
@@ -829,6 +839,9 @@ definitions:
type: string
about:
type: string
can_unbridge:
type: boolean
description: If a user ID was provided with the request, this will indicate whether or not the user can unbridge the room.
AuthSuccess:
type: object