Skip to content

Commit db13d1a

Browse files
committed
Fix notifying playing gamers
1 parent ce77afe commit db13d1a

File tree

1 file changed

+17
-5
lines changed

1 file changed

+17
-5
lines changed

src/rest/notification/notification.service.ts

+17-5
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import {
2222
import { Cron, CronExpression } from "@nestjs/schedule";
2323
import { NotificationCreatedEvent } from "./event/notification-created.event";
2424
import { NotificationMapper } from "./notification.mapper";
25+
import { InfoApi } from "../../generated-api/gameserver";
2526

2627
@Injectable()
2728
export class NotificationService {
@@ -36,6 +37,8 @@ export class NotificationService {
3637
private readonly notificationEntityRepository: Repository<NotificationEntity>,
3738
private readonly ebus: EventBus,
3839
private readonly mapper: NotificationMapper,
40+
41+
private readonly ms: InfoApi,
3942
) {
4043
webpush.setVapidDetails(
4144
@@ -134,16 +137,25 @@ export class NotificationService {
134137
const qs: GetQueueStateQueryResult = await this.qbus.execute(
135138
new GetQueueStateQuery(Dota2Version.Dota_684),
136139
);
137-
const inQueue = qs.entries
138-
.filter((t) => t.modes.includes(mode))
139-
.reduce((a, b) => a + b.players.length, 0);
140140

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
142148
.filter((t) => t.modes.includes(mode))
143149
.flatMap((t) => t.players);
144150

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+
145157
return await this.delivery.broadcastPredicate(
146-
(steamId) => !alreadyInQueue.includes(steamId),
158+
(steamId) => !ignorePing.has(steamId),
147159
MessageTypeS2C.GO_QUEUE,
148160
new PleaseEnterQueueMessageS2C(mode, Dota2Version.Dota_684, inQueue),
149161
);

0 commit comments

Comments
 (0)