use injected meta in claim-achievement.ts

This commit is contained in:
dakkar 2024-10-09 17:15:27 +01:00
parent 96e77f8d39
commit 7b7bc8b7b3

View file

@ -3,10 +3,11 @@
* SPDX-License-Identifier: AGPL-3.0-only * SPDX-License-Identifier: AGPL-3.0-only
*/ */
import { DI } from '@/di-symbols.js';
import { Injectable } from '@nestjs/common'; import { Injectable } from '@nestjs/common';
import { Endpoint } from '@/server/api/endpoint-base.js'; import { Endpoint } from '@/server/api/endpoint-base.js';
import { AchievementService, ACHIEVEMENT_TYPES } from '@/core/AchievementService.js'; import { AchievementService, ACHIEVEMENT_TYPES } from '@/core/AchievementService.js';
import { MetaService } from '@/core/MetaService.js'; import type { MiMeta } from '@/models/_.js';
export const meta = { export const meta = {
requireCredential: true, requireCredential: true,
@ -25,12 +26,13 @@ export const paramDef = {
@Injectable() @Injectable()
export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-disable-line import/no-default-export export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-disable-line import/no-default-export
constructor( constructor(
@Inject(DI.meta)
private serverSettings: MiMeta,
private achievementService: AchievementService, private achievementService: AchievementService,
private metaService: MetaService,
) { ) {
super(meta, paramDef, async (ps, me) => { super(meta, paramDef, async (ps, me) => {
const meta = await this.metaService.fetch(); if (!this.serverSettings.enableAchievements) return;
if (!meta.enableAchievements) return;
await this.achievementService.create(me.id, ps.name); await this.achievementService.create(me.id, ps.name);
}); });