build-1.2.1-beta1,fix: webapi群成员列表加入缓存,表情回应兼容int类型emoji_id

This commit is contained in:
linyuchen 2024-05-05 13:26:33 +08:00
parent 720fd94b7f
commit a41cd42e8d
2 changed files with 23 additions and 18 deletions

View File

@ -1,5 +1,5 @@
import { OB11GroupMember } from '../../types';
import { getGroup, getGroupMember } from '@/core/data';
import { getGroup, getGroupMember, groupMembers } from '@/core/data';
import { OB11Constructor } from '../../constructor';
import BaseAction from '../BaseAction';
import { ActionName } from '../types';
@ -7,11 +7,13 @@ import { NTQQUserApi } from '@/core/apis/user';
import { log, logDebug } from '@/common/utils/log';
import { isNull } from '../../../common/utils/helper';
import { WebApi } from '@/core/apis/webapi';
import { NTQQGroupApi } from '@/core';
export interface PayloadType {
group_id: number;
user_id: number;
no_cache?: boolean | string;
}
class GetGroupMemberInfo extends BaseAction<PayloadType, OB11GroupMember> {
@ -22,7 +24,10 @@ class GetGroupMemberInfo extends BaseAction<PayloadType, OB11GroupMember> {
if (!group) {
throw (`群(${payload.group_id})不存在`);
}
const WebGroupMember = await WebApi.getGroupMembers(payload.group_id.toString());
const webGroupMembers = await WebApi.getGroupMembers(payload.group_id.toString());
if (payload.no_cache == true || payload.no_cache === 'true') {
groupMembers.set(group.groupCode, await NTQQGroupApi.getGroupMembers(payload.group_id.toString()));
}
const member = await getGroupMember(payload.group_id.toString(), payload.user_id.toString());
// log(member);
if (member) {
@ -35,12 +40,12 @@ class GetGroupMemberInfo extends BaseAction<PayloadType, OB11GroupMember> {
logDebug('获取群成员详细信息失败, 只能返回基础信息', e);
}
const retMember = OB11Constructor.groupMember(payload.group_id.toString(), member);
for (let i = 0, len = WebGroupMember.length; i < len; i++) {
if (WebGroupMember[i]?.uin && WebGroupMember[i].uin === retMember.user_id) {
retMember.join_time = WebGroupMember[i]?.join_time;
retMember.last_sent_time = WebGroupMember[i]?.last_speak_time;
retMember.qage = WebGroupMember[i]?.qage;
retMember.level = WebGroupMember[i]?.lv.level;
for (let i = 0, len = webGroupMembers.length; i < len; i++) {
if (webGroupMembers[i]?.uin && webGroupMembers[i].uin === retMember.user_id) {
retMember.join_time = webGroupMembers[i]?.join_time;
retMember.last_sent_time = webGroupMembers[i]?.last_speak_time;
retMember.qage = webGroupMembers[i]?.qage;
retMember.level = webGroupMembers[i]?.lv.level;
}
}

View File

@ -18,12 +18,12 @@ class GetGroupMemberList extends BaseAction<PayloadType, OB11GroupMember[]> {
protected async _handle(payload: PayloadType) {
const MemberMap: Map<number, OB11GroupMember> = new Map<number, OB11GroupMember>();
const WebGroupMember = await WebApi.getGroupMembers(payload.group_id.toString());
const webGroupMembers = await WebApi.getGroupMembers(payload.group_id.toString());
const group = await getGroup(payload.group_id.toString());
if (!group) {
throw (`${payload.group_id}不存在`);
}
if (payload.no_cache || payload.no_cache === 'true') {
if (payload.no_cache == true || payload.no_cache === 'true') {
// webGroupMembers = await WebApi.getGroupMembers(payload.group_id.toString());
const _groupMembers = await NTQQGroupApi.getGroupMembers(payload.group_id.toString());
groupMembers.set(group.groupCode, _groupMembers);
@ -35,17 +35,17 @@ class GetGroupMemberList extends BaseAction<PayloadType, OB11GroupMember[]> {
MemberMap.set(_groupMembers[i].user_id, _groupMembers[i]);
}
// 合并数据
for (let i = 0, len = WebGroupMember.length; i < len; i++) {
if (!WebGroupMember[i]?.uin) {
for (let i = 0, len = webGroupMembers.length; i < len; i++) {
if (!webGroupMembers[i]?.uin) {
continue;
}
const MemberData = MemberMap.get(WebGroupMember[i]?.uin);
const MemberData = MemberMap.get(webGroupMembers[i]?.uin);
if (MemberData) {
MemberData.join_time = WebGroupMember[i]?.join_time;
MemberData.last_sent_time = WebGroupMember[i]?.last_speak_time;
MemberData.qage = WebGroupMember[i]?.qage;
MemberData.level = WebGroupMember[i]?.lv.level;
MemberMap.set(WebGroupMember[i]?.uin, MemberData);
MemberData.join_time = webGroupMembers[i]?.join_time;
MemberData.last_sent_time = webGroupMembers[i]?.last_speak_time;
MemberData.qage = webGroupMembers[i]?.qage;
MemberData.level = webGroupMembers[i]?.lv.level;
MemberMap.set(webGroupMembers[i]?.uin, MemberData);
}
}
// 还原Map到Array