12 files changed
+1066
-11
No files matched your search
@@ -2475,6 +2475,52 @@ export const actions = [
|
||||
},
|
||||
}),
|
||||
|
||||
groupAction({
|
||||
name: 'get_group_todo_list',
|
||||
summary: '获取群待办列表',
|
||||
returns: '群待办数组,包含可用于待办操作的消息标识、服务端摘要与时间',
|
||||
readOnly: true,
|
||||
run: async (p, ctx) => {
|
||||
const todos = await ctx.bridge.apis.extras.getGroupTodoList(p.group_id);
|
||||
const projections = todos.map((todo) => {
|
||||
const messageId = hashMessageIdInt32(
|
||||
todo.sequence,
|
||||
p.group_id,
|
||||
GROUP_MESSAGE_EVENT,
|
||||
);
|
||||
const meta: MessageMeta = {
|
||||
isGroup: true,
|
||||
targetId: p.group_id,
|
||||
sequence: todo.sequence,
|
||||
sequenceAuthoritative: true,
|
||||
eventName: GROUP_MESSAGE_EVENT,
|
||||
clientSequence: 0,
|
||||
random: todo.random,
|
||||
timestamp: todo.createdAt,
|
||||
};
|
||||
return { todo, messageId, meta };
|
||||
});
|
||||
|
||||
ctx.cacheMessageMetas(projections.map(({ messageId, meta }) => ({
|
||||
messageId,
|
||||
meta,
|
||||
})));
|
||||
|
||||
return okResponse(projections.map(({ todo, messageId }) => {
|
||||
const cached = ctx.getMessage(messageId)?.message;
|
||||
return {
|
||||
message_id: messageId,
|
||||
message_seq: todo.sequence,
|
||||
message_random: todo.random,
|
||||
message: Array.isArray(cached) ? cached : null,
|
||||
text: todo.text,
|
||||
create_time: todo.createdAt,
|
||||
update_time: todo.updatedAt,
|
||||
};
|
||||
}));
|
||||
},
|
||||
}),
|
||||
|
||||
groupAction({
|
||||
name: 'set_group_todo',
|
||||
summary: '设置群待办',
|
||||
|
||||
@@ -90,9 +90,9 @@ describe('compileActionRegistry namespace conflicts', () => {
|
||||
});
|
||||
|
||||
describe('compiled production Action registry', () => {
|
||||
it('preserves all 187 canonical Action docs', () => {
|
||||
expect(ACTION_REGISTRY.actions).toHaveLength(187);
|
||||
expect(collectActionDocs()).toHaveLength(187);
|
||||
it('preserves all 190 canonical Action docs', () => {
|
||||
expect(ACTION_REGISTRY.actions).toHaveLength(190);
|
||||
expect(collectActionDocs()).toHaveLength(190);
|
||||
});
|
||||
|
||||
it('resolves every executable name to exactly one canonical doc', () => {
|
||||
|
||||
@@ -72,6 +72,7 @@ const APIS_ROUTING: Record<string, [string, string]> = {
|
||||
setGroupTodo: ['extras', 'setGroupTodo'],
|
||||
completeGroupTodo: ['extras', 'completeGroupTodo'],
|
||||
cancelGroupTodo: ['extras', 'cancelGroupTodo'],
|
||||
getGroupTodoList: ['extras', 'getGroupTodoList'],
|
||||
getStrangerStatus: ['extras', 'getStrangerStatus'],
|
||||
fetchAiVoiceList: ['extras', 'fetchAiVoiceList'],
|
||||
fetchAiVoice: ['extras', 'fetchAiVoice'],
|
||||
@@ -1176,6 +1177,82 @@ describe('extended-actions / set_/complete_/cancel_group_todo', () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe('extended-actions / get_group_todo_list', () => {
|
||||
it('maps QQ identities to OneBot ids, caches metadata, and includes cached content', async () => {
|
||||
const getGroupTodoList = vi.fn(async () => [{
|
||||
sourceId: '5631_0',
|
||||
sequence: 5631,
|
||||
random: 0,
|
||||
text: '测试待办',
|
||||
createdAt: 1735000000,
|
||||
updatedAt: 1735000001,
|
||||
}]);
|
||||
const bridge = fakeBridge({ getGroupTodoList });
|
||||
const messageId = hashMessageIdInt32(5631, 100, GROUP_MESSAGE_EVENT);
|
||||
const cacheMessageMetas = vi.fn();
|
||||
const message = [{ type: 'text', data: { text: '原消息' } }];
|
||||
const ctx = fakeCtx(bridge, {
|
||||
cacheMessageMetas,
|
||||
getMessage: (id) => id === messageId ? { message } : null,
|
||||
});
|
||||
|
||||
const response = await makeHandler(ctx).handle('get_group_todo_list', { group_id: 100 });
|
||||
|
||||
expect(getGroupTodoList).toHaveBeenCalledWith(100);
|
||||
expect(cacheMessageMetas).toHaveBeenCalledWith([{
|
||||
messageId,
|
||||
meta: {
|
||||
isGroup: true,
|
||||
targetId: 100,
|
||||
sequence: 5631,
|
||||
sequenceAuthoritative: true,
|
||||
eventName: GROUP_MESSAGE_EVENT,
|
||||
clientSequence: 0,
|
||||
random: 0,
|
||||
timestamp: 1735000000,
|
||||
},
|
||||
}]);
|
||||
expect(response).toMatchObject({
|
||||
status: 'ok',
|
||||
data: [{
|
||||
message_id: messageId,
|
||||
message_seq: 5631,
|
||||
message_random: 0,
|
||||
message,
|
||||
text: '测试待办',
|
||||
create_time: 1735000000,
|
||||
update_time: 1735000001,
|
||||
}],
|
||||
});
|
||||
});
|
||||
|
||||
it('still returns a usable message id when the original body is not cached', async () => {
|
||||
const bridge = fakeBridge({
|
||||
getGroupTodoList: vi.fn(async () => [{
|
||||
sourceId: '88_0',
|
||||
sequence: 88,
|
||||
random: 0,
|
||||
text: '',
|
||||
createdAt: 0,
|
||||
updatedAt: 0,
|
||||
}]),
|
||||
});
|
||||
const response = await makeHandler(fakeCtx(bridge)).handle(
|
||||
'get_group_todo_list',
|
||||
{ group_id: 100 },
|
||||
);
|
||||
|
||||
expect(response).toMatchObject({
|
||||
status: 'ok',
|
||||
data: [{
|
||||
message_id: hashMessageIdInt32(88, 100, GROUP_MESSAGE_EVENT),
|
||||
message_seq: 88,
|
||||
message: null,
|
||||
}],
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('extended-actions / set_group_reaction', () => {
|
||||
it('rejects a local-only message id without calling the reaction protocol', async () => {
|
||||
const setGroupReaction = vi.fn(async () => {});
|
||||
|
||||
Reference in new issue
Block a user