Skip to content

Commit 0a36e7b

Browse files
committed
fix: exports route
1 parent 5b6d5d9 commit 0a36e7b

File tree

13 files changed

+54
-32
lines changed

13 files changed

+54
-32
lines changed

libs/decorators/crontab.decorators.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ export function CronTab(cronTime: string, options: { monitor: string }): MethodD
77
return applyDecorators(
88
Cron(cronTime, {
99
timeZone: 'Etc/UTC',
10-
disabled: !Config.CRON_ENABLED,
10+
disabled: !Config.CRON_ENABLED && Config.IS_PROD,
1111
}),
1212
SentryCron(options.monitor, {
1313
schedule: {

libs/discord-oauth/src/discord-oauth.service.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ export class DiscordOauthService {
4141
return payload as APIGuildMember[];
4242
}
4343

44-
public buildAvatarUrl(userId: string, avatar: string | null) {
44+
public toAvatarUrl(userId: string, avatar: string | null) {
4545
if (!avatar) {
4646
return `https://cdn.discordapp.com/embed/avatars/${BigInt(userId) % BigInt(5)}.png`;
4747
}

libs/interceptors/http-cache.interceptor.ts

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -27,16 +27,6 @@ export class HttpCacheInterceptor extends CacheInterceptor {
2727
res.setHeader('x-cache-key', cacheKey);
2828
}
2929

30-
if (cacheKey && !Config.IS_PROD) {
31-
const timestamp = await this.cacheManager.ttl(cacheKey);
32-
if (typeof timestamp === 'number' && timestamp > Date.now()) {
33-
res.setHeader(
34-
'Cache-Control',
35-
`public, max-age=${Math.floor((timestamp - Date.now()) / 1000)}`,
36-
);
37-
}
38-
}
39-
4030
return super.intercept(context, next);
4131
}
4232

src/auth/auth.controller.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { ApiExcludeRoute, ApiKeyAuth } from '@app/decorators';
22
import { paragraph } from '@app/helpers';
33
import { Body, Controller, Get, Param, Post, Req, Res, UseGuards } from '@nestjs/common';
4-
import { ApiExcludeEndpoint, ApiOperation } from '@nestjs/swagger';
4+
import { ApiExcludeEndpoint, ApiExtraModels, ApiOperation } from '@nestjs/swagger';
55
import { Request, Response } from 'express';
66
import { AuthService } from './auth.service';
77
import {
@@ -11,12 +11,14 @@ import {
1111
HandoffTokenDto,
1212
HandoffTokenInputDto,
1313
HandoffUserDto,
14+
JwtUserInput,
1415
LoginInputDto,
1516
LoginOkDto,
1617
TurnstileLoginDto,
1718
} from './dto';
1819
import { ApiKeyGuard } from './guards';
1920

21+
@ApiExtraModels(JwtUserInput)
2022
@Controller('/auth')
2123
export class AuthController {
2224
constructor(private authService: AuthService) {}

src/auth/auth.service.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,7 @@ export class AuthService {
170170
avatar: string | null;
171171
username: string;
172172
displayName: string;
173+
applicationId: string | null;
173174
};
174175

175176
return {
@@ -179,7 +180,8 @@ export class AuthService {
179180
roles: [UserRoles.USER],
180181
username: user.username,
181182
displayName: user.displayName,
182-
avatarUrl: this.discordOauthService.buildAvatarUrl(user.userId, user.avatar),
183+
applicationId: user.applicationId,
184+
avatarUrl: this.discordOauthService.toAvatarUrl(user.userId, user.avatar),
183185
};
184186
}
185187

@@ -195,6 +197,7 @@ export class AuthService {
195197
guildId: payload.guildId,
196198
username: user.username,
197199
avatar: user.avatar || null,
200+
applicationId: payload.applicationId || null,
198201
displayName: user.global_name || user.username,
199202
}),
200203
'EX',

src/auth/dto/jwt-user.dto.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { ApiProperty } from '@nestjs/swagger';
12
import { randomUUID } from 'node:crypto';
23
import { UserRoles } from './user-roles.dto';
34

@@ -6,6 +7,7 @@ export class JwtUserInput {
67
userId: string;
78
username: string;
89
version: string;
10+
@ApiProperty({ type: 'array', items: { type: 'string' } })
911
roles: UserRoles[];
1012
guildIds: string[];
1113
applicationId?: string;

src/auth/dto/login.dto.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { EnumArray } from '@app/decorators';
2-
import { IsNotEmpty, IsString } from 'class-validator';
2+
import { IsNotEmpty, IsOptional, IsString } from 'class-validator';
33
import { UserRoles } from './user-roles.dto';
44

55
export class LoginInputDto {
@@ -68,6 +68,10 @@ export class HandoffTokenInputDto {
6868
@IsString()
6969
@IsNotEmpty()
7070
guildId: string;
71+
72+
@IsString()
73+
@IsOptional()
74+
applicationId: string | null;
7175
}
7276

7377
export class HandoffTokenDto {
@@ -89,5 +93,7 @@ export class HandoffUserDto {
8993

9094
guildId: string;
9195

96+
applicationId: string | null;
97+
9298
avatarUrl: string | null;
9399
}

src/db/mongodb.module.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ export enum Collections {
2727

2828
PORTAL_USERS = 'PortalUsers',
2929
PLAYER_LINKS = 'PlayerLinks',
30+
PLAYER_LINK_AUDIT_LOGS = 'PlayerLinkAuditLogs',
3031
CLAN_WARS = 'ClanWars',
3132
CWL_GROUPS = 'CWLGroups',
3233
LEGEND_ATTACKS = 'LegendAttacks',

src/exports/exports.service.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ export class ExportsService {
3737

3838
async exportClanMembers(input: ExportMembersInput) {
3939
const scheduled = await this.reusableSheetService.getSheet({
40-
scheduled: true,
40+
scheduled: input.scheduled,
4141
clanTags: input.clanTags,
4242
guildId: input.guildId,
4343
sheetType: SheetType.CLAN_MEMBERS,

src/links/links.controller.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,11 @@ export class LinksController {
2424
@CurrentUser() user: JwtUser,
2525
@Param('playerTag') playerTag: string,
2626
): Promise<ResultOkDto> {
27-
return this.linksService.deleteLink(user.userId, playerTag);
27+
return this.linksService.deleteLink({
28+
playerTag,
29+
userId: user.userId,
30+
isAdmin: JwtUser.isAdmin(user),
31+
});
2832
}
2933

3034
@Post('/query')

0 commit comments

Comments
 (0)