refactor(api): move 3 friend methods to FriendApi (#6 commit 7/13)

Inlines `actions/friend.ts` into `apis/friend.ts::FriendApi`. The
roster READ side (fetchFriendList) stays on ContactsApi where it
naturally lives next to fetchGroupList — the friend/group rosters
share the same pipeline.

Method renaming (Api namespace already says "friend"):

  setFriendAddRequest → handleRequest    (accept/reject UID-or-flag)
  deleteFriend        → delete           (with cache refresh)
  setFriendRemark     → setRemark

`delete` still does the post-OIDB best-effort
`apis.contacts.fetchFriendList()` refresh to evict the stale entry.

Callers updated: `instance-context.ts`, `actions/extended.ts`.
Tests rewritten to use `new FriendApi(bridge as any).method(...)`.

587/587 tests pass.
This commit is contained in:
DrSmoothl committed 2026-05-20 23:20:33 +08:00
1 parent 73f1cd3c80
commit 2ec72d59f9
8 files changed
+97 -80

No files matched your search

+1 -1
View File
@@ -540,7 +540,7 @@ export function register(h: ApiHandler, ctx: ApiActionContext): void {
if (params.remark === undefined) {
return failedResponse(RETCODE.BAD_REQUEST, 'remark is required (pass an empty string to clear)');
}
await ctx.bridge.setFriendRemark(userId, asString(params.remark));
await ctx.bridge.apis.friend.setRemark(userId, asString(params.remark));
return okResponse();
});