fix(onebot): restore group and doubt request accounts
get_group_system_msg now keeps join and invite records, reports the inviter, and fills a missing requester nick from the user profile. get_doubt_friends_add_request returns the QQ number plus the request message, source, and time that QQ actually sends. Closes #400 Closes #401 Closes #402 Closes #403
This commit is contained in:
13 files changed
+418
-79
No files matched your search
@@ -354,6 +354,18 @@ export class ContactsApi {
|
||||
const targetUin = raw.target?.uin ?? 0;
|
||||
const invitorUin = raw.invitor?.uin ?? 0;
|
||||
const operatorUin = raw.operatorUser?.uin ?? 0;
|
||||
const targetUid = raw.target?.uid
|
||||
|| this.ctx.identity.findUidByUin(targetUin, groupId)
|
||||
|| this.ctx.identity.findUidByUin(targetUin)
|
||||
|| '';
|
||||
const invitorUid = raw.invitor?.uid
|
||||
|| this.ctx.identity.findUidByUin(invitorUin, groupId)
|
||||
|| this.ctx.identity.findUidByUin(invitorUin)
|
||||
|| '';
|
||||
const operatorUid = raw.operatorUser?.uid
|
||||
|| this.ctx.identity.findUidByUin(operatorUin, groupId)
|
||||
|| this.ctx.identity.findUidByUin(operatorUin)
|
||||
|| '';
|
||||
const notifyType = raw.eventType ?? 0;
|
||||
const operationType = groupRequestOperationType(notifyType);
|
||||
const sequence = normalizeGroupRequestSequence(raw.sequence, groupId);
|
||||
@@ -368,20 +380,23 @@ export class ContactsApi {
|
||||
requests.push({
|
||||
groupId,
|
||||
groupName: raw.group?.groupName ?? '',
|
||||
targetUid: this.ctx.identity.findUidByUin(targetUin, groupId)
|
||||
?? this.ctx.identity.findUidByUin(targetUin)
|
||||
?? '',
|
||||
targetUin,
|
||||
targetUid,
|
||||
targetUin: targetUin
|
||||
|| this.ctx.identity.findUinByUid(targetUid, groupId)
|
||||
|| this.ctx.identity.findUinByUid(targetUid)
|
||||
|| 0,
|
||||
targetName: raw.target?.name ?? '',
|
||||
invitorUid: this.ctx.identity.findUidByUin(invitorUin, groupId)
|
||||
?? this.ctx.identity.findUidByUin(invitorUin)
|
||||
?? '',
|
||||
invitorUin,
|
||||
invitorUid,
|
||||
invitorUin: invitorUin
|
||||
|| this.ctx.identity.findUinByUid(invitorUid, groupId)
|
||||
|| this.ctx.identity.findUinByUid(invitorUid)
|
||||
|| 0,
|
||||
invitorName: raw.invitor?.name ?? '',
|
||||
operatorUid: this.ctx.identity.findUidByUin(operatorUin, groupId)
|
||||
?? this.ctx.identity.findUidByUin(operatorUin)
|
||||
?? '',
|
||||
operatorUin,
|
||||
operatorUid,
|
||||
operatorUin: operatorUin
|
||||
|| this.ctx.identity.findUinByUid(operatorUid, groupId)
|
||||
|| this.ctx.identity.findUinByUid(operatorUid)
|
||||
|| 0,
|
||||
operatorName: raw.operatorUser?.name ?? '',
|
||||
sequence,
|
||||
state: raw.state ?? 0,
|
||||
|
||||
@@ -48,8 +48,19 @@ export class FriendApi {
|
||||
}
|
||||
|
||||
/** List doubtful friend-add requests (可能认识的人). */
|
||||
getDoubtRequests(count: number): Promise<DoubtBuddyRequest[]> {
|
||||
return GetDoubtBuddyReq.invoke(this.ctx, { count });
|
||||
async getDoubtRequests(count: number): Promise<DoubtBuddyRequest[]> {
|
||||
const list = await GetDoubtBuddyReq.invoke(this.ctx, { count });
|
||||
return list.map((item) => {
|
||||
let uid = item.uid;
|
||||
let userId = item.user_id;
|
||||
if (userId <= 0 && uid) {
|
||||
userId = this.ctx.identity.findUinByUid(uid) ?? 0;
|
||||
}
|
||||
if (!uid && userId > 0) {
|
||||
uid = this.ctx.identity.findUidByUin(userId) ?? '';
|
||||
}
|
||||
return { ...item, uid, user_id: userId };
|
||||
});
|
||||
}
|
||||
|
||||
/** Approve a doubtful friend-add request by its uid (the list item's flag). */
|
||||
|
||||
Reference in new issue
Block a user