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 { GroupNotify, GroupNotifyStatus } from '@/core/entities';
|
||||||
import BaseAction from '../BaseAction';
|
import BaseAction from '../BaseAction';
|
||||||
import { ActionName } from '../types';
|
import { ActionName } from '../types';
|
||||||
import { uid2UinMap } from '@/core/data';
|
|
||||||
import { NTQQUserApi } from '@/core/apis/user';
|
import { NTQQUserApi } from '@/core/apis/user';
|
||||||
import { NTQQGroupApi } from '@/core/apis/group';
|
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 notifies: GroupNotify[] = data.notifies.filter(notify => notify.status === GroupNotifyStatus.WAIT_HANDLE);
|
||||||
// const returnData: OB11GroupRequestNotify[] = [];
|
// const returnData: OB11GroupRequestNotify[] = [];
|
||||||
// for (const notify of notifies) {
|
// 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({
|
// returnData.push({
|
||||||
// group_id: parseInt(notify.group.groupCode),
|
// group_id: parseInt(notify.group.groupCode),
|
||||||
// user_id: parseInt(uin),
|
// user_id: parseInt(uin),
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
import BaseAction from '../BaseAction';
|
import BaseAction from '../BaseAction';
|
||||||
import { OB11Message, OB11User } from '../../types';
|
import { OB11Message, OB11User } from '../../types';
|
||||||
import { getFriend, friends, uid2UinMap, getUidByUin } from '@/core/data';
|
import { getFriend, friends } from '@/core/data';
|
||||||
import { ActionName } from '../types';
|
import { ActionName } from '../types';
|
||||||
import { ChatType } from '@/core/entities';
|
import { ChatType } from '@/core/entities';
|
||||||
import { dbUtil } from '@/common/utils/db';
|
import { dbUtil } from '@/common/utils/db';
|
||||||
@@ -8,6 +8,7 @@ import { NTQQMsgApi } from '@/core/apis/msg';
|
|||||||
import { OB11Constructor } from '../../constructor';
|
import { OB11Constructor } from '../../constructor';
|
||||||
import { logDebug } from '@/common/utils/log';
|
import { logDebug } from '@/common/utils/log';
|
||||||
import { FromSchema, JSONSchema } from 'json-schema-to-ts';
|
import { FromSchema, JSONSchema } from 'json-schema-to-ts';
|
||||||
|
import { NTQQUserApi } from '@/core';
|
||||||
|
|
||||||
interface Response {
|
interface Response {
|
||||||
messages: OB11Message[];
|
messages: OB11Message[];
|
||||||
@@ -16,7 +17,7 @@ interface Response {
|
|||||||
const SchemaData = {
|
const SchemaData = {
|
||||||
type: 'object',
|
type: 'object',
|
||||||
properties: {
|
properties: {
|
||||||
user_id: { type: [ 'number' , 'string' ] },
|
user_id: { type: ['number', 'string'] },
|
||||||
message_seq: { type: 'number' },
|
message_seq: { type: 'number' },
|
||||||
count: { type: 'number' }
|
count: { type: 'number' }
|
||||||
},
|
},
|
||||||
@@ -29,7 +30,7 @@ export default class GetFriendMsgHistory extends BaseAction<Payload, Response> {
|
|||||||
actionName = ActionName.GetFriendMsgHistory;
|
actionName = ActionName.GetFriendMsgHistory;
|
||||||
PayloadSchema = SchemaData;
|
PayloadSchema = SchemaData;
|
||||||
protected async _handle(payload: Payload): Promise<Response> {
|
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) {
|
if (!uid) {
|
||||||
throw `记录${payload.user_id}不存在`;
|
throw `记录${payload.user_id}不存在`;
|
||||||
}
|
}
|
||||||
|
@@ -1,9 +1,7 @@
|
|||||||
import { NTQQGroupApi } from '@/core';
|
import { NTQQGroupApi, NTQQUserApi } from '@/core';
|
||||||
import BaseAction from '../BaseAction';
|
import BaseAction from '../BaseAction';
|
||||||
import { ActionName } from '../types';
|
import { ActionName } from '../types';
|
||||||
import { NTQQMsgApi } from '@/core/apis/msg';
|
|
||||||
import { FromSchema, JSONSchema } from 'json-schema-to-ts';
|
import { FromSchema, JSONSchema } from 'json-schema-to-ts';
|
||||||
import { uid2UinMap } from '@/core/data';
|
|
||||||
|
|
||||||
const SchemaData = {
|
const SchemaData = {
|
||||||
type: 'object',
|
type: 'object',
|
||||||
@@ -24,22 +22,22 @@ export class GetGroupSystemMsg extends BaseAction<void, any> {
|
|||||||
if (SSNotify.type == 1) {
|
if (SSNotify.type == 1) {
|
||||||
retData.InvitedRequest.push({
|
retData.InvitedRequest.push({
|
||||||
request_id: SSNotify.seq,
|
request_id: SSNotify.seq,
|
||||||
invitor_uin: uid2UinMap[SSNotify.user1?.uid],
|
invitor_uin: await NTQQUserApi.getUinByUid(SSNotify.user1?.uid),
|
||||||
invitor_nick: SSNotify.user1?.nickName,
|
invitor_nick: SSNotify.user1?.nickName,
|
||||||
group_id: SSNotify.group?.groupCode,
|
group_id: SSNotify.group?.groupCode,
|
||||||
group_name: SSNotify.group?.groupName,
|
group_name: SSNotify.group?.groupName,
|
||||||
checked: SSNotify.status === 1 ? false : true,
|
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) {
|
} else if (SSNotify.type == 7) {
|
||||||
retData.join_requests.push({
|
retData.join_requests.push({
|
||||||
request_id: SSNotify.seq,
|
request_id: SSNotify.seq,
|
||||||
requester_uin: uid2UinMap[SSNotify.user1?.uid],
|
requester_uin: await NTQQUserApi.getUinByUid(SSNotify.user1?.uid),
|
||||||
requester_nick: SSNotify.user1?.nickName,
|
requester_nick: SSNotify.user1?.nickName,
|
||||||
group_id: SSNotify.group?.groupCode,
|
group_id: SSNotify.group?.groupCode,
|
||||||
group_name: SSNotify.group?.groupName,
|
group_name: SSNotify.group?.groupName,
|
||||||
checked: SSNotify.status === 1 ? false : true,
|
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 { httpHeart, ob11HTTPServer } from '@/onebot11/server/http';
|
||||||
import { ob11WebsocketServer } from '@/onebot11/server/ws/WebsocketServer';
|
import { ob11WebsocketServer } from '@/onebot11/server/ws/WebsocketServer';
|
||||||
import { ob11ReverseWebsockets } from '@/onebot11/server/ws/ReverseWebsocket';
|
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 { dbUtil } from '@/common/utils/db';
|
||||||
import { BuddyListener, GroupListener, NodeIKernelBuddyListener } from '@/core/listeners';
|
import { BuddyListener, GroupListener, NodeIKernelBuddyListener } from '@/core/listeners';
|
||||||
import { OB11FriendRequestEvent } from '@/onebot11/event/request/OB11FriendRequest';
|
import { OB11FriendRequestEvent } from '@/onebot11/event/request/OB11FriendRequest';
|
||||||
@@ -161,7 +161,7 @@ export class NapCatOnebot11 {
|
|||||||
// const role = (await getGroupMember(peeruin, selfInfo.uin))?.role;
|
// const role = (await getGroupMember(peeruin, selfInfo.uin))?.role;
|
||||||
// const isPrivilege = role === 3 || role === 4;
|
// const isPrivilege = role === 3 || role === 4;
|
||||||
// if (!isPrivilege) {
|
// if (!isPrivilege) {
|
||||||
// const leaveUin = uid2UinMap[sysMsg.other[0].event[0].peerString];
|
// const leaveUin =
|
||||||
// log('[群聊] 群组 ', peeruin, ' 成员' + leaveUin + '退出');
|
// log('[群聊] 群组 ', peeruin, ' 成员' + leaveUin + '退出');
|
||||||
// const groupDecreaseEvent = new OB11GroupDecreaseEvent(peeruin, parseInt(leaveUin), 0, 'leave');// 不知道怎么出去的
|
// const groupDecreaseEvent = new OB11GroupDecreaseEvent(peeruin, parseInt(leaveUin), 0, 'leave');// 不知道怎么出去的
|
||||||
// postOB11Event(groupDecreaseEvent, true);
|
// postOB11Event(groupDecreaseEvent, true);
|
||||||
|
Reference in New Issue
Block a user