Merge branch 'main' into pr/734

This commit is contained in:
手瓜一十雪
2025-01-24 21:42:49 +08:00
3 changed files with 26 additions and 15 deletions

4
.gitignore vendored
View File

@@ -4,7 +4,7 @@ package-lock.json
out/
dist/
/src/core.lib/common/
/localdebug/
devconfig/*
# Editor
!.vscode/extensions.json
@@ -13,4 +13,4 @@ dist/
# Build
*.db
checkVersion.sh
bun.lockb
bun.lockb

View File

@@ -10,14 +10,21 @@ export interface NodeIKernelProfileLikeService {
getBuddyProfileLike(req: BuddyProfileLikeReq): Promise<GeneralCallResult & {
info: {
userLikeInfos: Array<{
uid: string,
time: string,
favoriteInfo: {
userInfos: Array<NTVoteInfo>,//哪些人点我
total_count: number,
last_time: number,
today_count: number
},
voteInfo: {
total_count: number,
new_count: number,
new_nearby_count: number,
last_visit_time: number,
userInfos: Array<NTVoteInfo>
userInfos: Array<NTVoteInfo>,//点过哪些人
}
}>,
friendMaxVotes: number,
start: number

View File

@@ -5,8 +5,7 @@ import { Type, Static } from '@sinclair/typebox';
const SchemaData = Type.Object({
user_id: Type.Optional(Type.Union([Type.Number(), Type.String()])),
start: Type.Union([Type.Number(), Type.String()], { default: 0 }),
count: Type.Union([Type.Number(), Type.String()], { default: 10 }),
type: Type.Union([Type.Number(), Type.String()], { default: 2 }),
count: Type.Union([Type.Number(), Type.String()], { default: 10 })
});
type Payload = Static<typeof SchemaData>;
@@ -15,15 +14,20 @@ export class GetProfileLike extends OneBotAction<Payload, any> {
actionName = ActionName.GetProfileLike;
payloadSchema = SchemaData;
async _handle(payload: Payload) {
const user_uid =
this.core.selfInfo.uin === payload.user_id || !payload.user_id ?
this.core.selfInfo.uid :
await this.core.apis.UserApi.getUidByUinV2(payload.user_id.toString());
const ret = await this.core.apis.UserApi.getProfileLike(user_uid ?? this.core.selfInfo.uid, +payload.start, +payload.count, +payload.type);
const listdata = ret.info.userLikeInfos[0].voteInfo.userInfos;
for (const item of listdata) {
const isSelf = this.core.selfInfo.uin === payload.user_id || !payload.user_id;
const userUid = isSelf || !payload.user_id ? this.core.selfInfo.uid : await this.core.apis.UserApi.getUidByUinV2(payload.user_id.toString());
const type = isSelf ? 2 : 1;
const ret = await this.core.apis.UserApi.getProfileLike(userUid ?? this.core.selfInfo.uid, +payload.start, +payload.count, type);
const data = ret.info.userLikeInfos[0];
if (!data) {
throw new Error('get info error');
}
for (const item of data.voteInfo.userInfos) {
item.uin = +((await this.core.apis.UserApi.getUinByUidV2(item.uid)) ?? '');
}
return ret.info.userLikeInfos[0].voteInfo;
for (const item of data.favoriteInfo.userInfos) {
item.uin = +((await this.core.apis.UserApi.getUinByUidV2(item.uid)) ?? '');
}
return data;
}
}
}