@@ -22,6 +22,7 @@ import {
22
22
import { Cron , CronExpression } from "@nestjs/schedule" ;
23
23
import { NotificationCreatedEvent } from "./event/notification-created.event" ;
24
24
import { NotificationMapper } from "./notification.mapper" ;
25
+ import { InfoApi } from "../../generated-api/gameserver" ;
25
26
26
27
@Injectable ( )
27
28
export class NotificationService {
@@ -36,6 +37,8 @@ export class NotificationService {
36
37
private readonly notificationEntityRepository : Repository < NotificationEntity > ,
37
38
private readonly ebus : EventBus ,
38
39
private readonly mapper : NotificationMapper ,
40
+
41
+ private readonly ms : InfoApi ,
39
42
) {
40
43
webpush . setVapidDetails (
41
44
@@ -134,16 +137,25 @@ export class NotificationService {
134
137
const qs : GetQueueStateQueryResult = await this . qbus . execute (
135
138
new GetQueueStateQuery ( Dota2Version . Dota_684 ) ,
136
139
) ;
137
- const inQueue = qs . entries
138
- . filter ( ( t ) => t . modes . includes ( mode ) )
139
- . reduce ( ( a , b ) => a + b . players . length , 0 ) ;
140
140
141
- const alreadyInQueue = qs . entries
141
+ const inGame : string [ ] = await this . ms
142
+ . infoControllerGameSessions ( )
143
+ . then ( ( it ) =>
144
+ it . flatMap ( ( ses ) => [ ...ses . info . radiant , ...ses . info . dire ] ) ,
145
+ ) ;
146
+
147
+ const alreadyInQueue : string [ ] = qs . entries
142
148
. filter ( ( t ) => t . modes . includes ( mode ) )
143
149
. flatMap ( ( t ) => t . players ) ;
144
150
151
+ const ignorePing = new Set ( [ ...inGame , ...alreadyInQueue ] ) ;
152
+
153
+ const inQueue = qs . entries
154
+ . filter ( ( t ) => t . modes . includes ( mode ) )
155
+ . reduce ( ( a , b ) => a + b . players . length , 0 ) ;
156
+
145
157
return await this . delivery . broadcastPredicate (
146
- ( steamId ) => ! alreadyInQueue . includes ( steamId ) ,
158
+ ( steamId ) => ! ignorePing . has ( steamId ) ,
147
159
MessageTypeS2C . GO_QUEUE ,
148
160
new PleaseEnterQueueMessageS2C ( mode , Dota2Version . Dota_684 , inQueue ) ,
149
161
) ;
0 commit comments