Skip to content

Commit

Permalink
アバターデコレーションを削除 (#352)
Browse files Browse the repository at this point in the history
* finish backend

* finish frontend

* remove consts from misskey-js

* minor fix
  • Loading branch information
adzukimame authored Dec 7, 2024
1 parent 2c40d98 commit f5a51b4
Show file tree
Hide file tree
Showing 47 changed files with 28 additions and 1,779 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
export default class RemoveAvatarDecorations1733585002559 {
name = 'RemoveAvatarDecorations1733585002559'

async up(queryRunner) {
// AvatarDecoration21697941908548
await queryRunner.query(`ALTER TABLE "user" DROP COLUMN "avatarDecorations"`);
await queryRunner.query(`ALTER TABLE "user" ADD "avatarDecorations" character varying(512) array NOT NULL DEFAULT '{}'`);

// AvatarDecoration1697847397844
await queryRunner.query(`ALTER TABLE "user" DROP COLUMN "avatarDecorations"`);
await queryRunner.query(`DROP TABLE "avatar_decoration"`);
}

async down(queryRunner) {
// AvatarDecoration1697847397844
await queryRunner.query(`CREATE TABLE "avatar_decoration" ("id" character varying(32) NOT NULL, "updatedAt" TIMESTAMP WITH TIME ZONE, "url" character varying(1024) NOT NULL, "name" character varying(256) NOT NULL, "description" character varying(2048) NOT NULL, "roleIdsThatCanBeUsedThisDecoration" character varying(128) array NOT NULL DEFAULT '{}', CONSTRAINT "PK_b6de9296f6097078e1dc53f7603" PRIMARY KEY ("id"))`);
await queryRunner.query(`ALTER TABLE "user" ADD "avatarDecorations" character varying(512) array NOT NULL DEFAULT '{}'`);

// AvatarDecoration21697941908548
await queryRunner.query(`ALTER TABLE "user" DROP COLUMN "avatarDecorations"`);
await queryRunner.query(`ALTER TABLE "user" ADD "avatarDecorations" jsonb NOT NULL DEFAULT '[]'`);
}
}
105 changes: 0 additions & 105 deletions packages/backend/src/core/AvatarDecorationService.ts

This file was deleted.

6 changes: 0 additions & 6 deletions packages/backend/src/core/CoreModule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import { AccountUpdateService } from './AccountUpdateService.js';
import { AiService } from './AiService.js';
import { AntennaService } from './AntennaService.js';
import { AppLockService } from './AppLockService.js';
import { AvatarDecorationService } from './AvatarDecorationService.js';
import { CaptchaService } from './CaptchaService.js';
import { CreateSystemUserService } from './CreateSystemUserService.js';
import { CustomEmojiService } from './CustomEmojiService.js';
Expand Down Expand Up @@ -130,7 +129,6 @@ const $AccountUpdateService: Provider = { provide: 'AccountUpdateService', useEx
const $AiService: Provider = { provide: 'AiService', useExisting: AiService };
const $AntennaService: Provider = { provide: 'AntennaService', useExisting: AntennaService };
const $AppLockService: Provider = { provide: 'AppLockService', useExisting: AppLockService };
const $AvatarDecorationService: Provider = { provide: 'AvatarDecorationService', useExisting: AvatarDecorationService };
const $CaptchaService: Provider = { provide: 'CaptchaService', useExisting: CaptchaService };
const $CreateSystemUserService: Provider = { provide: 'CreateSystemUserService', useExisting: CreateSystemUserService };
const $CustomEmojiService: Provider = { provide: 'CustomEmojiService', useExisting: CustomEmojiService };
Expand Down Expand Up @@ -252,7 +250,6 @@ const $ApQuestionService: Provider = { provide: 'ApQuestionService', useExisting
AiService,
AntennaService,
AppLockService,
AvatarDecorationService,
CaptchaService,
CreateSystemUserService,
CustomEmojiService,
Expand Down Expand Up @@ -370,7 +367,6 @@ const $ApQuestionService: Provider = { provide: 'ApQuestionService', useExisting
$AiService,
$AntennaService,
$AppLockService,
$AvatarDecorationService,
$CaptchaService,
$CreateSystemUserService,
$CustomEmojiService,
Expand Down Expand Up @@ -489,7 +485,6 @@ const $ApQuestionService: Provider = { provide: 'ApQuestionService', useExisting
AiService,
AntennaService,
AppLockService,
AvatarDecorationService,
CaptchaService,
CreateSystemUserService,
CustomEmojiService,
Expand Down Expand Up @@ -606,7 +601,6 @@ const $ApQuestionService: Provider = { provide: 'ApQuestionService', useExisting
$AiService,
$AntennaService,
$AppLockService,
$AvatarDecorationService,
$CaptchaService,
$CreateSystemUserService,
$CustomEmojiService,
Expand Down
5 changes: 1 addition & 4 deletions packages/backend/src/core/GlobalEventService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import type { MiUserList } from '@/models/UserList.js';
import type { MiSignin } from '@/models/Signin.js';
import type { MiWebhook } from '@/models/Webhook.js';
import type { MiMeta } from '@/models/Meta.js';
import { MiAvatarDecoration, MiRole, MiRoleAssignment } from '@/models/_.js';
import { MiRole, MiRoleAssignment } from '@/models/_.js';
import type { Packed } from '@/misc/json-schema.js';
import { DI } from '@/di-symbols.js';
import type { Config } from '@/config.js';
Expand Down Expand Up @@ -177,9 +177,6 @@ export interface InternalEventTypes {
antennaCreated: MiAntenna;
antennaDeleted: MiAntenna;
antennaUpdated: MiAntenna;
avatarDecorationCreated: MiAvatarDecoration;
avatarDecorationDeleted: MiAvatarDecoration;
avatarDecorationUpdated: MiAvatarDecoration;
metaUpdated: MiMeta;
followChannel: { userId: MiUser['id']; channelId: MiChannel['id']; };
unfollowChannel: { userId: MiUser['id']; channelId: MiChannel['id']; };
Expand Down
6 changes: 0 additions & 6 deletions packages/backend/src/core/RoleService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,13 @@ export type RolePolicies = {
inviteLimitCycle: number;
inviteExpirationTime: number;
canManageCustomEmojis: boolean;
canManageAvatarDecorations: boolean;
canSearchNotes: boolean;
canUseTranslator: boolean;
driveCapacityMb: number;
alwaysMarkNsfw: boolean;
canUpdateBioMedia: boolean;
pinLimit: number;
rateLimitFactor: number;
avatarDecorationLimit: number;
canMakePureRenoteOfRemoteNotes: boolean;
canImportAntennas: boolean;
canImportBlocking: boolean;
Expand All @@ -67,15 +65,13 @@ export const DEFAULT_POLICIES: RolePolicies = {
inviteLimitCycle: 60 * 24 * 7,
inviteExpirationTime: 0,
canManageCustomEmojis: false,
canManageAvatarDecorations: false,
canSearchNotes: false,
canUseTranslator: true,
driveCapacityMb: 100,
alwaysMarkNsfw: false,
canUpdateBioMedia: true,
pinLimit: 5,
rateLimitFactor: 1,
avatarDecorationLimit: 1,
canMakePureRenoteOfRemoteNotes: true,
canImportAntennas: true,
canImportBlocking: true,
Expand Down Expand Up @@ -358,15 +354,13 @@ export class RoleService implements OnApplicationShutdown, OnModuleInit {
inviteLimitCycle: calc('inviteLimitCycle', vs => Math.max(...vs)),
inviteExpirationTime: calc('inviteExpirationTime', vs => Math.max(...vs)),
canManageCustomEmojis: calc('canManageCustomEmojis', vs => vs.some(v => v === true)),
canManageAvatarDecorations: calc('canManageAvatarDecorations', vs => vs.some(v => v === true)),
canSearchNotes: calc('canSearchNotes', vs => vs.some(v => v === true)),
canUseTranslator: calc('canUseTranslator', vs => vs.some(v => v === true)),
driveCapacityMb: calc('driveCapacityMb', vs => Math.max(...vs)),
alwaysMarkNsfw: calc('alwaysMarkNsfw', vs => vs.some(v => v === true)),
canUpdateBioMedia: calc('canUpdateBioMedia', vs => vs.some(v => v === true)),
pinLimit: calc('pinLimit', vs => Math.max(...vs)),
rateLimitFactor: calc('rateLimitFactor', vs => Math.max(...vs)),
avatarDecorationLimit: calc('avatarDecorationLimit', vs => Math.max(...vs)),
canMakePureRenoteOfRemoteNotes: calc('canMakePureRenoteOfRemoteNotes', vs => vs.some(v => v === true)),
canImportAntennas: calc('canImportAntennas', vs => vs.some(v => v === true)),
canImportBlocking: calc('canImportBlocking', vs => vs.some(v => v === true)),
Expand Down
11 changes: 0 additions & 11 deletions packages/backend/src/core/entities/UserEntityService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ import { ApPersonService } from '@/core/activitypub/models/ApPersonService.js';
import { FederatedInstanceService } from '@/core/FederatedInstanceService.js';
import { IdService } from '@/core/IdService.js';
import type { CustomEmojiService } from '@/core/CustomEmojiService.js';
import { AvatarDecorationService } from '@/core/AvatarDecorationService.js';
import type { OnModuleInit } from '@nestjs/common';
import type { NoteEntityService } from './NoteEntityService.js';
import type { DriveFileEntityService } from './DriveFileEntityService.js';
Expand Down Expand Up @@ -86,7 +85,6 @@ export class UserEntityService implements OnModuleInit {
private roleService: RoleService;
private federatedInstanceService: FederatedInstanceService;
private idService: IdService;
private avatarDecorationService: AvatarDecorationService;

constructor(
private moduleRef: ModuleRef,
Expand Down Expand Up @@ -139,7 +137,6 @@ export class UserEntityService implements OnModuleInit {
this.roleService = this.moduleRef.get('RoleService');
this.federatedInstanceService = this.moduleRef.get('FederatedInstanceService');
this.idService = this.moduleRef.get('IdService');
this.avatarDecorationService = this.moduleRef.get('AvatarDecorationService');
}

//#region Validators
Expand Down Expand Up @@ -457,14 +454,6 @@ export class UserEntityService implements OnModuleInit {
host: user.host,
avatarUrl: user.avatarUrl ?? this.getIdenticonUrl(user),
avatarBlurhash: user.avatarBlurhash,
avatarDecorations: user.avatarDecorations.length > 0 ? this.avatarDecorationService.getAll().then(decorations => user.avatarDecorations.filter(ud => decorations.some(d => d.id === ud.id)).map(ud => ({
id: ud.id,
angle: ud.angle || undefined,
flipH: ud.flipH || undefined,
offsetX: ud.offsetX || undefined,
offsetY: ud.offsetY || undefined,
url: decorations.find(d => d.id === ud.id)!.url,
}))) : [],
isBot: user.isBot,
instance: user.host ? this.federatedInstanceService.federatedInstanceCache.fetch(user.host).then(instance => instance ? {
name: instance.name,
Expand Down
1 change: 0 additions & 1 deletion packages/backend/src/di-symbols.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ export const DI = {
usersRepository: Symbol('usersRepository'),
notesRepository: Symbol('notesRepository'),
appsRepository: Symbol('appsRepository'),
avatarDecorationsRepository: Symbol('avatarDecorationsRepository'),
noteThreadMutingsRepository: Symbol('noteThreadMutingsRepository'),
noteReactionsRepository: Symbol('noteReactionsRepository'),
noteUnreadsRepository: Symbol('noteUnreadsRepository'),
Expand Down
39 changes: 0 additions & 39 deletions packages/backend/src/models/AvatarDecoration.ts

This file was deleted.

9 changes: 0 additions & 9 deletions packages/backend/src/models/RepositoryModule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import {
MiAntenna,
MiApp,
MiAuthSession,
MiAvatarDecoration,
MiBlocking,
MiChannel,
MiChannelFavorite,
Expand Down Expand Up @@ -81,12 +80,6 @@ const $appsRepository: Provider = {
inject: [DI.db],
};

const $avatarDecorationsRepository: Provider = {
provide: DI.avatarDecorationsRepository,
useFactory: (db: DataSource) => db.getRepository(MiAvatarDecoration).extend(miRepository as MiRepository<MiAvatarDecoration>),
inject: [DI.db],
};

const $noteThreadMutingsRepository: Provider = {
provide: DI.noteThreadMutingsRepository,
useFactory: (db: DataSource) => db.getRepository(MiNoteThreadMuting).extend(miRepository as MiRepository<MiNoteThreadMuting>),
Expand Down Expand Up @@ -375,7 +368,6 @@ const $userMemosRepository: Provider = {
$usersRepository,
$notesRepository,
$appsRepository,
$avatarDecorationsRepository,
$noteThreadMutingsRepository,
$noteReactionsRepository,
$noteUnreadsRepository,
Expand Down Expand Up @@ -428,7 +420,6 @@ const $userMemosRepository: Provider = {
$usersRepository,
$notesRepository,
$appsRepository,
$avatarDecorationsRepository,
$noteThreadMutingsRepository,
$noteReactionsRepository,
$noteUnreadsRepository,
Expand Down
11 changes: 0 additions & 11 deletions packages/backend/src/models/User.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,17 +127,6 @@ export class MiUser {
})
public bannerBlurhash: string | null;

@Column('jsonb', {
default: [],
})
public avatarDecorations: {
id: string;
angle?: number;
flipH?: boolean;
offsetX?: number;
offsetY?: number;
}[];

@Index()
@Column('varchar', {
length: 128, array: true, default: '{}',
Expand Down
Loading

0 comments on commit f5a51b4

Please sign in to comment.