fix: get_stranger_info

This commit is contained in:
手瓜一十雪 2024-08-04 22:21:24 +08:00
parent dce8416942
commit 38894177ee
4 changed files with 70 additions and 26 deletions

View File

@ -1,4 +1,4 @@
import { ModifyProfileParams, SelfInfo, User, UserDetailInfoByUin } from '@/core/entities'; import { ModifyProfileParams, SelfInfo, User, UserDetailInfoByUin, UserDetailInfoByUinV2 } from '@/core/entities';
import { friends, groupMembers, selfInfo } from '@/core/data'; import { friends, groupMembers, selfInfo } from '@/core/data';
import { CacheClassFuncAsync, CacheClassFuncAsyncExtend } from '@/common/utils/helper'; import { CacheClassFuncAsync, CacheClassFuncAsyncExtend } from '@/common/utils/helper';
import { napCatCore, NTQQFriendApi } from '@/core'; import { napCatCore, NTQQFriendApi } from '@/core';
@ -211,7 +211,7 @@ export class NTQQUserApi {
}) })
static async getUidByUin(Uin: string) { static async getUidByUin(Uin: string) {
//此代码仅临时使用,后期会被废弃 //此代码仅临时使用,后期会被废弃
if (!requireMinNTQQBuild('26702')) { if (requireMinNTQQBuild('26702')) {
return await NTQQUserApi.getUidByUinV2(Uin); return await NTQQUserApi.getUidByUinV2(Uin);
} }
return await NTQQUserApi.getUidByUinV1(Uin); return await NTQQUserApi.getUidByUinV1(Uin);
@ -225,7 +225,7 @@ export class NTQQUserApi {
}) })
static async getUinByUid(Uid: string) { static async getUinByUid(Uid: string) {
//此代码仅临时使用,后期会被废弃 //此代码仅临时使用,后期会被废弃
if (!requireMinNTQQBuild('26702')) { if (requireMinNTQQBuild('26702')) {
return await NTQQUserApi.getUinByUidV2(Uid); return await NTQQUserApi.getUinByUidV2(Uid);
} }
return await NTQQUserApi.getUinByUidV1(Uid); return await NTQQUserApi.getUinByUidV1(Uid);
@ -243,10 +243,11 @@ export class NTQQUserApi {
if (uid) return uid; if (uid) return uid;
uid = (await NTQQFriendApi.getBuddyIdMap(true)).getValue(Uin); uid = (await NTQQFriendApi.getBuddyIdMap(true)).getValue(Uin);
if (uid) return uid; if (uid) return uid;
let unveifyUid = (await NTQQUserApi.getUserDetailInfoByUin(Uin)).info.uid;//从QQ Native 特殊转换 // let unveifyUid = (await NTQQUserApi.getUserDetailInfoByUin(Uin)).info.uid;//从QQ Native 特殊转换
if (unveifyUid.indexOf("*") == -1) uid = unveifyUid; // if (unveifyUid.indexOf("*") == -1) uid = unveifyUid;
if (uid) return uid; return uid; //if (uid) return uid;
return uid;
} }
//后期改成流水线处理 //后期改成流水线处理
static async getUinByUidV2(Uid: string) { static async getUinByUidV2(Uid: string) {
@ -333,6 +334,14 @@ export class NTQQUserApi {
static async getRecentContactList() { static async getRecentContactList() {
return await napCatCore.session.getRecentContactService().getRecentContactList(); return await napCatCore.session.getRecentContactService().getRecentContactList();
} }
static async getUserDetailInfoByUinV2(Uin: string) {
return await NTEventDispatch.CallNoListenerEvent
<(Uin: string) => Promise<UserDetailInfoByUinV2>>(
'NodeIKernelProfileService/getUserDetailInfoByUin',
5000,
Uin
);
}
static async getUserDetailInfoByUin(Uin: string) { static async getUserDetailInfoByUin(Uin: string) {
return NTEventDispatch.CallNoListenerEvent return NTEventDispatch.CallNoListenerEvent
<(Uin: string) => Promise<UserDetailInfoByUin>>( <(Uin: string) => Promise<UserDetailInfoByUin>>(

View File

@ -276,6 +276,17 @@ export enum BizKey {
KPRIVILEGEICON, KPRIVILEGEICON,
KPHOTOWALL KPHOTOWALL
} }
export interface UserDetailInfoByUinV2 {
result: number,
errMsg: string,
detail: {
uid: string,
uin: string,
simpleInfo: SimpleInfo,
commonExt: CommonExt,
photoWall: null
}
}
export interface UserDetailInfoByUin { export interface UserDetailInfoByUin {
result: number, result: number,
errMsg: string, errMsg: string,

View File

@ -5,6 +5,7 @@ import { ActionName } from '../types';
import { NTQQUserApi } from '@/core/apis/user'; import { NTQQUserApi } from '@/core/apis/user';
import { FromSchema, JSONSchema } from 'json-schema-to-ts'; import { FromSchema, JSONSchema } from 'json-schema-to-ts';
import { calcQQLevel } from '@/common/utils/qqlevel'; import { calcQQLevel } from '@/common/utils/qqlevel';
import { requireMinNTQQBuild } from '@/common/utils/QQBasicInfo';
const SchemaData = { const SchemaData = {
type: 'object', type: 'object',
@ -20,6 +21,7 @@ export default class GoCQHTTPGetStrangerInfo extends BaseAction<Payload, OB11Use
actionName = ActionName.GoCQHTTP_GetStrangerInfo; actionName = ActionName.GoCQHTTP_GetStrangerInfo;
protected async _handle(payload: Payload): Promise<OB11User> { protected async _handle(payload: Payload): Promise<OB11User> {
if (!requireMinNTQQBuild('26702')) {
const user_id = payload.user_id.toString(); const user_id = payload.user_id.toString();
const extendData = await NTQQUserApi.getUserDetailInfoByUin(user_id); const extendData = await NTQQUserApi.getUserDetailInfoByUin(user_id);
const uid = (await NTQQUserApi.getUidByUin(user_id))!; const uid = (await NTQQUserApi.getUidByUin(user_id))!;
@ -39,5 +41,26 @@ export default class GoCQHTTPGetStrangerInfo extends BaseAction<Payload, OB11Use
} }
const data = { ...extendData, ...(await NTQQUserApi.getUserDetailInfo(uid)) }; const data = { ...extendData, ...(await NTQQUserApi.getUserDetailInfo(uid)) };
return OB11Constructor.stranger(data); return OB11Constructor.stranger(data);
} else {
const user_id = payload.user_id.toString();
const extendData = await NTQQUserApi.getUserDetailInfoByUinV2(user_id);
//console.log(extendData);
const uid = (await NTQQUserApi.getUidByUin(user_id))!;
if (!uid || uid.indexOf('*') != -1) {
const ret = {
...extendData,
user_id: parseInt(extendData.detail.uin) || 0,
nickname: extendData.detail.simpleInfo.coreInfo.nick,
sex: OB11UserSex.unknown,
age: 0,
level: extendData.detail.commonExt.qqLevel && calcQQLevel(extendData.detail.commonExt.qqLevel) || 0,
login_days: 0,
uid: ''
};
return ret;
}
const data = { ...extendData, ...(await NTQQUserApi.getUserDetailInfo(uid)) };
return OB11Constructor.stranger(data);
}
} }
} }

View File

@ -92,8 +92,9 @@ export class OB11Constructor {
} }
else if (msg.chatType == ChatType.friend) { else if (msg.chatType == ChatType.friend) {
resMsg.sub_type = 'friend'; resMsg.sub_type = 'friend';
const user = await NTQQUserApi.getUserDetailInfoByUin(msg.senderUin!); resMsg.sender.nickname = (await NTQQUserApi.getUserDetailInfo(msg.senderUid)).nick;
resMsg.sender.nickname = user.info.nick; //const user = await NTQQUserApi.getUserDetailInfoByUin(msg.senderUin!);
//resMsg.sender.nickname = user.info.nick;
} }
else if (msg.chatType == ChatType.temp) { else if (msg.chatType == ChatType.temp) {
resMsg.sub_type = 'group'; resMsg.sub_type = 'group';