use injected meta in claim-achievement.ts
This commit is contained in:
parent
96e77f8d39
commit
7b7bc8b7b3
1 changed files with 6 additions and 4 deletions
|
@ -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);
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue