mirror of
https://github.com/NapNeko/NapCatQQ.git
synced 2024-11-21 09:36:35 +00:00
53 lines
1.7 KiB
TypeScript
53 lines
1.7 KiB
TypeScript
|
|
import { FromSchema, JSONSchema } from 'json-schema-to-ts';
|
|
import BaseAction from '../BaseAction';
|
|
import { ActionName } from '../types';
|
|
import { NTQQMsgApi, NTQQUserApi } from '@/core';
|
|
import { OB11Constructor } from '@/onebot11/constructor';
|
|
|
|
const SchemaData = {
|
|
type: 'object',
|
|
properties: {
|
|
count: { type: ['number', 'string'] }
|
|
}
|
|
} as const satisfies JSONSchema;
|
|
|
|
type Payload = FromSchema<typeof SchemaData>;
|
|
|
|
export default class GetRecentContact extends BaseAction<Payload, any> {
|
|
actionName = ActionName.GetRecentContact;
|
|
PayloadSchema = SchemaData;
|
|
protected async _handle(payload: Payload) {
|
|
let ret = await NTQQUserApi.getRecentContactListSnapShot(parseInt((payload.count || 10).toString()));
|
|
let data = await Promise.all(ret.info.changedList.map(async (t) => {
|
|
let FastMsg = await NTQQMsgApi.getMsgsByMsgId({ chatType: t.chatType, peerUid: t.peerUid }, [t.msgId]);
|
|
if (FastMsg.msgList.length > 0) {
|
|
//扩展ret.info.changedList
|
|
let lastestMsg = await OB11Constructor.message(FastMsg.msgList[0]);
|
|
return {
|
|
lastestMsg: lastestMsg,
|
|
peerUin: t.peerUin,
|
|
remark: t.remark,
|
|
msgTime: t.msgTime,
|
|
chatType: t.chatType,
|
|
msgId: t.msgId,
|
|
sendNickName: t.sendNickName,
|
|
sendMemberName: t.sendMemberName,
|
|
peerName: t.peerName
|
|
};
|
|
}
|
|
return {
|
|
peerUin: t.peerUin,
|
|
remark: t.remark,
|
|
msgTime: t.msgTime,
|
|
chatType: t.chatType,
|
|
msgId: t.msgId,
|
|
sendNickName: t.sendNickName,
|
|
sendMemberName: t.sendMemberName,
|
|
peerName: t.peerName
|
|
};
|
|
}));
|
|
return data;
|
|
}
|
|
}
|