mirror of
https://github.com/NapNeko/NapCatQQ.git
synced 2025-07-19 12:03:37 +00:00
refactor: Uid <-> Uin & Remove Cached
This commit is contained in:
2
src/core
2
src/core
Submodule src/core updated: 84dbc667ac...4f1266bd7e
@@ -1,7 +1,6 @@
|
||||
import { GroupNotify, GroupNotifyStatus } from '@/core/entities';
|
||||
import BaseAction from '../BaseAction';
|
||||
import { ActionName } from '../types';
|
||||
import { uid2UinMap } from '@/core/data';
|
||||
import { NTQQUserApi } from '@/core/apis/user';
|
||||
import { NTQQGroupApi } from '@/core/apis/group';
|
||||
|
||||
@@ -20,7 +19,7 @@ export default class GetGroupAddRequest extends BaseAction<null, OB11GroupReques
|
||||
// const notifies: GroupNotify[] = data.notifies.filter(notify => notify.status === GroupNotifyStatus.WAIT_HANDLE);
|
||||
// const returnData: OB11GroupRequestNotify[] = [];
|
||||
// for (const notify of notifies) {
|
||||
// const uin = uid2UinMap[notify.user1.uid] || (await NTQQUserApi.getUserDetailInfo(notify.user1.uid))?.uin;
|
||||
// const uin = || (await NTQQUserApi.getUserDetailInfo(notify.user1.uid))?.uin;
|
||||
// returnData.push({
|
||||
// group_id: parseInt(notify.group.groupCode),
|
||||
// user_id: parseInt(uin),
|
||||
|
@@ -1,6 +1,6 @@
|
||||
import BaseAction from '../BaseAction';
|
||||
import { OB11Message, OB11User } from '../../types';
|
||||
import { getFriend, friends, uid2UinMap, getUidByUin } from '@/core/data';
|
||||
import { getFriend, friends } from '@/core/data';
|
||||
import { ActionName } from '../types';
|
||||
import { ChatType } from '@/core/entities';
|
||||
import { dbUtil } from '@/common/utils/db';
|
||||
@@ -8,6 +8,7 @@ import { NTQQMsgApi } from '@/core/apis/msg';
|
||||
import { OB11Constructor } from '../../constructor';
|
||||
import { logDebug } from '@/common/utils/log';
|
||||
import { FromSchema, JSONSchema } from 'json-schema-to-ts';
|
||||
import { NTQQUserApi } from '@/core';
|
||||
|
||||
interface Response {
|
||||
messages: OB11Message[];
|
||||
@@ -16,7 +17,7 @@ interface Response {
|
||||
const SchemaData = {
|
||||
type: 'object',
|
||||
properties: {
|
||||
user_id: { type: [ 'number' , 'string' ] },
|
||||
user_id: { type: ['number', 'string'] },
|
||||
message_seq: { type: 'number' },
|
||||
count: { type: 'number' }
|
||||
},
|
||||
@@ -29,7 +30,7 @@ export default class GetFriendMsgHistory extends BaseAction<Payload, Response> {
|
||||
actionName = ActionName.GetFriendMsgHistory;
|
||||
PayloadSchema = SchemaData;
|
||||
protected async _handle(payload: Payload): Promise<Response> {
|
||||
const uid = getUidByUin(payload.user_id.toString());
|
||||
const uid = await NTQQUserApi.getUidByUin(payload.user_id.toString());
|
||||
if (!uid) {
|
||||
throw `记录${payload.user_id}不存在`;
|
||||
}
|
||||
|
@@ -1,9 +1,7 @@
|
||||
import { NTQQGroupApi } from '@/core';
|
||||
import { NTQQGroupApi, NTQQUserApi } from '@/core';
|
||||
import BaseAction from '../BaseAction';
|
||||
import { ActionName } from '../types';
|
||||
import { NTQQMsgApi } from '@/core/apis/msg';
|
||||
import { FromSchema, JSONSchema } from 'json-schema-to-ts';
|
||||
import { uid2UinMap } from '@/core/data';
|
||||
|
||||
const SchemaData = {
|
||||
type: 'object',
|
||||
@@ -24,22 +22,22 @@ export class GetGroupSystemMsg extends BaseAction<void, any> {
|
||||
if (SSNotify.type == 1) {
|
||||
retData.InvitedRequest.push({
|
||||
request_id: SSNotify.seq,
|
||||
invitor_uin: uid2UinMap[SSNotify.user1?.uid],
|
||||
invitor_uin: await NTQQUserApi.getUinByUid(SSNotify.user1?.uid),
|
||||
invitor_nick: SSNotify.user1?.nickName,
|
||||
group_id: SSNotify.group?.groupCode,
|
||||
group_name: SSNotify.group?.groupName,
|
||||
checked: SSNotify.status === 1 ? false : true,
|
||||
actor: uid2UinMap[SSNotify.user2?.uid] || 0,
|
||||
actor: await NTQQUserApi.getUinByUid(SSNotify.user2?.uid) || 0,
|
||||
});
|
||||
} else if (SSNotify.type == 7) {
|
||||
retData.join_requests.push({
|
||||
request_id: SSNotify.seq,
|
||||
requester_uin: uid2UinMap[SSNotify.user1?.uid],
|
||||
requester_uin: await NTQQUserApi.getUinByUid(SSNotify.user1?.uid),
|
||||
requester_nick: SSNotify.user1?.nickName,
|
||||
group_id: SSNotify.group?.groupCode,
|
||||
group_name: SSNotify.group?.groupName,
|
||||
checked: SSNotify.status === 1 ? false : true,
|
||||
actor: uid2UinMap[SSNotify.user2?.uid] || 0,
|
||||
actor: await NTQQUserApi.getUinByUid(SSNotify.user2?.uid) || 0,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@@ -17,7 +17,7 @@ import { OB11Config, ob11Config } from '@/onebot11/config';
|
||||
import { httpHeart, ob11HTTPServer } from '@/onebot11/server/http';
|
||||
import { ob11WebsocketServer } from '@/onebot11/server/ws/WebsocketServer';
|
||||
import { ob11ReverseWebsockets } from '@/onebot11/server/ws/ReverseWebsocket';
|
||||
import { friendRequests, getFriend, getGroup, getGroupMember, groupNotifies, selfInfo, tempGroupCodeMap, uid2UinMap } from '@/core/data';
|
||||
import { friendRequests, getFriend, getGroup, getGroupMember, groupNotifies, selfInfo, tempGroupCodeMap } from '@/core/data';
|
||||
import { dbUtil } from '@/common/utils/db';
|
||||
import { BuddyListener, GroupListener, NodeIKernelBuddyListener } from '@/core/listeners';
|
||||
import { OB11FriendRequestEvent } from '@/onebot11/event/request/OB11FriendRequest';
|
||||
@@ -161,7 +161,7 @@ export class NapCatOnebot11 {
|
||||
// const role = (await getGroupMember(peeruin, selfInfo.uin))?.role;
|
||||
// const isPrivilege = role === 3 || role === 4;
|
||||
// if (!isPrivilege) {
|
||||
// const leaveUin = uid2UinMap[sysMsg.other[0].event[0].peerString];
|
||||
// const leaveUin =
|
||||
// log('[群聊] 群组 ', peeruin, ' 成员' + leaveUin + '退出');
|
||||
// const groupDecreaseEvent = new OB11GroupDecreaseEvent(peeruin, parseInt(leaveUin), 0, 'leave');// 不知道怎么出去的
|
||||
// postOB11Event(groupDecreaseEvent, true);
|
||||
|
Reference in New Issue
Block a user