refactor(api): move interaction methods to InteractionApi (#6 commit 6/13)
Folds the entire `actions/interaction.ts` (sendPoke / sendLike / setGroupReaction / getEmojiLikes) plus the lone-survivor `setGroupEssence` from `actions/group-message.ts` into `apis/interaction.ts::InteractionApi`. Both action files deleted — the recall + markRead halves of group-message were already absorbed into MessageApi back in commit 1. Skipping the planned standalone GroupMessageApi commit: with only one method left (`setGroupEssence`), giving it its own Api class would be pure overhead. Essence is conceptually an "interaction" anyway (mark a message as essence is parallel to "react with an emoji"). Method renaming (Api namespace already says "interaction"): sendPoke → sendPoke (no rename — already minimal) sendLike → sendLike setGroupReaction → setReaction setGroupEssence → setEssence getEmojiLikes → getEmojiLikes (no rename — read-side, fine) Callers updated: `instance-context.ts`, `modules/message-actions.ts`, `actions/extended.ts`. Tests `interaction.test.ts` rewritten to use `new InteractionApi(bridge as any).method(...)` and gained a `setEssence` test. `group-message.test.ts` rewritten to target MessageApi.recall* / markRead* methods that were already moved. 587/587 tests pass.
This commit is contained in:
1 parent
c92daa56df
commit
73f1cd3c80
11 files changed
+155
-221
No files matched your search
@@ -88,7 +88,7 @@ export function register(h: ApiHandler, ctx: ApiActionContext): void {
|
||||
const userId = asNumber(params.user_id);
|
||||
const times = asNumber(params.times) || 1;
|
||||
if (!userId) return failedResponse(RETCODE.BAD_REQUEST, 'user_id is required');
|
||||
await ctx.bridge.sendLike(userId, times);
|
||||
await ctx.bridge.apis.interaction.sendLike(userId, times);
|
||||
return okResponse();
|
||||
});
|
||||
|
||||
@@ -177,7 +177,7 @@ export function register(h: ApiHandler, ctx: ApiActionContext): void {
|
||||
return failedResponse(RETCODE.BAD_REQUEST, 'group_id does not match message session');
|
||||
}
|
||||
|
||||
await ctx.bridge.setGroupReaction(meta.targetId, meta.sequence, code, isSet);
|
||||
await ctx.bridge.apis.interaction.setReaction(meta.targetId, meta.sequence, code, isSet);
|
||||
return okResponse();
|
||||
});
|
||||
|
||||
@@ -822,7 +822,7 @@ export function register(h: ApiHandler, ctx: ApiActionContext): void {
|
||||
try {
|
||||
const meta = ctx.getMessageMeta(messageId);
|
||||
if (!meta?.isGroup || !meta?.sequence) return failedResponse(RETCODE.BAD_REQUEST, 'message not found or not a group message');
|
||||
const result = await ctx.bridge.getEmojiLikes(meta.targetId, meta.sequence, emojiId);
|
||||
const result = await ctx.bridge.apis.interaction.getEmojiLikes(meta.targetId, meta.sequence, emojiId);
|
||||
return okResponse({ emoji_like_list: result.users.map(u => ({ user_id: String(u.uin), nick_name: '' })) });
|
||||
} catch (e) {
|
||||
return failedResponse(RETCODE.ACTION_FAILED, String(e));
|
||||
@@ -839,7 +839,7 @@ export function register(h: ApiHandler, ctx: ApiActionContext): void {
|
||||
try {
|
||||
const meta = ctx.getMessageMeta(messageId);
|
||||
if (!meta?.isGroup || !meta?.sequence) return failedResponse(RETCODE.BAD_REQUEST, 'message not found or not a group message');
|
||||
const result = await ctx.bridge.getEmojiLikes(meta.targetId, meta.sequence, emojiId, emojiType, count, cookie);
|
||||
const result = await ctx.bridge.apis.interaction.getEmojiLikes(meta.targetId, meta.sequence, emojiId, emojiType, count, cookie);
|
||||
return okResponse({
|
||||
result: 0,
|
||||
errMsg: '',
|
||||
|
||||
Reference in new issue
Block a user