Move API version number to endpoint definition
This commit is contained in:
@@ -84,6 +84,10 @@ class Config(BaseBridgeConfig):
|
|||||||
|
|
||||||
copy("appservice.provisioning.enabled")
|
copy("appservice.provisioning.enabled")
|
||||||
copy("appservice.provisioning.prefix")
|
copy("appservice.provisioning.prefix")
|
||||||
|
if base["appservice.provisioning.prefix"].endswith("/v1"):
|
||||||
|
base["appservice.provisioning.prefix"] = base["appservice.provisioning.prefix"][
|
||||||
|
: -len("/v1")
|
||||||
|
]
|
||||||
copy("appservice.provisioning.shared_secret")
|
copy("appservice.provisioning.shared_secret")
|
||||||
if base["appservice.provisioning.shared_secret"] == "generate":
|
if base["appservice.provisioning.shared_secret"] == "generate":
|
||||||
base["appservice.provisioning.shared_secret"] = self._new_token()
|
base["appservice.provisioning.shared_secret"] = self._new_token()
|
||||||
|
|||||||
@@ -67,7 +67,7 @@ appservice:
|
|||||||
# Whether or not the provisioning API should be enabled.
|
# Whether or not the provisioning API should be enabled.
|
||||||
enabled: true
|
enabled: true
|
||||||
# The prefix to use in the provisioning API endpoints.
|
# The prefix to use in the provisioning API endpoints.
|
||||||
prefix: /_matrix/provision/v1
|
prefix: /_matrix/provision
|
||||||
# The shared secret to authorize users of the API.
|
# The shared secret to authorize users of the API.
|
||||||
# Set to "generate" to generate and save a new token.
|
# Set to "generate" to generate and save a new token.
|
||||||
shared_secret: generate
|
shared_secret: generate
|
||||||
|
|||||||
@@ -53,16 +53,16 @@ class ProvisioningAPI(AuthAPI):
|
|||||||
|
|
||||||
self.app = web.Application(loop=bridge.loop, middlewares=[self.error_middleware])
|
self.app = web.Application(loop=bridge.loop, middlewares=[self.error_middleware])
|
||||||
|
|
||||||
portal_prefix = "/portal/{mxid:![^/]+}"
|
portal_prefix = "/v1/portal/{mxid:![^/]+}"
|
||||||
self.app.router.add_route("GET", f"{portal_prefix}", self.get_portal_by_mxid)
|
self.app.router.add_route("GET", f"{portal_prefix}", self.get_portal_by_mxid)
|
||||||
self.app.router.add_route("GET", "/portal/{tgid:-[0-9]+}", self.get_portal_by_tgid)
|
self.app.router.add_route("GET", "/v1/portal/{tgid:-[0-9]+}", self.get_portal_by_tgid)
|
||||||
self.app.router.add_route(
|
self.app.router.add_route(
|
||||||
"POST", portal_prefix + "/connect/{chat_id:-[0-9]+}", self.connect_chat
|
"POST", portal_prefix + "/connect/{chat_id:-[0-9]+}", self.connect_chat
|
||||||
)
|
)
|
||||||
self.app.router.add_route("POST", f"{portal_prefix}/create", self.create_chat)
|
self.app.router.add_route("POST", f"{portal_prefix}/create", self.create_chat)
|
||||||
self.app.router.add_route("POST", f"{portal_prefix}/disconnect", self.disconnect_chat)
|
self.app.router.add_route("POST", f"{portal_prefix}/disconnect", self.disconnect_chat)
|
||||||
|
|
||||||
user_prefix = "/user/{mxid:@[^:]*:[^/]+}"
|
user_prefix = "/v1/user/{mxid:@[^:]*:[^/]+}"
|
||||||
self.app.router.add_route("GET", f"{user_prefix}", self.get_user_info)
|
self.app.router.add_route("GET", f"{user_prefix}", self.get_user_info)
|
||||||
self.app.router.add_route("GET", f"{user_prefix}/chats", self.get_chats)
|
self.app.router.add_route("GET", f"{user_prefix}/chats", self.get_chats)
|
||||||
self.app.router.add_route("GET", f"{user_prefix}/contacts", self.get_contacts)
|
self.app.router.add_route("GET", f"{user_prefix}/contacts", self.get_contacts)
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ tags:
|
|||||||
- name: Misc
|
- name: Misc
|
||||||
|
|
||||||
paths:
|
paths:
|
||||||
/bridge:
|
/v1/bridge:
|
||||||
get:
|
get:
|
||||||
operationId: get_bridge
|
operationId: get_bridge
|
||||||
summary: Get the bridge's information
|
summary: Get the bridge's information
|
||||||
@@ -34,7 +34,7 @@ paths:
|
|||||||
relaybot_username:
|
relaybot_username:
|
||||||
type: string
|
type: string
|
||||||
description: The relay bot's username on Telegram
|
description: The relay bot's username on Telegram
|
||||||
/portal/{room_id}:
|
/v1/portal/{room_id}:
|
||||||
get:
|
get:
|
||||||
operationId: get_portal
|
operationId: get_portal
|
||||||
summary: Get the bridging status and info of the connected Telegram chat
|
summary: Get the bridging status and info of the connected Telegram chat
|
||||||
@@ -78,7 +78,7 @@ paths:
|
|||||||
required: false
|
required: false
|
||||||
schema:
|
schema:
|
||||||
type: string
|
type: string
|
||||||
/portal/{chat_id}:
|
/v1/portal/{chat_id}:
|
||||||
get:
|
get:
|
||||||
operationId: get_portal_by_tgid
|
operationId: get_portal_by_tgid
|
||||||
summary: Get the bridging status and info of the connected Telegram chat
|
summary: Get the bridging status and info of the connected Telegram chat
|
||||||
@@ -136,7 +136,7 @@ paths:
|
|||||||
required: false
|
required: false
|
||||||
schema:
|
schema:
|
||||||
type: string
|
type: string
|
||||||
/portal/{room_id}/connect/{chat_id}:
|
/v1/portal/{room_id}/connect/{chat_id}:
|
||||||
post:
|
post:
|
||||||
operationId: connect_portal
|
operationId: connect_portal
|
||||||
summary: Connect an existing Telegram chat to the given room
|
summary: Connect an existing Telegram chat to the given room
|
||||||
@@ -214,7 +214,7 @@ paths:
|
|||||||
- chat_already_bridged
|
- chat_already_bridged
|
||||||
error:
|
error:
|
||||||
$ref: "#/components/schemas/HumanReadableError"
|
$ref: "#/components/schemas/HumanReadableError"
|
||||||
/portal/{room_id}/create:
|
/v1/portal/{room_id}/create:
|
||||||
post:
|
post:
|
||||||
operationId: create_portal
|
operationId: create_portal
|
||||||
summary: Create a new Telegram chat for the given room
|
summary: Create a new Telegram chat for the given room
|
||||||
@@ -302,7 +302,7 @@ paths:
|
|||||||
type: string
|
type: string
|
||||||
example: Discussion about mautrix-telegram
|
example: Discussion about mautrix-telegram
|
||||||
required: true
|
required: true
|
||||||
/portal/{room_id}/disconnect:
|
/v1/portal/{room_id}/disconnect:
|
||||||
post:
|
post:
|
||||||
operationId: disconnect_portal
|
operationId: disconnect_portal
|
||||||
summary: Disconnect the Telegram chat from the room
|
summary: Disconnect the Telegram chat from the room
|
||||||
@@ -357,7 +357,7 @@ paths:
|
|||||||
schema:
|
schema:
|
||||||
type: boolean
|
type: boolean
|
||||||
default: false
|
default: false
|
||||||
/user/{user_id}:
|
/v1/user/{user_id}:
|
||||||
get:
|
get:
|
||||||
operationId: get_me
|
operationId: get_me
|
||||||
summary: Get the info of the Telegram user the given Matrix user is logged in as
|
summary: Get the info of the Telegram user the given Matrix user is logged in as
|
||||||
@@ -382,7 +382,7 @@ paths:
|
|||||||
required: true
|
required: true
|
||||||
schema:
|
schema:
|
||||||
type: string
|
type: string
|
||||||
/user/{user_id}/chats:
|
/v1/user/{user_id}/chats:
|
||||||
get:
|
get:
|
||||||
operationId: get_chats
|
operationId: get_chats
|
||||||
summary: Get the list of Telegram chats the given Matrix user has access to
|
summary: Get the list of Telegram chats the given Matrix user has access to
|
||||||
@@ -422,7 +422,7 @@ paths:
|
|||||||
required: true
|
required: true
|
||||||
schema:
|
schema:
|
||||||
type: string
|
type: string
|
||||||
/user/{user_id}/contacts:
|
/v1/user/{user_id}/contacts:
|
||||||
get:
|
get:
|
||||||
operationId: get_contacts
|
operationId: get_contacts
|
||||||
summary: Get the user's Telegram contacts
|
summary: Get the user's Telegram contacts
|
||||||
@@ -460,7 +460,7 @@ paths:
|
|||||||
required: true
|
required: true
|
||||||
schema:
|
schema:
|
||||||
type: string
|
type: string
|
||||||
/user/{user_id}/pm/{identifier}:
|
/v1/user/{user_id}/pm/{identifier}:
|
||||||
post:
|
post:
|
||||||
operationId: start_dm
|
operationId: start_dm
|
||||||
summary: Start a direct chat with a Telegram user.
|
summary: Start a direct chat with a Telegram user.
|
||||||
@@ -516,7 +516,7 @@ paths:
|
|||||||
- type: integer
|
- type: integer
|
||||||
description: Internal Telegram user ID
|
description: Internal Telegram user ID
|
||||||
example: 987654321
|
example: 987654321
|
||||||
/user/{user_id}/login/bot_token:
|
/v1/user/{user_id}/login/bot_token:
|
||||||
post:
|
post:
|
||||||
operationId: post_bot_token
|
operationId: post_bot_token
|
||||||
summary: Log in with a bot token
|
summary: Log in with a bot token
|
||||||
@@ -573,7 +573,7 @@ paths:
|
|||||||
description: The access token of the bot to log in as
|
description: The access token of the bot to log in as
|
||||||
example: 297900271:IXjeGEcAN61zHnjPgkWnYWyvVp9K4ulHBEv
|
example: 297900271:IXjeGEcAN61zHnjPgkWnYWyvVp9K4ulHBEv
|
||||||
required: true
|
required: true
|
||||||
/user/{user_id}/login/request_code:
|
/v1/user/{user_id}/login/request_code:
|
||||||
post:
|
post:
|
||||||
operationId: post_login_phone
|
operationId: post_login_phone
|
||||||
summary: Request a phone code from Telegram
|
summary: Request a phone code from Telegram
|
||||||
@@ -693,7 +693,7 @@ paths:
|
|||||||
description: The phone number to log in as.
|
description: The phone number to log in as.
|
||||||
example: "+123456789"
|
example: "+123456789"
|
||||||
required: true
|
required: true
|
||||||
/user/{user_id}/login/send_code:
|
/v1/user/{user_id}/login/send_code:
|
||||||
post:
|
post:
|
||||||
operationId: post_login_code
|
operationId: post_login_code
|
||||||
summary: Send the login code
|
summary: Send the login code
|
||||||
@@ -771,7 +771,7 @@ paths:
|
|||||||
format: int32
|
format: int32
|
||||||
example: 123456
|
example: 123456
|
||||||
required: true
|
required: true
|
||||||
/user/{user_id}/login/send_password:
|
/v1/user/{user_id}/login/send_password:
|
||||||
post:
|
post:
|
||||||
operationId: post_login_password
|
operationId: post_login_password
|
||||||
summary: Send the two-factor auth password
|
summary: Send the two-factor auth password
|
||||||
@@ -843,7 +843,7 @@ paths:
|
|||||||
format: password
|
format: password
|
||||||
example: hunter2
|
example: hunter2
|
||||||
required: true
|
required: true
|
||||||
/user/{user_id}/logout:
|
/v1/user/{user_id}/logout:
|
||||||
post:
|
post:
|
||||||
operationId: logout
|
operationId: logout
|
||||||
summary: Log out
|
summary: Log out
|
||||||
@@ -880,7 +880,7 @@ paths:
|
|||||||
security:
|
security:
|
||||||
- Bearer: []
|
- Bearer: []
|
||||||
servers:
|
servers:
|
||||||
- url: /_matrix/provision/v1
|
- url: /_matrix/provision
|
||||||
components:
|
components:
|
||||||
responses:
|
responses:
|
||||||
NotWhitelistedError:
|
NotWhitelistedError:
|
||||||
|
|||||||
Reference in New Issue
Block a user