diff options
| author | syuilo <Syuilotan@yahoo.co.jp> | 2023-10-21 18:38:07 +0900 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-10-21 18:38:07 +0900 |
| commit | 2c0a139da60ddf33e82353acbb985230c71c78da (patch) | |
| tree | b12d2762b332b7c885c5b210954053869618b62a /packages/backend/src/server/api/endpoints/i | |
| parent | Update CHANGELOG.md (diff) | |
| download | sharkey-2c0a139da60ddf33e82353acbb985230c71c78da.tar.gz sharkey-2c0a139da60ddf33e82353acbb985230c71c78da.tar.bz2 sharkey-2c0a139da60ddf33e82353acbb985230c71c78da.zip | |
feat: Avatar decoration (#12096)
* wip
* Update ja-JP.yml
* Update profile.vue
* .js
* Update home.test.ts
Diffstat (limited to 'packages/backend/src/server/api/endpoints/i')
| -rw-r--r-- | packages/backend/src/server/api/endpoints/i/update.ts | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/packages/backend/src/server/api/endpoints/i/update.ts b/packages/backend/src/server/api/endpoints/i/update.ts index 431bb4c60a..f1837e7082 100644 --- a/packages/backend/src/server/api/endpoints/i/update.ts +++ b/packages/backend/src/server/api/endpoints/i/update.ts @@ -32,6 +32,7 @@ import { DriveFileEntityService } from '@/core/entities/DriveFileEntityService.j import { HttpRequestService } from '@/core/HttpRequestService.js'; import type { Config } from '@/config.js'; import { safeForSql } from '@/misc/safe-for-sql.js'; +import { AvatarDecorationService } from '@/core/AvatarDecorationService.js'; import { ApiLoggerService } from '../../ApiLoggerService.js'; import { ApiError } from '../../error.js'; @@ -131,6 +132,9 @@ export const paramDef = { birthday: { ...birthdaySchema, nullable: true }, lang: { type: 'string', enum: [null, ...Object.keys(langmap)] as string[], nullable: true }, avatarId: { type: 'string', format: 'misskey:id', nullable: true }, + avatarDecorations: { type: 'array', maxItems: 1, items: { + type: 'string', + } }, bannerId: { type: 'string', format: 'misskey:id', nullable: true }, fields: { type: 'array', @@ -207,6 +211,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint- private roleService: RoleService, private cacheService: CacheService, private httpRequestService: HttpRequestService, + private avatarDecorationService: AvatarDecorationService, ) { super(meta, paramDef, async (ps, _user, token) => { const user = await this.usersRepository.findOneByOrFail({ id: _user.id }) as MiLocalUser; @@ -296,6 +301,17 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint- updates.bannerBlurhash = null; } + if (ps.avatarDecorations) { + const decorations = await this.avatarDecorationService.getAll(true); + const myRoles = await this.roleService.getUserRoles(user.id); + const allRoles = await this.roleService.getRoles(); + const decorationIds = decorations + .filter(d => d.roleIdsThatCanBeUsedThisDecoration.filter(roleId => allRoles.some(r => r.id === roleId)).length === 0 || myRoles.some(r => d.roleIdsThatCanBeUsedThisDecoration.includes(r.id))) + .map(d => d.id); + + updates.avatarDecorations = ps.avatarDecorations.filter(id => decorationIds.includes(id)); + } + if (ps.pinnedPageId) { const page = await this.pagesRepository.findOneBy({ id: ps.pinnedPageId }); |