refactor(api): move 10 profile methods to ProfileApi (#6 commit 8/13)

Inlines `actions/profile.ts` into `apis/profile.ts::ProfileApi`. The
file covers personal profile (nickname / long-nick / personal note),
online status (regular + DIY with custom face/wording), avatars
(personal + group via highway), input-status, likes (received from
others), unidirectional friend list, and custom face roaming.

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

  getProfileLike → getLike    (only obvious shortening; rest keep
                               their `set*`/`fetch*` prefixes because
                               they're already minimal at the call
                               site under `apis.profile.X`)

Callers updated: `instance-context.ts`, `actions/group-admin.ts`,
`actions/extended.ts`. The extended-actions test gained a sizable
`APIS_ROUTING` block covering profile/interaction/friend (all of the
late-stage Api hubs need auto-promotion now), so legacy tests that
stub `setDiyOnlineStatus`/`setOnlineStatus`/`deleteFriend`/etc as flat
methods keep working.

Tests rewritten to use `new ProfileApi(bridge as any).method(...)`.

587/587 tests pass.
This commit is contained in:
DrSmoothl committed 2026-05-20 23:26:35 +08:00
1 parent 2ec72d59f9
commit 62c5590fe1
10 files changed
+335 -381

No files matched your search

+8 -8
View File
@@ -661,7 +661,7 @@ export function register(h: ApiHandler, ctx: ApiActionContext): void {
try {
await ctx.bridge.setProfile(nickname, personalNote);
await ctx.bridge.apis.profile.setProfile(nickname, personalNote);
return okResponse();
} catch (e) {
return failedResponse(RETCODE.ACTION_FAILED, String(e));
@@ -681,7 +681,7 @@ export function register(h: ApiHandler, ctx: ApiActionContext): void {
try {
await ctx.bridge.setOnlineStatus(status, extStatus, batteryStatus);
await ctx.bridge.apis.profile.setOnlineStatus(status, extStatus, batteryStatus);
return okResponse();
} catch (e) {
return failedResponse(RETCODE.ACTION_FAILED, String(e));
@@ -699,7 +699,7 @@ export function register(h: ApiHandler, ctx: ApiActionContext): void {
const wording = asString(params.wording);
if (!faceId) return failedResponse(RETCODE.BAD_REQUEST, 'face_id is required');
try {
await ctx.bridge.setDiyOnlineStatus(faceId, wording, faceType);
await ctx.bridge.apis.profile.setDiyOnlineStatus(faceId, wording, faceType);
return okResponse();
} catch (err) {
return failedResponse(RETCODE.ACTION_FAILED, err instanceof Error ? err.message : String(err));
@@ -808,7 +808,7 @@ export function register(h: ApiHandler, ctx: ApiActionContext): void {
h.registerAction('fetch_custom_face', async (params) => {
const count = asNumber(params.count) || 10;
try {
const urls = await ctx.bridge.fetchCustomFace(count);
const urls = await ctx.bridge.apis.profile.fetchCustomFace(count);
return okResponse(urls);
} catch (e) {
return failedResponse(RETCODE.ACTION_FAILED, String(e));
@@ -898,7 +898,7 @@ export function register(h: ApiHandler, ctx: ApiActionContext): void {
h.registerAction('get_unidirectional_friend_list', async () => {
try {
const data = await ctx.bridge.getUnidirectionalFriendList();
const data = await ctx.bridge.apis.profile.getUnidirectionalFriendList();
return okResponse(data);
} catch (e) {
return failedResponse(RETCODE.ACTION_FAILED, String(e));
@@ -914,7 +914,7 @@ export function register(h: ApiHandler, ctx: ApiActionContext): void {
try {
await ctx.bridge.setSelfLongNick(longNick);
await ctx.bridge.apis.profile.setSelfLongNick(longNick);
return okResponse({});
} catch (e) {
return failedResponse(RETCODE.ACTION_FAILED, String(e));
@@ -935,7 +935,7 @@ export function register(h: ApiHandler, ctx: ApiActionContext): void {
try {
await ctx.bridge.setAvatar(file);
await ctx.bridge.apis.profile.setAvatar(file);
return okResponse();
} catch (e) {
return failedResponse(RETCODE.ACTION_FAILED, String(e));
@@ -957,7 +957,7 @@ export function register(h: ApiHandler, ctx: ApiActionContext): void {
try {
await ctx.bridge.setInputStatus(userId, eventType);
await ctx.bridge.apis.profile.setInputStatus(userId, eventType);
return okResponse({});
} catch (e) {
return failedResponse(RETCODE.ACTION_FAILED, String(e));