feat(message-gateway): add user bind and unbind APIs

This commit is contained in:
ryan
2026-08-16 12:19:32 +08:00
parent 69d39d906f
commit 635c1760ad
10 changed files with 1118 additions and 0 deletions
+254
View File
@@ -4574,6 +4574,205 @@ const docTemplate = `{
}
}
},
"/api/v1/message-gateway/bindings": {
"get": {
"security": [
{
"SessionCookie": []
}
],
"description": "Returns the current user's bound messaging channels",
"produces": [
"application/json"
],
"tags": [
"message-gateway"
],
"summary": "List message gateway bindings",
"responses": {
"200": {
"description": "OK",
"schema": {
"allOf": [
{
"$ref": "#/definitions/response.Any"
},
{
"type": "object",
"properties": {
"data": {
"type": "array",
"items": {
"$ref": "#/definitions/message_gateway.BindingDTO"
}
}
}
}
]
}
},
"401": {
"description": "Unauthorized",
"schema": {
"$ref": "#/definitions/response.Any"
}
}
}
},
"post": {
"security": [
{
"SessionCookie": []
}
],
"description": "Binds the current user to a platform identity using a one-time pairing code",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"message-gateway"
],
"summary": "Bind a messaging channel",
"parameters": [
{
"description": "bind body",
"name": "request",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/message_gateway.BindRequest"
}
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"allOf": [
{
"$ref": "#/definitions/response.Any"
},
{
"type": "object",
"properties": {
"data": {
"$ref": "#/definitions/message_gateway.BindingDTO"
}
}
}
]
}
},
"400": {
"description": "Bad Request",
"schema": {
"$ref": "#/definitions/response.Any"
}
},
"409": {
"description": "Conflict",
"schema": {
"$ref": "#/definitions/response.Any"
}
}
}
}
},
"/api/v1/message-gateway/bindings/{id}": {
"delete": {
"security": [
{
"SessionCookie": []
}
],
"description": "Removes a binding owned by the current user",
"produces": [
"application/json"
],
"tags": [
"message-gateway"
],
"summary": "Unbind a messaging channel",
"parameters": [
{
"type": "integer",
"description": "binding id",
"name": "id",
"in": "path",
"required": true
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/response.Any"
}
},
"403": {
"description": "Forbidden",
"schema": {
"$ref": "#/definitions/response.Any"
}
},
"404": {
"description": "Not Found",
"schema": {
"$ref": "#/definitions/response.Any"
}
}
}
}
},
"/api/v1/message-gateway/channels": {
"get": {
"security": [
{
"SessionCookie": []
}
],
"description": "Returns enabled system bots the current user can pair with",
"produces": [
"application/json"
],
"tags": [
"message-gateway"
],
"summary": "List enabled messaging channels",
"responses": {
"200": {
"description": "OK",
"schema": {
"allOf": [
{
"$ref": "#/definitions/response.Any"
},
{
"type": "object",
"properties": {
"data": {
"type": "array",
"items": {
"$ref": "#/definitions/message_gateway.PublicChannelDTO"
}
}
}
}
]
}
},
"401": {
"description": "Unauthorized",
"schema": {
"$ref": "#/definitions/response.Any"
}
}
}
}
},
"/api/v1/oauth/callback": {
"post": {
"description": "接收前端传回的 state 和 code,完成 OAuth/OIDC 认证并建立会话。支持登录(login)和账号绑定(bind)两种场景。",
@@ -6432,6 +6631,46 @@ const docTemplate = `{
}
}
},
"message_gateway.BindRequest": {
"type": "object",
"properties": {
"channel_id": {
"type": "string"
},
"code": {
"type": "string"
}
}
},
"message_gateway.BindingDTO": {
"type": "object",
"properties": {
"channel_id": {
"type": "string",
"example": "0"
},
"channel_name": {
"type": "string"
},
"channel_type": {
"type": "string"
},
"created_at": {
"type": "string"
},
"id": {
"type": "string",
"example": "0"
},
"platform_user_id": {
"type": "string"
},
"user_id": {
"type": "string",
"example": "0"
}
}
},
"message_gateway.ChannelDTO": {
"type": "object",
"properties": {
@@ -6537,6 +6776,21 @@ const docTemplate = `{
}
}
},
"message_gateway.PublicChannelDTO": {
"type": "object",
"properties": {
"id": {
"type": "string",
"example": "0"
},
"name": {
"type": "string"
},
"type": {
"type": "string"
}
}
},
"message_gateway.UpdateChannelRequest": {
"type": "object",
"properties": {
+254
View File
@@ -4567,6 +4567,205 @@
}
}
},
"/api/v1/message-gateway/bindings": {
"get": {
"security": [
{
"SessionCookie": []
}
],
"description": "Returns the current user's bound messaging channels",
"produces": [
"application/json"
],
"tags": [
"message-gateway"
],
"summary": "List message gateway bindings",
"responses": {
"200": {
"description": "OK",
"schema": {
"allOf": [
{
"$ref": "#/definitions/response.Any"
},
{
"type": "object",
"properties": {
"data": {
"type": "array",
"items": {
"$ref": "#/definitions/message_gateway.BindingDTO"
}
}
}
}
]
}
},
"401": {
"description": "Unauthorized",
"schema": {
"$ref": "#/definitions/response.Any"
}
}
}
},
"post": {
"security": [
{
"SessionCookie": []
}
],
"description": "Binds the current user to a platform identity using a one-time pairing code",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"message-gateway"
],
"summary": "Bind a messaging channel",
"parameters": [
{
"description": "bind body",
"name": "request",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/message_gateway.BindRequest"
}
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"allOf": [
{
"$ref": "#/definitions/response.Any"
},
{
"type": "object",
"properties": {
"data": {
"$ref": "#/definitions/message_gateway.BindingDTO"
}
}
}
]
}
},
"400": {
"description": "Bad Request",
"schema": {
"$ref": "#/definitions/response.Any"
}
},
"409": {
"description": "Conflict",
"schema": {
"$ref": "#/definitions/response.Any"
}
}
}
}
},
"/api/v1/message-gateway/bindings/{id}": {
"delete": {
"security": [
{
"SessionCookie": []
}
],
"description": "Removes a binding owned by the current user",
"produces": [
"application/json"
],
"tags": [
"message-gateway"
],
"summary": "Unbind a messaging channel",
"parameters": [
{
"type": "integer",
"description": "binding id",
"name": "id",
"in": "path",
"required": true
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/response.Any"
}
},
"403": {
"description": "Forbidden",
"schema": {
"$ref": "#/definitions/response.Any"
}
},
"404": {
"description": "Not Found",
"schema": {
"$ref": "#/definitions/response.Any"
}
}
}
}
},
"/api/v1/message-gateway/channels": {
"get": {
"security": [
{
"SessionCookie": []
}
],
"description": "Returns enabled system bots the current user can pair with",
"produces": [
"application/json"
],
"tags": [
"message-gateway"
],
"summary": "List enabled messaging channels",
"responses": {
"200": {
"description": "OK",
"schema": {
"allOf": [
{
"$ref": "#/definitions/response.Any"
},
{
"type": "object",
"properties": {
"data": {
"type": "array",
"items": {
"$ref": "#/definitions/message_gateway.PublicChannelDTO"
}
}
}
}
]
}
},
"401": {
"description": "Unauthorized",
"schema": {
"$ref": "#/definitions/response.Any"
}
}
}
}
},
"/api/v1/oauth/callback": {
"post": {
"description": "接收前端传回的 state 和 code,完成 OAuth/OIDC 认证并建立会话。支持登录(login)和账号绑定(bind)两种场景。",
@@ -6425,6 +6624,46 @@
}
}
},
"message_gateway.BindRequest": {
"type": "object",
"properties": {
"channel_id": {
"type": "string"
},
"code": {
"type": "string"
}
}
},
"message_gateway.BindingDTO": {
"type": "object",
"properties": {
"channel_id": {
"type": "string",
"example": "0"
},
"channel_name": {
"type": "string"
},
"channel_type": {
"type": "string"
},
"created_at": {
"type": "string"
},
"id": {
"type": "string",
"example": "0"
},
"platform_user_id": {
"type": "string"
},
"user_id": {
"type": "string",
"example": "0"
}
}
},
"message_gateway.ChannelDTO": {
"type": "object",
"properties": {
@@ -6530,6 +6769,21 @@
}
}
},
"message_gateway.PublicChannelDTO": {
"type": "object",
"properties": {
"id": {
"type": "string",
"example": "0"
},
"name": {
"type": "string"
},
"type": {
"type": "string"
}
}
},
"message_gateway.UpdateChannelRequest": {
"type": "object",
"properties": {
+155
View File
@@ -327,6 +327,33 @@ definitions:
date:
type: string
type: object
message_gateway.BindRequest:
properties:
channel_id:
type: string
code:
type: string
type: object
message_gateway.BindingDTO:
properties:
channel_id:
example: "0"
type: string
channel_name:
type: string
channel_type:
type: string
created_at:
type: string
id:
example: "0"
type: string
platform_user_id:
type: string
user_id:
example: "0"
type: string
type: object
message_gateway.ChannelDTO:
properties:
app_id:
@@ -396,6 +423,16 @@ definitions:
type:
type: string
type: object
message_gateway.PublicChannelDTO:
properties:
id:
example: "0"
type: string
name:
type: string
type:
type: string
type: object
message_gateway.UpdateChannelRequest:
properties:
app_id:
@@ -4252,6 +4289,124 @@ paths:
summary: Sample Hello API
tags:
- custom
/api/v1/message-gateway/bindings:
get:
description: Returns the current user's bound messaging channels
produces:
- application/json
responses:
"200":
description: OK
schema:
allOf:
- $ref: '#/definitions/response.Any'
- properties:
data:
items:
$ref: '#/definitions/message_gateway.BindingDTO'
type: array
type: object
"401":
description: Unauthorized
schema:
$ref: '#/definitions/response.Any'
security:
- SessionCookie: []
summary: List message gateway bindings
tags:
- message-gateway
post:
consumes:
- application/json
description: Binds the current user to a platform identity using a one-time
pairing code
parameters:
- description: bind body
in: body
name: request
required: true
schema:
$ref: '#/definitions/message_gateway.BindRequest'
produces:
- application/json
responses:
"200":
description: OK
schema:
allOf:
- $ref: '#/definitions/response.Any'
- properties:
data:
$ref: '#/definitions/message_gateway.BindingDTO'
type: object
"400":
description: Bad Request
schema:
$ref: '#/definitions/response.Any'
"409":
description: Conflict
schema:
$ref: '#/definitions/response.Any'
security:
- SessionCookie: []
summary: Bind a messaging channel
tags:
- message-gateway
/api/v1/message-gateway/bindings/{id}:
delete:
description: Removes a binding owned by the current user
parameters:
- description: binding id
in: path
name: id
required: true
type: integer
produces:
- application/json
responses:
"200":
description: OK
schema:
$ref: '#/definitions/response.Any'
"403":
description: Forbidden
schema:
$ref: '#/definitions/response.Any'
"404":
description: Not Found
schema:
$ref: '#/definitions/response.Any'
security:
- SessionCookie: []
summary: Unbind a messaging channel
tags:
- message-gateway
/api/v1/message-gateway/channels:
get:
description: Returns enabled system bots the current user can pair with
produces:
- application/json
responses:
"200":
description: OK
schema:
allOf:
- $ref: '#/definitions/response.Any'
- properties:
data:
items:
$ref: '#/definitions/message_gateway.PublicChannelDTO'
type: array
type: object
"401":
description: Unauthorized
schema:
$ref: '#/definitions/response.Any'
security:
- SessionCookie: []
summary: List enabled messaging channels
tags:
- message-gateway
/api/v1/oauth/{source}/authorize:
get:
description: 根据指定认证源名称发起 OAuth 授权,支持 purpose 参数用于区分登录和账号绑定场景。认证源必须已启用。