feat: implement get group notice
This commit is contained in:
1 parent
51c2fa285a
commit
a0d584375a
6 files changed
+116
-3
No files matched your search
@@ -261,8 +261,20 @@ export function register(h: ApiHandler, ctx: ApiActionContext): void {
|
||||
}
|
||||
});
|
||||
|
||||
h.registerAction('_get_group_notice', async () => {
|
||||
return failedResponse(RETCODE.ACTION_FAILED, 'not yet implemented');
|
||||
h.registerAction('_get_group_notice', async (params) => {
|
||||
const groupId = asNumber(params.group_id);
|
||||
if (!groupId) return failedResponse(RETCODE.BAD_REQUEST, 'group_id is required');
|
||||
|
||||
if (!ctx.getGroupNotice) {
|
||||
return failedResponse(RETCODE.ACTION_FAILED, 'not implemented');
|
||||
}
|
||||
|
||||
try {
|
||||
const notices = await ctx.getGroupNotice(groupId);
|
||||
return okResponse(notices);
|
||||
} catch (e) {
|
||||
return failedResponse(RETCODE.ACTION_FAILED, String(e));
|
||||
}
|
||||
});
|
||||
|
||||
h.registerAction('_del_group_notice', async () => {
|
||||
|
||||
@@ -99,6 +99,7 @@ export interface ApiActionContext {
|
||||
getGroupEssence?: (groupId: number, pageStart?: number, pageLimit?: number) => Promise<GroupEssenceMsgRet>;
|
||||
getGroupEssenceAll?: (groupId: number) => Promise<GroupEssenceMsgRet[]>;
|
||||
sendGroupNotice?: (groupId: number, content: string, options?: any) => Promise<any>;
|
||||
getGroupNotice?: (groupId: number) => Promise<any[]>;
|
||||
}
|
||||
|
||||
type ActionHandler = (params: JsonObject) => Promise<import('./types').ApiResponse>;
|
||||
|
||||
@@ -129,6 +129,7 @@ export function buildApiContext(ref: InstanceRef): ApiActionContext {
|
||||
getGroupEssence: (groupId: number, pageStart: number = 0, pageLimit: number = 50) => bridge.getGroupEssence(groupId, pageStart, pageLimit),
|
||||
getGroupEssenceAll: (groupId: number) => bridge.getGroupEssenceAll(groupId),
|
||||
sendGroupNotice: (groupId: number, content: string, options?: any) => bridge.sendGroupNotice(groupId, content, options),
|
||||
getGroupNotice: (groupId: number) => bridge.getGroupNotice(groupId),
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user