Skip to content

Commit

Permalink
Merge pull request #239 from clansty/main
Browse files Browse the repository at this point in the history
fix: revert get_friends_with_category return type
  • Loading branch information
MliKiowa authored Aug 12, 2024
2 parents b58a194 + 8f6d26b commit 20a37fe
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 17 deletions.
18 changes: 9 additions & 9 deletions src/core/apis/friend.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,21 +54,21 @@ export class NTQQFriendApi {
uids.push(
...buddyListV2.flatMap(item => {
item.buddyUids.forEach(uid => {
categoryMap.set(uid, { categoryId: item.categoryId, categroyName: item.categroyName });
categoryMap.set(uid, { categoryId: item.categoryId, categoryName: item.categroyName });
});
return item.buddyUids;
}));
const data = await this.core.eventWrapper.callNoListenerEvent<NodeIKernelProfileService['getCoreAndBaseInfo']>(
'NodeIKernelProfileService/getCoreAndBaseInfo', 5000, 'nodeStore', uids,
);
return Array.from(data).map(([key, value]) => {
const category = categoryMap.get(key);
return category ? {
...value,
categoryId: category.categoryId,
categroyName: category.categroyName,
} : value;
});
return buddyListV2.map(category => ({
categoryId: category.categoryId,
categorySortId: category.categorySortId,
categoryName: category.categroyName,
categoryMbCount: category.categroyMbCount,
onlineCount: category.onlineCount,
buddyList: category.buddyUids.map(uid => data.get(uid)!).filter(value => value),
}));
}

async isBuddy(uid: string) {
Expand Down
5 changes: 1 addition & 4 deletions src/core/entities/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -176,10 +176,7 @@ export interface SimpleInfo {
intimate: any | null;
}

export interface FriendV2 extends SimpleInfo {
categoryId?: number;
categroyName?: string;
}
export type FriendV2 = SimpleInfo;

export interface SelfStatusInfo {
uid: string;
Expand Down
5 changes: 4 additions & 1 deletion src/onebot/action/extends/GetFriendWithCategory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@ export class GetFriendWithCategory extends BaseAction<void, any> {
async _handle(payload: void) {
if (this.CoreContext.context.basicInfoWrapper.requireMinNTQQBuild('26702')) {
//全新逻辑
return OB11Constructor.friendsV2(await this.CoreContext.apis.FriendApi.getBuddyV2ExWithCate(true));
return (await this.CoreContext.apis.FriendApi.getBuddyV2ExWithCate(true)).map(category => ({
...category,
buddyList: OB11Constructor.friendsV2(category.buddyList),
}));
} else {
throw new Error('this ntqq version not support, must be 26702 or later');
}
Expand Down
2 changes: 0 additions & 2 deletions src/onebot/helper/data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -656,8 +656,6 @@ export class OB11Constructor {
remark: friend.coreInfo.nick,
sex: sexValue,
level: 0,
categroyName: friend.categroyName,
categoryId: friend.categoryId,
});
});
return data;
Expand Down
2 changes: 1 addition & 1 deletion src/onebot/types/entity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export interface OB11User {
age?: number;
qid?: string;
login_days?: number;
categroyName?: string;
categoryName?: string;
categoryId?: number;
}

Expand Down

0 comments on commit 20a37fe

Please sign in to comment.