feat(message-gateway): add admin channel CRUD APIs

This commit is contained in:
ryan
2026-08-16 12:17:05 +08:00
parent 09ec9d0af3
commit 69d39d906f
10 changed files with 1741 additions and 0 deletions
+423
View File
@@ -1183,6 +1183,295 @@ const docTemplate = `{
"responses": {}
}
},
"/api/v1/admin/message-gateway/channels": {
"get": {
"security": [
{
"SessionCookie": []
}
],
"description": "Returns all messaging channels; secrets are masked",
"produces": [
"application/json"
],
"tags": [
"admin-message-gateway"
],
"summary": "List message gateway channels",
"responses": {
"200": {
"description": "OK",
"schema": {
"allOf": [
{
"$ref": "#/definitions/response.Any"
},
{
"type": "object",
"properties": {
"data": {
"type": "array",
"items": {
"$ref": "#/definitions/message_gateway.ChannelDTO"
}
}
}
}
]
}
}
}
},
"post": {
"security": [
{
"SessionCookie": []
}
],
"description": "Creates a Telegram or QQ channel with encrypted credentials",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"admin-message-gateway"
],
"summary": "Create message gateway channel",
"parameters": [
{
"description": "create body",
"name": "request",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/message_gateway.CreateChannelRequest"
}
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"allOf": [
{
"$ref": "#/definitions/response.Any"
},
{
"type": "object",
"properties": {
"data": {
"$ref": "#/definitions/message_gateway.ChannelDTO"
}
}
}
]
}
},
"400": {
"description": "Bad Request",
"schema": {
"$ref": "#/definitions/response.Any"
}
}
}
}
},
"/api/v1/admin/message-gateway/channels/definitions": {
"get": {
"security": [
{
"SessionCookie": []
}
],
"description": "Returns form field definitions for Telegram and QQ channels",
"produces": [
"application/json"
],
"tags": [
"admin-message-gateway"
],
"summary": "List message gateway channel definitions",
"responses": {
"200": {
"description": "OK",
"schema": {
"allOf": [
{
"$ref": "#/definitions/response.Any"
},
{
"type": "object",
"properties": {
"data": {
"type": "array",
"items": {
"$ref": "#/definitions/message_gateway.Definition"
}
}
}
}
]
}
}
}
}
},
"/api/v1/admin/message-gateway/channels/{id}": {
"delete": {
"security": [
{
"SessionCookie": []
}
],
"description": "Deletes a channel and cascaded bindings and pairing codes",
"produces": [
"application/json"
],
"tags": [
"admin-message-gateway"
],
"summary": "Delete message gateway channel",
"parameters": [
{
"type": "integer",
"description": "channel id",
"name": "id",
"in": "path",
"required": true
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/response.Any"
}
},
"404": {
"description": "Not Found",
"schema": {
"$ref": "#/definitions/response.Any"
}
}
}
},
"patch": {
"security": [
{
"SessionCookie": []
}
],
"description": "Updates a channel; empty secrets keep the current ciphertext",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"admin-message-gateway"
],
"summary": "Update message gateway channel",
"parameters": [
{
"type": "integer",
"description": "channel id",
"name": "id",
"in": "path",
"required": true
},
{
"description": "update body",
"name": "request",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/message_gateway.UpdateChannelRequest"
}
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"allOf": [
{
"$ref": "#/definitions/response.Any"
},
{
"type": "object",
"properties": {
"data": {
"$ref": "#/definitions/message_gateway.ChannelDTO"
}
}
}
]
}
},
"400": {
"description": "Bad Request",
"schema": {
"$ref": "#/definitions/response.Any"
}
},
"404": {
"description": "Not Found",
"schema": {
"$ref": "#/definitions/response.Any"
}
}
}
}
},
"/api/v1/admin/message-gateway/channels/{id}/test": {
"post": {
"security": [
{
"SessionCookie": []
}
],
"description": "Probes stored credentials without returning secrets",
"produces": [
"application/json"
],
"tags": [
"admin-message-gateway"
],
"summary": "Test message gateway channel",
"parameters": [
{
"type": "integer",
"description": "channel id",
"name": "id",
"in": "path",
"required": true
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/response.Any"
}
},
"400": {
"description": "Bad Request",
"schema": {
"$ref": "#/definitions/response.Any"
}
},
"404": {
"description": "Not Found",
"schema": {
"$ref": "#/definitions/response.Any"
}
}
}
}
},
"/api/v1/admin/push/channels": {
"get": {
"security": [
@@ -6143,6 +6432,140 @@ const docTemplate = `{
}
}
},
"message_gateway.ChannelDTO": {
"type": "object",
"properties": {
"app_id": {
"type": "string"
},
"app_secret": {
"type": "string"
},
"base_url": {
"type": "string"
},
"bot_token": {
"type": "string"
},
"created_at": {
"type": "string"
},
"enabled": {
"type": "boolean"
},
"id": {
"type": "string",
"example": "0"
},
"name": {
"type": "string"
},
"owner_scope": {
"type": "string"
},
"portal_host": {
"type": "string"
},
"type": {
"type": "string"
},
"updated_at": {
"type": "string"
}
}
},
"message_gateway.CreateChannelRequest": {
"type": "object",
"properties": {
"app_id": {
"type": "string"
},
"app_secret": {
"type": "string"
},
"base_url": {
"type": "string"
},
"bot_token": {
"type": "string"
},
"enabled": {
"type": "boolean"
},
"name": {
"type": "string"
},
"portal_host": {
"type": "string"
},
"sandbox": {
"type": "string"
},
"type": {
"type": "string"
}
}
},
"message_gateway.Definition": {
"type": "object",
"properties": {
"fields": {
"type": "array",
"items": {
"$ref": "#/definitions/message_gateway.Field"
}
},
"name": {
"type": "string"
},
"type": {
"type": "string"
}
}
},
"message_gateway.Field": {
"type": "object",
"properties": {
"key": {
"type": "string"
},
"required": {
"type": "boolean"
},
"type": {
"type": "string"
}
}
},
"message_gateway.UpdateChannelRequest": {
"type": "object",
"properties": {
"app_id": {
"type": "string"
},
"app_secret": {
"type": "string"
},
"base_url": {
"type": "string"
},
"bot_token": {
"type": "string"
},
"enabled": {
"type": "boolean"
},
"name": {
"type": "string"
},
"portal_host": {
"type": "string"
},
"sandbox": {
"type": "string"
}
}
},
"model.AccessToken": {
"type": "object",
"properties": {
+423
View File
@@ -1176,6 +1176,295 @@
"responses": {}
}
},
"/api/v1/admin/message-gateway/channels": {
"get": {
"security": [
{
"SessionCookie": []
}
],
"description": "Returns all messaging channels; secrets are masked",
"produces": [
"application/json"
],
"tags": [
"admin-message-gateway"
],
"summary": "List message gateway channels",
"responses": {
"200": {
"description": "OK",
"schema": {
"allOf": [
{
"$ref": "#/definitions/response.Any"
},
{
"type": "object",
"properties": {
"data": {
"type": "array",
"items": {
"$ref": "#/definitions/message_gateway.ChannelDTO"
}
}
}
}
]
}
}
}
},
"post": {
"security": [
{
"SessionCookie": []
}
],
"description": "Creates a Telegram or QQ channel with encrypted credentials",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"admin-message-gateway"
],
"summary": "Create message gateway channel",
"parameters": [
{
"description": "create body",
"name": "request",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/message_gateway.CreateChannelRequest"
}
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"allOf": [
{
"$ref": "#/definitions/response.Any"
},
{
"type": "object",
"properties": {
"data": {
"$ref": "#/definitions/message_gateway.ChannelDTO"
}
}
}
]
}
},
"400": {
"description": "Bad Request",
"schema": {
"$ref": "#/definitions/response.Any"
}
}
}
}
},
"/api/v1/admin/message-gateway/channels/definitions": {
"get": {
"security": [
{
"SessionCookie": []
}
],
"description": "Returns form field definitions for Telegram and QQ channels",
"produces": [
"application/json"
],
"tags": [
"admin-message-gateway"
],
"summary": "List message gateway channel definitions",
"responses": {
"200": {
"description": "OK",
"schema": {
"allOf": [
{
"$ref": "#/definitions/response.Any"
},
{
"type": "object",
"properties": {
"data": {
"type": "array",
"items": {
"$ref": "#/definitions/message_gateway.Definition"
}
}
}
}
]
}
}
}
}
},
"/api/v1/admin/message-gateway/channels/{id}": {
"delete": {
"security": [
{
"SessionCookie": []
}
],
"description": "Deletes a channel and cascaded bindings and pairing codes",
"produces": [
"application/json"
],
"tags": [
"admin-message-gateway"
],
"summary": "Delete message gateway channel",
"parameters": [
{
"type": "integer",
"description": "channel id",
"name": "id",
"in": "path",
"required": true
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/response.Any"
}
},
"404": {
"description": "Not Found",
"schema": {
"$ref": "#/definitions/response.Any"
}
}
}
},
"patch": {
"security": [
{
"SessionCookie": []
}
],
"description": "Updates a channel; empty secrets keep the current ciphertext",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"admin-message-gateway"
],
"summary": "Update message gateway channel",
"parameters": [
{
"type": "integer",
"description": "channel id",
"name": "id",
"in": "path",
"required": true
},
{
"description": "update body",
"name": "request",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/message_gateway.UpdateChannelRequest"
}
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"allOf": [
{
"$ref": "#/definitions/response.Any"
},
{
"type": "object",
"properties": {
"data": {
"$ref": "#/definitions/message_gateway.ChannelDTO"
}
}
}
]
}
},
"400": {
"description": "Bad Request",
"schema": {
"$ref": "#/definitions/response.Any"
}
},
"404": {
"description": "Not Found",
"schema": {
"$ref": "#/definitions/response.Any"
}
}
}
}
},
"/api/v1/admin/message-gateway/channels/{id}/test": {
"post": {
"security": [
{
"SessionCookie": []
}
],
"description": "Probes stored credentials without returning secrets",
"produces": [
"application/json"
],
"tags": [
"admin-message-gateway"
],
"summary": "Test message gateway channel",
"parameters": [
{
"type": "integer",
"description": "channel id",
"name": "id",
"in": "path",
"required": true
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/response.Any"
}
},
"400": {
"description": "Bad Request",
"schema": {
"$ref": "#/definitions/response.Any"
}
},
"404": {
"description": "Not Found",
"schema": {
"$ref": "#/definitions/response.Any"
}
}
}
}
},
"/api/v1/admin/push/channels": {
"get": {
"security": [
@@ -6136,6 +6425,140 @@
}
}
},
"message_gateway.ChannelDTO": {
"type": "object",
"properties": {
"app_id": {
"type": "string"
},
"app_secret": {
"type": "string"
},
"base_url": {
"type": "string"
},
"bot_token": {
"type": "string"
},
"created_at": {
"type": "string"
},
"enabled": {
"type": "boolean"
},
"id": {
"type": "string",
"example": "0"
},
"name": {
"type": "string"
},
"owner_scope": {
"type": "string"
},
"portal_host": {
"type": "string"
},
"type": {
"type": "string"
},
"updated_at": {
"type": "string"
}
}
},
"message_gateway.CreateChannelRequest": {
"type": "object",
"properties": {
"app_id": {
"type": "string"
},
"app_secret": {
"type": "string"
},
"base_url": {
"type": "string"
},
"bot_token": {
"type": "string"
},
"enabled": {
"type": "boolean"
},
"name": {
"type": "string"
},
"portal_host": {
"type": "string"
},
"sandbox": {
"type": "string"
},
"type": {
"type": "string"
}
}
},
"message_gateway.Definition": {
"type": "object",
"properties": {
"fields": {
"type": "array",
"items": {
"$ref": "#/definitions/message_gateway.Field"
}
},
"name": {
"type": "string"
},
"type": {
"type": "string"
}
}
},
"message_gateway.Field": {
"type": "object",
"properties": {
"key": {
"type": "string"
},
"required": {
"type": "boolean"
},
"type": {
"type": "string"
}
}
},
"message_gateway.UpdateChannelRequest": {
"type": "object",
"properties": {
"app_id": {
"type": "string"
},
"app_secret": {
"type": "string"
},
"base_url": {
"type": "string"
},
"bot_token": {
"type": "string"
},
"enabled": {
"type": "boolean"
},
"name": {
"type": "string"
},
"portal_host": {
"type": "string"
},
"sandbox": {
"type": "string"
}
}
},
"model.AccessToken": {
"type": "object",
"properties": {
+259
View File
@@ -327,6 +327,94 @@ definitions:
date:
type: string
type: object
message_gateway.ChannelDTO:
properties:
app_id:
type: string
app_secret:
type: string
base_url:
type: string
bot_token:
type: string
created_at:
type: string
enabled:
type: boolean
id:
example: "0"
type: string
name:
type: string
owner_scope:
type: string
portal_host:
type: string
type:
type: string
updated_at:
type: string
type: object
message_gateway.CreateChannelRequest:
properties:
app_id:
type: string
app_secret:
type: string
base_url:
type: string
bot_token:
type: string
enabled:
type: boolean
name:
type: string
portal_host:
type: string
sandbox:
type: string
type:
type: string
type: object
message_gateway.Definition:
properties:
fields:
items:
$ref: '#/definitions/message_gateway.Field'
type: array
name:
type: string
type:
type: string
type: object
message_gateway.Field:
properties:
key:
type: string
required:
type: boolean
type:
type: string
type: object
message_gateway.UpdateChannelRequest:
properties:
app_id:
type: string
app_secret:
type: string
base_url:
type: string
bot_token:
type: string
enabled:
type: boolean
name:
type: string
portal_host:
type: string
sandbox:
type: string
type: object
model.AccessToken:
properties:
created_at:
@@ -2139,6 +2227,177 @@ paths:
summary: 系统日志实时推送
tags:
- admin
/api/v1/admin/message-gateway/channels:
get:
description: Returns all messaging channels; secrets are masked
produces:
- application/json
responses:
"200":
description: OK
schema:
allOf:
- $ref: '#/definitions/response.Any'
- properties:
data:
items:
$ref: '#/definitions/message_gateway.ChannelDTO'
type: array
type: object
security:
- SessionCookie: []
summary: List message gateway channels
tags:
- admin-message-gateway
post:
consumes:
- application/json
description: Creates a Telegram or QQ channel with encrypted credentials
parameters:
- description: create body
in: body
name: request
required: true
schema:
$ref: '#/definitions/message_gateway.CreateChannelRequest'
produces:
- application/json
responses:
"200":
description: OK
schema:
allOf:
- $ref: '#/definitions/response.Any'
- properties:
data:
$ref: '#/definitions/message_gateway.ChannelDTO'
type: object
"400":
description: Bad Request
schema:
$ref: '#/definitions/response.Any'
security:
- SessionCookie: []
summary: Create message gateway channel
tags:
- admin-message-gateway
/api/v1/admin/message-gateway/channels/{id}:
delete:
description: Deletes a channel and cascaded bindings and pairing codes
parameters:
- description: channel id
in: path
name: id
required: true
type: integer
produces:
- application/json
responses:
"200":
description: OK
schema:
$ref: '#/definitions/response.Any'
"404":
description: Not Found
schema:
$ref: '#/definitions/response.Any'
security:
- SessionCookie: []
summary: Delete message gateway channel
tags:
- admin-message-gateway
patch:
consumes:
- application/json
description: Updates a channel; empty secrets keep the current ciphertext
parameters:
- description: channel id
in: path
name: id
required: true
type: integer
- description: update body
in: body
name: request
required: true
schema:
$ref: '#/definitions/message_gateway.UpdateChannelRequest'
produces:
- application/json
responses:
"200":
description: OK
schema:
allOf:
- $ref: '#/definitions/response.Any'
- properties:
data:
$ref: '#/definitions/message_gateway.ChannelDTO'
type: object
"400":
description: Bad Request
schema:
$ref: '#/definitions/response.Any'
"404":
description: Not Found
schema:
$ref: '#/definitions/response.Any'
security:
- SessionCookie: []
summary: Update message gateway channel
tags:
- admin-message-gateway
/api/v1/admin/message-gateway/channels/{id}/test:
post:
description: Probes stored credentials without returning secrets
parameters:
- description: channel id
in: path
name: id
required: true
type: integer
produces:
- application/json
responses:
"200":
description: OK
schema:
$ref: '#/definitions/response.Any'
"400":
description: Bad Request
schema:
$ref: '#/definitions/response.Any'
"404":
description: Not Found
schema:
$ref: '#/definitions/response.Any'
security:
- SessionCookie: []
summary: Test message gateway channel
tags:
- admin-message-gateway
/api/v1/admin/message-gateway/channels/definitions:
get:
description: Returns form field definitions for Telegram and QQ channels
produces:
- application/json
responses:
"200":
description: OK
schema:
allOf:
- $ref: '#/definitions/response.Any'
- properties:
data:
items:
$ref: '#/definitions/message_gateway.Definition'
type: array
type: object
security:
- SessionCookie: []
summary: List message gateway channel definitions
tags:
- admin-message-gateway
/api/v1/admin/push/channels:
get:
description: 返回系统配置的所有消息通道列表,需要管理员权限