mirror of
https://github.com/NapNeko/NapCatQQ.git
synced 2025-07-19 12:03:37 +00:00
refactor: api getbuddyv2
This commit is contained in:
@@ -1,21 +1,31 @@
|
|||||||
import { FriendRequest, User } from '@/core/entities';
|
import { FriendRequest, SimpleInfo, User } from '@/core/entities';
|
||||||
import { BuddyListReqType, napCatCore, NodeIKernelBuddyListener, OnBuddyChangeParams } from '@/core';
|
import { BuddyListReqType, napCatCore, NodeIKernelBuddyListener, NodeIKernelProfileService, OnBuddyChangeParams } from '@/core';
|
||||||
import { NTEventDispatch } from '@/common/utils/EventTask';
|
import { NTEventDispatch } from '@/common/utils/EventTask';
|
||||||
|
|
||||||
export class NTQQFriendApi {
|
export class NTQQFriendApi {
|
||||||
static async getBuddyV2(refresh = false) {
|
static async getBuddyV2(refresh = false): Promise<SimpleInfo[]> {
|
||||||
// NTEventDispatch.RegisterListen<NodeIKernelBuddyListener['onBuddyListChange']>('NodeIKernelBuddyListener/onBuddyListChange', 1, 5000, (arg: OnBuddyChangeParams) => {
|
// NTEventDispatch.RegisterListen<NodeIKernelBuddyListener['onBuddyListChange']>('NodeIKernelBuddyListener/onBuddyListChange', 1, 5000, (arg: OnBuddyChangeParams) => {
|
||||||
// console.log(arg);
|
// console.log(arg);
|
||||||
// return true;
|
// return true;
|
||||||
// }).catch().then();
|
// }).catch().then();
|
||||||
|
let uids: string[];
|
||||||
if (!refresh) {
|
if (!refresh) {
|
||||||
return await napCatCore.session.getBuddyService().getBuddyListFromCache('0');
|
uids = (await napCatCore.session.getBuddyService().getBuddyListFromCache('0')).flatMap((item) => item.buddyUids);
|
||||||
}
|
}
|
||||||
return (await (napCatCore.session.getBuddyService().getBuddyListV2('0', BuddyListReqType.KNOMAL))).data;
|
uids = (await (napCatCore.session.getBuddyService().getBuddyListV2('0', BuddyListReqType.KNOMAL))).data.flatMap((item) => item.buddyUids);
|
||||||
|
let data = await NTEventDispatch.CallNoListenerEvent<NodeIKernelProfileService['getCoreAndBaseInfo']>('NodeIKernelProfileService/getCoreAndBaseInfo', 5000, 'nodeStore', uids);
|
||||||
|
//遍历data
|
||||||
|
let retArr = Array.from(data.values());
|
||||||
|
return retArr;
|
||||||
}
|
}
|
||||||
static async isBuddy(uid: string) {
|
static async isBuddy(uid: string) {
|
||||||
return napCatCore.session.getBuddyService().isBuddy(uid);
|
return napCatCore.session.getBuddyService().isBuddy(uid);
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* @deprecated
|
||||||
|
* @param forced
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
static async getFriends(forced = false): Promise<User[]> {
|
static async getFriends(forced = false): Promise<User[]> {
|
||||||
let [_retData, _BuddyArg] = await NTEventDispatch.CallNormalEvent
|
let [_retData, _BuddyArg] = await NTEventDispatch.CallNormalEvent
|
||||||
<(force: boolean) => Promise<any>, (arg: OnBuddyChangeParams) => void>
|
<(force: boolean) => Promise<any>, (arg: OnBuddyChangeParams) => void>
|
||||||
|
@@ -2,11 +2,12 @@ import { QQLevel, Sex } from './user';
|
|||||||
|
|
||||||
export interface Group {
|
export interface Group {
|
||||||
groupCode: string,
|
groupCode: string,
|
||||||
|
createTime?:string,//高版本才有
|
||||||
maxMember: number,
|
maxMember: number,
|
||||||
memberCount: number,
|
memberCount: number,
|
||||||
groupName: string,
|
groupName: string,
|
||||||
groupStatus: 0,
|
groupStatus: number,
|
||||||
memberRole: 2,
|
memberRole: number,
|
||||||
isTop: boolean,
|
isTop: boolean,
|
||||||
toppedTimestamp: string,
|
toppedTimestamp: string,
|
||||||
privilegeFlag: number, //65760
|
privilegeFlag: number, //65760
|
||||||
|
@@ -9,14 +9,14 @@ export interface BuddyCategoryType {
|
|||||||
categroyMbCount: number;
|
categroyMbCount: number;
|
||||||
buddyList: User[];
|
buddyList: User[];
|
||||||
}
|
}
|
||||||
interface CoreInfo {
|
export interface CoreInfo {
|
||||||
uid: string;
|
uid: string;
|
||||||
uin: string;
|
uin: string;
|
||||||
nick: string;
|
nick: string;
|
||||||
remark: string;
|
remark: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface BaseInfo {
|
export interface BaseInfo {
|
||||||
qid: string;
|
qid: string;
|
||||||
longNick: string;
|
longNick: string;
|
||||||
birthday_year: number;
|
birthday_year: number;
|
||||||
@@ -162,16 +162,16 @@ interface PhotoWall {
|
|||||||
picList: Pic[];
|
picList: Pic[];
|
||||||
}
|
}
|
||||||
|
|
||||||
interface SimpleInfo {
|
export interface SimpleInfo {
|
||||||
uid: string;
|
uid?: string;
|
||||||
uin: string;
|
uin?: string;
|
||||||
coreInfo: CoreInfo;
|
coreInfo: CoreInfo;
|
||||||
baseInfo: BaseInfo;
|
baseInfo: BaseInfo;
|
||||||
status: UserStatus;
|
status: UserStatus | null;
|
||||||
vasInfo: VasInfo;
|
vasInfo: VasInfo | null;
|
||||||
relationFlags: RelationFlags;
|
relationFlags: RelationFlags | null;
|
||||||
otherFlags: any;
|
otherFlags: any | null;
|
||||||
intimate: any;
|
intimate: any | null;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface UserDetailInfoListenerArg {
|
export interface UserDetailInfoListenerArg {
|
||||||
@@ -272,7 +272,7 @@ export interface Friend extends User { }
|
|||||||
export enum BizKey {
|
export enum BizKey {
|
||||||
KPRIVILEGEICON,
|
KPRIVILEGEICON,
|
||||||
KPHOTOWALL
|
KPHOTOWALL
|
||||||
}
|
}
|
||||||
export interface UserDetailInfoByUin {
|
export interface UserDetailInfoByUin {
|
||||||
result: number,
|
result: number,
|
||||||
errMsg: string,
|
errMsg: string,
|
||||||
|
@@ -5,7 +5,7 @@ import { GeneralCallResult } from '@/core/services/common';
|
|||||||
export interface QueryMsgsParams {
|
export interface QueryMsgsParams {
|
||||||
chatInfo: Peer,
|
chatInfo: Peer,
|
||||||
filterMsgType: [],
|
filterMsgType: [],
|
||||||
filterSendersUid: [],
|
filterSendersUid: string[],
|
||||||
filterMsgFromTime: string,
|
filterMsgFromTime: string,
|
||||||
filterMsgToTime: string,
|
filterMsgToTime: string,
|
||||||
pageLimit: number,
|
pageLimit: number,
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
import { AnyCnameRecord } from 'node:dns';
|
import { AnyCnameRecord } from 'node:dns';
|
||||||
import { BizKey, ModifyProfileParams, UserDetailInfoByUin } from '../entities';
|
import { BaseInfo, BizKey, CoreInfo, ModifyProfileParams, SimpleInfo, UserDetailInfoByUin } from '../entities';
|
||||||
import { NodeIKernelProfileListener } from '../listeners';
|
import { NodeIKernelProfileListener } from '../listeners';
|
||||||
import { GeneralCallResult } from '@/core/services/common';
|
import { GeneralCallResult } from '@/core/services/common';
|
||||||
export enum UserDetailSource {
|
export enum UserDetailSource {
|
||||||
@@ -14,6 +14,17 @@ export enum ProfileBizType {
|
|||||||
KOTHER
|
KOTHER
|
||||||
}
|
}
|
||||||
export interface NodeIKernelProfileService {
|
export interface NodeIKernelProfileService {
|
||||||
|
// {
|
||||||
|
// coreInfo: CoreInfo,
|
||||||
|
// baseInfo: BaseInfo,
|
||||||
|
// status: null,
|
||||||
|
// vasInfo: null,
|
||||||
|
// relationFlags: null,
|
||||||
|
// otherFlags: null,
|
||||||
|
// intimate: null
|
||||||
|
// }
|
||||||
|
getCoreAndBaseInfo(callfrom: string, uids: string[]): Promise<Map<string, SimpleInfo>>;
|
||||||
|
|
||||||
fetchUserDetailInfo(trace: string, uids: string[], arg2: number, arg3: number[]): Promise<unknown>;
|
fetchUserDetailInfo(trace: string, uids: string[], arg2: number, arg3: number[]): Promise<unknown>;
|
||||||
|
|
||||||
addKernelProfileListener(listener: NodeIKernelProfileListener): number;
|
addKernelProfileListener(listener: NodeIKernelProfileListener): number;
|
||||||
|
@@ -21,7 +21,7 @@ export interface NodeIKernelRobotService {
|
|||||||
|
|
||||||
removeKernelRobotListener(ListenerId: number): unknown;
|
removeKernelRobotListener(ListenerId: number): unknown;
|
||||||
|
|
||||||
getAllRobotFriendsFromCache(): unknown;
|
getAllRobotFriendsFromCache(): Promise<unknown>;
|
||||||
|
|
||||||
fetchAllRobots(arg1: unknown, arg2: unknown): unknown;
|
fetchAllRobots(arg1: unknown, arg2: unknown): unknown;
|
||||||
|
|
||||||
|
@@ -5,6 +5,7 @@ import BaseAction from '../BaseAction';
|
|||||||
import { ActionName } from '../types';
|
import { ActionName } from '../types';
|
||||||
import { NTQQFriendApi } from '@/core';
|
import { NTQQFriendApi } from '@/core';
|
||||||
import { FromSchema, JSONSchema } from 'json-schema-to-ts';
|
import { FromSchema, JSONSchema } from 'json-schema-to-ts';
|
||||||
|
import { requireMinNTQQBuild } from '@/common/utils/QQBasicInfo';
|
||||||
|
|
||||||
|
|
||||||
// no_cache get时传字符串
|
// no_cache get时传字符串
|
||||||
@@ -20,7 +21,10 @@ export default class GetFriendList extends BaseAction<Payload, OB11User[]> {
|
|||||||
actionName = ActionName.GetFriendList;
|
actionName = ActionName.GetFriendList;
|
||||||
PayloadSchema = SchemaData;
|
PayloadSchema = SchemaData;
|
||||||
protected async _handle(payload: Payload) {
|
protected async _handle(payload: Payload) {
|
||||||
//let data = await NTQQFriendApi.getBuddyV2(payload?.no_cache === true || payload?.no_cache=== 'true');
|
if (requireMinNTQQBuild('26702')) {
|
||||||
|
//全新逻辑
|
||||||
|
return OB11Constructor.friendsV2(await NTQQFriendApi.getBuddyV2(payload?.no_cache === true || payload?.no_cache === 'true'));
|
||||||
|
}
|
||||||
if (friends.size === 0 || payload?.no_cache === true || payload?.no_cache === 'true') {
|
if (friends.size === 0 || payload?.no_cache === true || payload?.no_cache === 'true') {
|
||||||
const _friends = await NTQQFriendApi.getFriends(true);
|
const _friends = await NTQQFriendApi.getFriends(true);
|
||||||
// log('强制刷新好友列表,结果: ', _friends)
|
// log('强制刷新好友列表,结果: ', _friends)
|
||||||
|
@@ -22,6 +22,7 @@ import {
|
|||||||
RawMessage,
|
RawMessage,
|
||||||
SelfInfo,
|
SelfInfo,
|
||||||
Sex,
|
Sex,
|
||||||
|
SimpleInfo,
|
||||||
TipGroupElementType,
|
TipGroupElementType,
|
||||||
User,
|
User,
|
||||||
VideoElement
|
VideoElement
|
||||||
@@ -552,7 +553,14 @@ export class OB11Constructor {
|
|||||||
nickname: selfInfo.nick,
|
nickname: selfInfo.nick,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
static friendsV2(friends: SimpleInfo[]): OB11User[] {
|
||||||
|
const data: OB11User[] = [];
|
||||||
|
friends.forEach(friend => {
|
||||||
|
const sexValue = this.sex(friend.baseInfo.sex!);
|
||||||
|
data.push({ ...friend.baseInfo, ...friend.coreInfo, user_id: parseInt(friend.coreInfo.uin), nickname: friend.coreInfo.nick, remark: friend.coreInfo.nick, sex: sexValue, level: 0 });
|
||||||
|
});
|
||||||
|
return data;
|
||||||
|
}
|
||||||
static friends(friends: Friend[]): OB11User[] {
|
static friends(friends: Friend[]): OB11User[] {
|
||||||
const data: OB11User[] = [];
|
const data: OB11User[] = [];
|
||||||
friends.forEach(friend => {
|
friends.forEach(friend => {
|
||||||
|
Reference in New Issue
Block a user