Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions src/chat/chat.controller.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import {
Body,
Controller,
ForbiddenException,
Get,
Param,
Put,
Expand All @@ -14,6 +15,7 @@ import { ChatService } from "./chat.service";
import { lobbies_set_input } from "generated/schema";
import { HasuraEventData } from "src/hasura/types/HasuraEventData";
import { ChatLobbyType } from "./enums/ChatLobbyTypes";
import { MatchChatLog } from "./types/MatchChatLog";

@Controller("chat")
export class ChatController {
Expand Down Expand Up @@ -78,6 +80,21 @@ export class ChatController {
};
}

@Get("matches/:matchId/log")
@UseGuards(SteamGuard)
public async matchChatLog(
@Req() request: Request,
@Param("matchId") matchId: string,
): Promise<MatchChatLog> {
const log = await this.chatService.matchChatLog(matchId, request.user);

if (!log) {
throw new ForbiddenException();
}

return log;
}

@HasuraEvent()
public async chat_lobbies_removed(data: HasuraEventData<lobbies_set_input>) {
await this.chatService.removeLobby(ChatLobbyType.MatchMaking, data.old.id);
Expand Down
14 changes: 10 additions & 4 deletions src/chat/chat.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1914,7 +1914,9 @@ describe("ChatService direct messages", () => {

it("keeps the audit row when the swap fails outright, since it may have applied", async () => {
store();
redis.eval.mockRejectedValueOnce(new Error("connection reset"));
redis.eval
.mockResolvedValueOnce(1)
.mockRejectedValueOnce(new Error("connection reset"));

await expect(edit()).rejects.toThrow("connection reset");

Expand Down Expand Up @@ -2796,7 +2798,7 @@ describe("ChatService direct messages", () => {
// test/chat-redis-actions.spec.ts; this is what the service does around it.
it("hands the move all four keys, then re-sends history with the reactions it carried", async () => {
hashes[REACTIONS] = { [MESSAGE_ID]: JSON.stringify({ fire: [ME] }) };
redis.eval.mockResolvedValueOnce(1);
redis.eval.mockResolvedValueOnce([MESSAGE_ID, hashes[ROOM][MESSAGE_ID]]);

await service.migrateLobbyMessages(
ChatLobbyType.Draft,
Expand Down Expand Up @@ -3414,7 +3416,9 @@ describe("ChatService direct messages", () => {
say(FRIEND, "from friend");
say(STRANGER, "from stranger");
blocks = [[ME, FRIEND]];
redis.eval.mockResolvedValueOnce(2);
redis.eval.mockResolvedValueOnce(
Object.entries(hashes["chat_match_m-1"]).flat(),
);

await service.migrateLobbyMessages(
ChatLobbyType.Draft,
Expand Down Expand Up @@ -3448,7 +3452,9 @@ describe("ChatService direct messages", () => {

it("logs a re-send whose block lookup fails instead of leaving it unhandled", async () => {
say(FRIEND, "from friend");
redis.eval.mockResolvedValueOnce(1);
redis.eval.mockResolvedValueOnce(
Object.entries(hashes["chat_match_m-1"]).flat(),
);
playerBlocks.blockedAmong.mockRejectedValueOnce(
new Error("pool timeout"),
);
Expand Down
Loading
Loading