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