Browse Source

* Cron fixed, pong invite game while playing fixed

master
vvandenb 2 years ago
parent
commit
2f001f8a42
  1. 16
      back/src/chat/chat.service.ts
  2. 8
      back/src/pong/pong.gateway.ts
  3. 2
      back/src/users/users.service.ts
  4. 2
      front/src/components/Chat.svelte

16
back/src/chat/chat.service.ts

@ -105,24 +105,16 @@ export class ChatService {
return rooms
}
@Cron('*/6 * * * * *')
async updateMutelists (): Promise<void> {
const channels = await this.ChannelRepository.find({})
channels.forEach((channel) => {
channel.muted = channel.muted.filter((data) => {
return Date.now() - data[1] < 0
})
void this.update(channel)
})
}
@Cron('*/6 * * * * *')
@Cron('*/10 * * * * *')
async updateBanlists (): Promise<void> {
const channels = await this.ChannelRepository.find({})
for (const channel of channels) {
channel.banned = channel.banned.filter((data) => {
return Date.now() - data[1] < 0
})
channel.muted = channel.muted.filter((data) => {
return Date.now() - data[1] < 0
})
void this.update(channel)
}
}

8
back/src/pong/pong.gateway.ts

@ -150,6 +150,9 @@ export class PongGateway implements OnGatewayConnection, OnGatewayDisconnect {
this.socketToPlayerName.get(key) ===
realGameCreationDto.playerNames[0]
)
const player1game: Game | undefined = this.games.playerGame(
realGameCreationDto.playerNames[0]
)
const player2Socket: Socket | undefined = Array.from(
this.socketToPlayerName.keys()
).find(
@ -157,10 +160,15 @@ export class PongGateway implements OnGatewayConnection, OnGatewayDisconnect {
this.socketToPlayerName.get(key) ===
realGameCreationDto.playerNames[1]
)
const player2game: Game | undefined = this.games.playerGame(
realGameCreationDto.playerNames[1]
)
if (
player1Socket !== undefined &&
player2Socket !== undefined &&
player1game === undefined &&
player2game === undefined &&
(client.id === player1Socket.id || client.id === player2Socket.id) &&
player1Socket.id !== player2Socket.id
) {

2
back/src/users/users.service.ts

@ -41,7 +41,7 @@ export class UsersService {
return user
}
@Cron('0 * * * * *')
@Cron('*/30 * * * * *')
async updateStatus (): Promise<void> {
const users = await this.usersRepository.find({})
users.forEach((usr) => {

2
front/src/components/Chat.svelte

@ -191,13 +191,13 @@
body: JSON.stringify(body),
});
if (response.ok) {
await show_popup(`User banned for: ${duration} seconds`, false);
const data: kickUserDto = {
chan: channel.id,
from: $store.ftId,
to: target.ftId,
};
socket.emit("kickUser", data);
await show_popup(`User banned for: ${duration} seconds`, false);
} else {
const error = await response.json();
await show_popup(error.message, false)

Loading…
Cancel
Save