mirror of
https://codeberg.org/yeentown/barkey
synced 2024-11-22 07:55:12 +00:00
add achievement
This commit is contained in:
parent
7fdf298bd4
commit
26ae2dfc0f
4 changed files with 17 additions and 1 deletions
|
@ -1049,6 +1049,9 @@ _achievements:
|
||||||
_noteFavorited1:
|
_noteFavorited1:
|
||||||
title: "星をみるひと"
|
title: "星をみるひと"
|
||||||
description: "初めてノートをお気に入りに登録した"
|
description: "初めてノートをお気に入りに登録した"
|
||||||
|
_myNoteFavorited1:
|
||||||
|
title: "星が欲しい"
|
||||||
|
description: "自分のノートが他の人からお気に入りに登録された"
|
||||||
_profileFilled:
|
_profileFilled:
|
||||||
title: "準備万端"
|
title: "準備万端"
|
||||||
description: "プロフィール設定を行った"
|
description: "プロフィール設定を行った"
|
||||||
|
|
|
@ -44,6 +44,7 @@ const ACHIEVEMENT_TYPES = [
|
||||||
'loggedInOnNewYearsDay',
|
'loggedInOnNewYearsDay',
|
||||||
'noteClipped1',
|
'noteClipped1',
|
||||||
'noteFavorited1',
|
'noteFavorited1',
|
||||||
|
'myNoteFavorited1',
|
||||||
'profileFilled',
|
'profileFilled',
|
||||||
'markedAsCat',
|
'markedAsCat',
|
||||||
'following1',
|
'following1',
|
||||||
|
@ -94,7 +95,7 @@ export class AchievementService {
|
||||||
@bindThis
|
@bindThis
|
||||||
public async create(
|
public async create(
|
||||||
userId: User['id'],
|
userId: User['id'],
|
||||||
type: string,
|
type: typeof ACHIEVEMENT_TYPES[number],
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
if (!ACHIEVEMENT_TYPES.includes(type)) return;
|
if (!ACHIEVEMENT_TYPES.includes(type)) return;
|
||||||
|
|
||||||
|
|
|
@ -6,6 +6,7 @@ import { Endpoint } from '@/server/api/endpoint-base.js';
|
||||||
import { GetterService } from '@/server/api/GetterService.js';
|
import { GetterService } from '@/server/api/GetterService.js';
|
||||||
import { DI } from '@/di-symbols.js';
|
import { DI } from '@/di-symbols.js';
|
||||||
import { ApiError } from '../../../error.js';
|
import { ApiError } from '../../../error.js';
|
||||||
|
import { AchievementService } from '@/core/AchievementService.js';
|
||||||
|
|
||||||
export const meta = {
|
export const meta = {
|
||||||
tags: ['notes', 'favorites'],
|
tags: ['notes', 'favorites'],
|
||||||
|
@ -51,6 +52,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
|
||||||
|
|
||||||
private idService: IdService,
|
private idService: IdService,
|
||||||
private getterService: GetterService,
|
private getterService: GetterService,
|
||||||
|
private achievementService: AchievementService,
|
||||||
) {
|
) {
|
||||||
super(meta, paramDef, async (ps, me) => {
|
super(meta, paramDef, async (ps, me) => {
|
||||||
// Get favoritee
|
// Get favoritee
|
||||||
|
@ -76,6 +78,10 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
|
||||||
noteId: note.id,
|
noteId: note.id,
|
||||||
userId: me.id,
|
userId: me.id,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (note.userHost == null) {
|
||||||
|
this.achievementService.create(note.userId, 'myNoteFavorited1');
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,6 +40,7 @@ export const ACHIEVEMENT_TYPES = [
|
||||||
'loggedInOnNewYearsDay',
|
'loggedInOnNewYearsDay',
|
||||||
'noteClipped1',
|
'noteClipped1',
|
||||||
'noteFavorited1',
|
'noteFavorited1',
|
||||||
|
'myNoteFavorited1',
|
||||||
'profileFilled',
|
'profileFilled',
|
||||||
'markedAsCat',
|
'markedAsCat',
|
||||||
'following1',
|
'following1',
|
||||||
|
@ -240,6 +241,11 @@ export const ACHIEVEMENT_BADGES = {
|
||||||
bg: null,
|
bg: null,
|
||||||
frame: 'bronze',
|
frame: 'bronze',
|
||||||
},
|
},
|
||||||
|
'myNoteFavorited1': {
|
||||||
|
img: '/fluent-emoji/1f320.png',
|
||||||
|
bg: null,
|
||||||
|
frame: 'silver',
|
||||||
|
},
|
||||||
'profileFilled': {
|
'profileFilled': {
|
||||||
img: '/fluent-emoji/1f44c.png',
|
img: '/fluent-emoji/1f44c.png',
|
||||||
bg: 'linear-gradient(0deg, rgb(187 183 59), rgb(255 143 77))',
|
bg: 'linear-gradient(0deg, rgb(187 183 59), rgb(255 143 77))',
|
||||||
|
|
Loading…
Reference in a new issue