fix(onebot): return profile like user details
Restore the interaction user lists returned by get_profile_like and keep self and other-user lookups consistent with the current client behavior. Resolve missing account identities when needed, surface lookup failures, and update the public action catalog with the completed response shape. Add regression coverage for request selection, response decoding, identity enrichment, and malformed results. Fixes #349
This commit is contained in:
9 files changed
+717
-70
No files matched your search
@@ -19,9 +19,12 @@ import { SetInputStatus } from '@snowluma/protocol/oidb-services/profile/set-inp
|
||||
import { SetProfile } from '@snowluma/protocol/oidb-services/profile/set-profile';
|
||||
import { SetSelfLongNick } from '@snowluma/protocol/oidb-services/profile/set-self-long-nick';
|
||||
import { protobuf_decode, protobuf_encode } from '@snowluma/proton';
|
||||
import { createLogger } from '@snowluma/common/logger';
|
||||
import type { Bridge } from '../bridge';
|
||||
import type { BridgeContext } from '../bridge-context';
|
||||
|
||||
const log = createLogger('Bridge.Profile');
|
||||
|
||||
function asBridge(ctx: BridgeContext): Bridge { return ctx as unknown as Bridge; }
|
||||
|
||||
export interface CustomFaceDetail {
|
||||
@@ -133,8 +136,37 @@ export class ProfileApi {
|
||||
|
||||
// ─────────────── queries on me / my contacts ───────────────
|
||||
|
||||
getLike(userId?: number, start = 0, limit = 10): Promise<LikeInfo> {
|
||||
return GetLike.invoke(this.ctx, { userId, start, limit });
|
||||
async getLike(userId?: number, start = 0, limit = 10): Promise<LikeInfo> {
|
||||
const info = await GetLike.invoke(this.ctx, { userId, start, limit });
|
||||
const users = [...info.favoriteInfo.userInfos, ...info.voteInfo.userInfos];
|
||||
const unresolved = new Map<string, typeof users>();
|
||||
|
||||
for (const user of users) {
|
||||
if (user.uin > 0) continue;
|
||||
const sameUid = unresolved.get(user.uid) ?? [];
|
||||
sameUid.push(user);
|
||||
unresolved.set(user.uid, sameUid);
|
||||
}
|
||||
|
||||
await Promise.all([...unresolved].map(async ([uid, sameUid]) => {
|
||||
try {
|
||||
const profile = await this.ctx.apis.contacts.fetchUserProfileByUid(uid);
|
||||
if (profile.uin <= 0) {
|
||||
log.warn('profile-like user resolution returned no uin: uid=%s', uid);
|
||||
return;
|
||||
}
|
||||
for (const user of sameUid) user.uin = profile.uin;
|
||||
} catch (error) {
|
||||
log.error(
|
||||
'profile-like user resolution failed: uid=%s err=%s',
|
||||
uid,
|
||||
error instanceof Error ? error.message : String(error),
|
||||
);
|
||||
throw error;
|
||||
}
|
||||
}));
|
||||
|
||||
return info;
|
||||
}
|
||||
|
||||
getUnidirectionalFriendList(): Promise<UnidirectionalFriendEntry[]> {
|
||||
|
||||
Reference in new issue
Block a user