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

+5 -1
View File
@@ -22,6 +22,7 @@
import type { BridgeContext } from '../bridge-context';
import { ContactsApi } from './contacts';
import { FriendApi } from './friend';
import { GroupAdminApi } from './group-admin';
import { GroupAlbumApi } from './group-album';
import { GroupFileApi } from './group-file';
@@ -41,8 +42,9 @@ export interface ApiHub {
readonly groupAlbum: GroupAlbumApi;
/** Interactive engagement: poke / like / reaction / essence / emoji-like-list. */
readonly interaction: InteractionApi;
/** Friend roster mutations: handleRequest / delete / setRemark. */
readonly friend: FriendApi;
// Pending — added as later commits land:
// readonly friend: FriendApi;
// readonly interaction: InteractionApi;
// readonly profile: ProfileApi;
// readonly forward: ForwardApi;
@@ -67,6 +69,7 @@ export function buildApiHub(ctx: BridgeContext): ApiHub {
groupFile: new GroupFileApi(ctx),
groupAlbum: new GroupAlbumApi(ctx),
interaction: new InteractionApi(ctx),
friend: new FriendApi(ctx),
};
}
@@ -74,6 +77,7 @@ export function buildApiHub(ctx: BridgeContext): ApiHub {
// `import type { MessageApi } from '@snowluma/core/.../apis'` for
// signature use. Concrete instances always come from `bridge.apis.*`.
export { ContactsApi } from './contacts';
export { FriendApi } from './friend';
export { GroupAdminApi } from './group-admin';
export { GroupAlbumApi } from './group-album';
export { GroupFileApi } from './group-file';