mirror of
https://github.com/Rain-kl/OpenFlare.git
synced 2026-09-30 22:26:38 +08:00
feat(message-gateway): add admin channel cards and per-type forms
This commit is contained in:
@@ -23,6 +23,7 @@ import {
|
||||
import { AuthService } from './auth';
|
||||
import { ConfigService } from './config';
|
||||
import { DbManageService } from './db-manage';
|
||||
import { AdminMessageGatewayService } from './message-gateway';
|
||||
import { PushService } from './push';
|
||||
import { AdminUploadService, UploadService } from './upload';
|
||||
import { UserService } from './user';
|
||||
@@ -43,6 +44,7 @@ const services = {
|
||||
adminUpload: AdminUploadService,
|
||||
dbManage: DbManageService,
|
||||
push: PushService,
|
||||
adminMessageGateway: AdminMessageGatewayService,
|
||||
} as const;
|
||||
|
||||
export default services;
|
||||
@@ -167,6 +169,16 @@ export type {
|
||||
} from './db-manage';
|
||||
|
||||
export { PushService } from './push';
|
||||
export { AdminMessageGatewayService } from './message-gateway';
|
||||
export type {
|
||||
MessageChannel,
|
||||
MessageChannelDefinition,
|
||||
CreateMessageChannelRequest,
|
||||
UpdateMessageChannelRequest,
|
||||
PublicMessageChannel,
|
||||
MessageBinding,
|
||||
BindMessageChannelRequest,
|
||||
} from './message-gateway';
|
||||
export type {
|
||||
PushEvent,
|
||||
PushHistory,
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
// Copyright 2026 Arctel.net
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { BaseService } from '@/lib/services/core';
|
||||
import type {
|
||||
CreateMessageChannelRequest,
|
||||
MessageChannel,
|
||||
MessageChannelDefinition,
|
||||
UpdateMessageChannelRequest,
|
||||
} from './types';
|
||||
|
||||
export class AdminMessageGatewayService extends BaseService {
|
||||
protected static readonly basePath = '/api/v1/admin/message-gateway';
|
||||
|
||||
static async list(): Promise<MessageChannel[]> {
|
||||
return this.get<MessageChannel[]>('/channels');
|
||||
}
|
||||
|
||||
static async definitions(): Promise<MessageChannelDefinition[]> {
|
||||
return this.get<MessageChannelDefinition[]>('/channels/definitions');
|
||||
}
|
||||
|
||||
static async create(
|
||||
data: CreateMessageChannelRequest,
|
||||
): Promise<MessageChannel> {
|
||||
return this.post<MessageChannel>('/channels', data);
|
||||
}
|
||||
|
||||
static async update(
|
||||
id: string,
|
||||
data: UpdateMessageChannelRequest,
|
||||
): Promise<MessageChannel> {
|
||||
return this.patch<MessageChannel>(`/channels/${id}`, data);
|
||||
}
|
||||
|
||||
static async remove(id: string): Promise<void> {
|
||||
return this.delete<void>(`/channels/${id}`);
|
||||
}
|
||||
|
||||
static async test(id: string): Promise<void> {
|
||||
return this.post<void>(`/channels/${id}/test`);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
// Copyright 2026 Arctel.net
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
export * from './types';
|
||||
export * from './admin.service';
|
||||
@@ -0,0 +1,73 @@
|
||||
// Copyright 2026 Arctel.net
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
export type MessageChannelType = 'telegram' | 'qq';
|
||||
|
||||
export interface MessageChannelField {
|
||||
key: string;
|
||||
type?: string;
|
||||
required?: boolean;
|
||||
}
|
||||
|
||||
export interface MessageChannelDefinition {
|
||||
type: MessageChannelType | string;
|
||||
name: string;
|
||||
fields: MessageChannelField[];
|
||||
}
|
||||
|
||||
export interface MessageChannel {
|
||||
id: string;
|
||||
name: string;
|
||||
type: MessageChannelType | string;
|
||||
owner_scope: string;
|
||||
enabled: boolean;
|
||||
bot_token?: string;
|
||||
app_id?: string;
|
||||
app_secret?: string;
|
||||
base_url?: string;
|
||||
portal_host?: string;
|
||||
created_at: string;
|
||||
updated_at: string;
|
||||
}
|
||||
|
||||
export interface CreateMessageChannelRequest {
|
||||
name: string;
|
||||
type: string;
|
||||
enabled?: boolean;
|
||||
bot_token?: string;
|
||||
app_id?: string;
|
||||
app_secret?: string;
|
||||
base_url?: string;
|
||||
portal_host?: string;
|
||||
}
|
||||
|
||||
export interface UpdateMessageChannelRequest {
|
||||
name?: string;
|
||||
enabled?: boolean;
|
||||
bot_token?: string;
|
||||
app_id?: string;
|
||||
app_secret?: string;
|
||||
base_url?: string;
|
||||
portal_host?: string;
|
||||
}
|
||||
|
||||
export interface PublicMessageChannel {
|
||||
id: string;
|
||||
name: string;
|
||||
type: MessageChannelType | string;
|
||||
}
|
||||
|
||||
export interface MessageBinding {
|
||||
id: string;
|
||||
user_id: string;
|
||||
channel_id: string;
|
||||
channel_name: string;
|
||||
channel_type: string;
|
||||
platform_user_id: string;
|
||||
created_at: string;
|
||||
}
|
||||
|
||||
export interface BindMessageChannelRequest {
|
||||
channel_id: string;
|
||||
code: string;
|
||||
}
|
||||
Reference in New Issue
Block a user