Skip to content

Commit

Permalink
fix(event): fix guild-request
Browse files Browse the repository at this point in the history
  • Loading branch information
ilharp committed Aug 23, 2024
1 parent 42e5f8c commit c3d3974
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 7 deletions.
7 changes: 7 additions & 0 deletions packages/engine-chronocat-api/src/services/groupNotify.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
import { getSingleScreenNotifies } from '../definitions/groupService'

let t = new Date().getTime()

const refresh = async () => {
const nt = new Date().getTime()

if (nt - t < 10000) return
t = nt

void getSingleScreenNotifies({
doubt: false,
startSeq: '',
Expand Down
13 changes: 8 additions & 5 deletions packages/engine-chronocat-event/src/handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -217,20 +217,23 @@ const dispatcher = async (
case 'nodeIKernelGroupListener/onGroupSingleScreenNotifies': {
const { notifies } = payload as OnGroupSingleScreenNotifies

for (const notify of notifies) {
const uin = await ctx.chronocat.uix.getUin2(notify.user1.uid) // 此时用户刚刚申请入群,不在群里,不能带 group 场景
// eslint-disable-next-line @typescript-eslint/no-misused-promises
notifies.forEach(async (x) => {
if (x.type !== 7 || x.status !== 1) return

const uin = await ctx.chronocat.uix.getUin2(x.user1.uid) // 此时用户刚刚申请入群,不在群里,不能带 group 场景
if (!uin) {
ctx.chronocat.l.error('内部错误', { code: 2152 })
return
}

const key = `${notify.group.groupCode}:${uin}:${notify.seq}`
const key = `${x.group.groupCode}:${uin}:${x.seq}`
if (emittedGroupReqList.includes(key)) return

emittedGroupReqList.push(key)

ctx.chronocat.emit(new GuildRequestDispatchMessage(notify, uin))
}
ctx.chronocat.emit(new GuildRequestDispatchMessage(x, uin))
})

return
}
Expand Down
4 changes: 2 additions & 2 deletions packages/red/src/redIpcEntity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -219,9 +219,9 @@ export interface OnGroupSingleScreenNotifies {
export interface GroupNotify {
seq: string // '1716209619000000'

type: number // 7
type: number // 7 申请入群,11 已退群

status: number // 1
status: number // 0 无需操作,1 未操作,2 已操作

group: {
groupCode: string
Expand Down

0 comments on commit c3d3974

Please sign in to comment.