From 8fd5eb7010ec91f3a189b967ccbe35a8ce373463 Mon Sep 17 00:00:00 2001 From: mattyatea Date: Tue, 24 Oct 2023 16:55:22 +0900 Subject: [PATCH] =?UTF-8?q?draft=E3=81=8B=E3=82=89request=E3=81=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: mattyatea --- locales/index.d.ts | 6 +-- locales/ja-JP.yml | 6 +-- .../migration/1697813507149-EmojiDraft.js | 13 ----- packages/backend/src/core/CoreModule.ts | 12 ++--- .../backend/src/core/CustomEmojiService.ts | 38 +++++++------- ...rvice.ts => EmojiRequestsEntityService.ts} | 22 ++++---- packages/backend/src/di-symbols.ts | 2 +- packages/backend/src/misc/json-schema.ts | 6 +-- .../models/{EmojiDraft.ts => EmojiRequest.ts} | 4 +- .../backend/src/models/RepositoryModule.ts | 12 ++--- packages/backend/src/models/_.ts | 6 +-- .../backend/src/models/json-schema/emoji.ts | 4 +- packages/backend/src/postgres.ts | 4 +- .../backend/src/server/api/EndpointsModule.ts | 32 ++++++------ packages/backend/src/server/api/endpoints.ts | 16 +++--- .../emoji/{add-draft.ts => add-request.ts} | 6 +-- .../api/endpoints/admin/emoji/delete.ts | 6 +-- .../emoji/{list-draft.ts => list-request.ts} | 18 +++---- .../{update-draft.ts => update-request.ts} | 14 ++--- .../api/endpoints/admin/emoji/update.ts | 10 ++-- .../{emoji-drafts.ts => emoji-requests.ts} | 17 +++--- .../src/components/MkCustomEmojiEditLocal.vue | 8 +-- ...Draft.vue => MkCustomEmojiEditRequest.vue} | 52 +++++++++---------- .../src/components/MkEmojiEditDialog.vue | 30 +++++------ .../frontend/src/components/MkEmojiPicker.vue | 2 +- packages/frontend/src/pages/about.emojis.vue | 12 ++--- .../src/pages/custom-emojis-manager.vue | 10 ++-- packages/frontend/src/pages/emojis.emoji.vue | 10 ++-- packages/misskey-js/etc/misskey-js.api.md | 2 +- packages/misskey-js/src/entities.ts | 2 +- 30 files changed, 184 insertions(+), 198 deletions(-) delete mode 100644 packages/backend/migration/1697813507149-EmojiDraft.js rename packages/backend/src/core/entities/{EmojiDraftsEntityService.ts => EmojiRequestsEntityService.ts} (71%) rename packages/backend/src/models/{EmojiDraft.ts => EmojiRequest.ts} (95%) rename packages/backend/src/server/api/endpoints/admin/emoji/{add-draft.ts => add-request.ts} (90%) rename packages/backend/src/server/api/endpoints/admin/emoji/{list-draft.ts => list-request.ts} (79%) rename packages/backend/src/server/api/endpoints/admin/emoji/{update-draft.ts => update-request.ts} (89%) rename packages/backend/src/server/api/endpoints/{emoji-drafts.ts => emoji-requests.ts} (66%) rename packages/frontend/src/components/{MkCustomEmojiEditDraft.vue => MkCustomEmojiEditRequest.vue} (73%) diff --git a/locales/index.d.ts b/locales/index.d.ts index 81352c786c..3090f0cd04 100644 --- a/locales/index.d.ts +++ b/locales/index.d.ts @@ -261,7 +261,7 @@ export interface Locale { "imageUrl": string; "remove": string; "removed": string; - "undraftAreYouSure": string; + "requestApprovalAreYouSure": string; "removeAreYouSure": string; "deleteAreYouSure": string; "resetAreYouSure": string; @@ -1027,8 +1027,8 @@ export interface Locale { "sensitiveWordsDescription2": string; "notesSearchNotAvailable": string; "license": string; - "draft": string; - "undrafted": string; + "requestPending": string; + "requestApproval": string; "requestEmojis": string; "emojiNameValidation": string; "unfavoriteConfirm": string; diff --git a/locales/ja-JP.yml b/locales/ja-JP.yml index f6a9050331..92c209c681 100644 --- a/locales/ja-JP.yml +++ b/locales/ja-JP.yml @@ -258,7 +258,7 @@ announcements: "お知らせ" imageUrl: "画像URL" remove: "削除" removed: "削除しました" -undraftAreYouSure: "「{x}」をドラフト解除しますか?" +requestApprovalAreYouSure: "「{x}」のリクエストを承認しますか?" removeAreYouSure: "「{x}」を削除しますか?" deleteAreYouSure: "「{x}」を削除しますか?" resetAreYouSure: "リセットしますか?" @@ -1024,8 +1024,8 @@ sensitiveWordsDescription: "設定したワードが含まれるノートの公 sensitiveWordsDescription2: "スペースで区切るとAND指定になり、キーワードをスラッシュで囲むと正規表現になります。" notesSearchNotAvailable: "ノート検索は利用できません。" license: "ライセンス" -draft: "下書き" -undrafted: "下書き解除" +requestPending: "申請中" +requestApproval: "リクエストを承認" requestEmojis: "リクエストされている絵文字" emojiNameValidation: "名前には英数字と_が利用できます。" unfavoriteConfirm: "お気に入り解除しますか?" diff --git a/packages/backend/migration/1697813507149-EmojiDraft.js b/packages/backend/migration/1697813507149-EmojiDraft.js deleted file mode 100644 index 10e03ce949..0000000000 --- a/packages/backend/migration/1697813507149-EmojiDraft.js +++ /dev/null @@ -1,13 +0,0 @@ -export class EmojiDraft1697813507149 { - name = 'EmojiDraft1697813507149' - - async up(queryRunner) { - await queryRunner.query(`CREATE TABLE "emoji_draft" ("id" character varying(32) NOT NULL, "updatedAt" TIMESTAMP WITH TIME ZONE, "name" character varying(128) NOT NULL, "category" character varying(128), "originalUrl" character varying(512) NOT NULL, "publicUrl" character varying(512) NOT NULL DEFAULT '', "type" character varying(64), "aliases" character varying(128) array NOT NULL DEFAULT '{}', "license" character varying(1024), "fileId" character varying(1024) NOT NULL, "localOnly" boolean NOT NULL DEFAULT false, "isSensitive" boolean NOT NULL DEFAULT false, CONSTRAINT "PK_6c7c36f693e1cb8ba1343e3336f" PRIMARY KEY ("id"))`); - await queryRunner.query(`CREATE UNIQUE INDEX "IDX_aw4zqjtyvxcsh797kbpzxmca6x" ON "emoji_draft" ("name") `); - } - - async down(queryRunner) { - await queryRunner.query(`DROP INDEX "public"."IDX_aw4zqjtyvxcsh797kbpzxmca6x"`); - await queryRunner.query(`DROP TABLE "emoji_draft"`); - } -} diff --git a/packages/backend/src/core/CoreModule.ts b/packages/backend/src/core/CoreModule.ts index 295197acd2..10fceb87e7 100644 --- a/packages/backend/src/core/CoreModule.ts +++ b/packages/backend/src/core/CoreModule.ts @@ -87,7 +87,7 @@ import { ClipEntityService } from './entities/ClipEntityService.js'; import { DriveFileEntityService } from './entities/DriveFileEntityService.js'; import { DriveFolderEntityService } from './entities/DriveFolderEntityService.js'; import { EmojiEntityService } from './entities/EmojiEntityService.js'; -import { EmojiDraftsEntityService } from './entities/EmojiDraftsEntityService.js'; +import { EmojiRequestsEntityService } from './entities/EmojiRequestsEntityService.js'; import { FollowingEntityService } from './entities/FollowingEntityService.js'; import { FollowRequestEntityService } from './entities/FollowRequestEntityService.js'; import { GalleryLikeEntityService } from './entities/GalleryLikeEntityService.js'; @@ -220,7 +220,7 @@ const $ClipEntityService: Provider = { provide: 'ClipEntityService', useExisting const $DriveFileEntityService: Provider = { provide: 'DriveFileEntityService', useExisting: DriveFileEntityService }; const $DriveFolderEntityService: Provider = { provide: 'DriveFolderEntityService', useExisting: DriveFolderEntityService }; const $EmojiEntityService: Provider = { provide: 'EmojiEntityService', useExisting: EmojiEntityService }; -const $EmojiDraftsEntityService: Provider = { provide: 'EmojiDraftsEntityService', useExisting: EmojiDraftsEntityService }; +const $EmojiRequestsEntityService: Provider = { provide: 'EmojiRequestsEntityService', useExisting: EmojiRequestsEntityService }; const $FollowingEntityService: Provider = { provide: 'FollowingEntityService', useExisting: FollowingEntityService }; const $FollowRequestEntityService: Provider = { provide: 'FollowRequestEntityService', useExisting: FollowRequestEntityService }; const $GalleryLikeEntityService: Provider = { provide: 'GalleryLikeEntityService', useExisting: GalleryLikeEntityService }; @@ -353,7 +353,7 @@ const $ApQuestionService: Provider = { provide: 'ApQuestionService', useExisting DriveFileEntityService, DriveFolderEntityService, EmojiEntityService, - EmojiDraftsEntityService, + EmojiRequestsEntityService, FollowingEntityService, FollowRequestEntityService, GalleryLikeEntityService, @@ -481,7 +481,7 @@ const $ApQuestionService: Provider = { provide: 'ApQuestionService', useExisting $DriveFileEntityService, $DriveFolderEntityService, $EmojiEntityService, - $EmojiDraftsEntityService, + $EmojiRequestsEntityService, $FollowingEntityService, $FollowRequestEntityService, $GalleryLikeEntityService, @@ -609,7 +609,7 @@ const $ApQuestionService: Provider = { provide: 'ApQuestionService', useExisting DriveFileEntityService, DriveFolderEntityService, EmojiEntityService, - EmojiDraftsEntityService, + EmojiRequestsEntityService, FollowingEntityService, FollowRequestEntityService, GalleryLikeEntityService, @@ -736,7 +736,7 @@ const $ApQuestionService: Provider = { provide: 'ApQuestionService', useExisting $DriveFileEntityService, $DriveFolderEntityService, $EmojiEntityService, - $EmojiDraftsEntityService, + $EmojiRequestsEntityService, $FollowingEntityService, $FollowRequestEntityService, $GalleryLikeEntityService, diff --git a/packages/backend/src/core/CustomEmojiService.ts b/packages/backend/src/core/CustomEmojiService.ts index 1aa6377be3..1346d3d839 100644 --- a/packages/backend/src/core/CustomEmojiService.ts +++ b/packages/backend/src/core/CustomEmojiService.ts @@ -12,13 +12,13 @@ import { EmojiEntityService } from '@/core/entities/EmojiEntityService.js'; import { GlobalEventService } from '@/core/GlobalEventService.js'; import type { MiDriveFile } from '@/models/DriveFile.js'; import type { MiEmoji } from '@/models/Emoji.js'; -import type { EmojisRepository, EmojiDraftsRepository, MiRole, MiUser } from '@/models/_.js'; +import type { EmojisRepository, EmojiRequestsRepository, MiRole, MiUser } from '@/models/_.js'; import { bindThis } from '@/decorators.js'; import { MemoryKVCache, RedisSingleCache } from '@/misc/cache.js'; import { UtilityService } from '@/core/UtilityService.js'; import type { Serialized } from '@/types.js'; import { ModerationLogService } from '@/core/ModerationLogService.js'; -import { MiEmojiDraft } from '@/models/EmojiDraft.js'; +import { MiEmojiRequest } from '@/models/EmojiRequest.js'; const parseEmojiStrRegexp = /^(\w+)(?:@([\w.-]+))?$/; @@ -34,8 +34,8 @@ export class CustomEmojiService implements OnApplicationShutdown { @Inject(DI.emojisRepository) private emojisRepository: EmojisRepository, - @Inject(DI.emojiDraftsRepository) - private emojiDraftsRepository: EmojiDraftsRepository, + @Inject(DI.emojiRequestsRepository) + private emojiRequestsRepository: EmojiRequestsRepository, private utilityService: UtilityService, private idService: IdService, @@ -60,7 +60,7 @@ export class CustomEmojiService implements OnApplicationShutdown { } @bindThis - public async draft(data: { + public async Request(data: { driveFile: MiDriveFile; name: string; category: string | null; @@ -68,8 +68,8 @@ export class CustomEmojiService implements OnApplicationShutdown { license: string | null; isSensitive: boolean; localOnly: boolean; - }, me?: MiUser): Promise { - const emoji = await this.emojiDraftsRepository.insert({ + }, me?: MiUser): Promise { + const emoji = await this.emojiRequestsRepository.insert({ id: this.idService.gen(), updatedAt: new Date(), name: data.name, @@ -82,7 +82,7 @@ export class CustomEmojiService implements OnApplicationShutdown { isSensitive: data.isSensitive, localOnly: data.localOnly, fileId: data.driveFile.id, - }).then(x => this.emojiDraftsRepository.findOneByOrFail(x.identifiers[0])); + }).then(x => this.emojiRequestsRepository.findOneByOrFail(x.identifiers[0])); if (me) { this.moderationLogService.log(me, 'addCustomEmoji', { @@ -196,7 +196,7 @@ export class CustomEmojiService implements OnApplicationShutdown { } } @bindThis - public async draftUpdate(id: MiEmoji['id'], data: { + public async RequestUpdate(id: MiEmoji['id'], data: { driveFile?: MiDriveFile; name?: string; category?: string | null; @@ -205,11 +205,11 @@ export class CustomEmojiService implements OnApplicationShutdown { isSensitive?: boolean; localOnly?: boolean; }, moderator?: MiUser): Promise { - const emoji = await this.emojiDraftsRepository.findOneByOrFail({ id: id }); - const sameNameEmoji = await this.emojiDraftsRepository.findOneBy({ name: data.name }); + const emoji = await this.emojiRequestsRepository.findOneByOrFail({ id: id }); + const sameNameEmoji = await this.emojiRequestsRepository.findOneBy({ name: data.name }); if (sameNameEmoji != null && sameNameEmoji.id !== id) throw new Error('name already exists'); - await this.emojiDraftsRepository.update(emoji.id, { + await this.emojiRequestsRepository.update(emoji.id, { updatedAt: new Date(), name: data.name, category: data.category, @@ -332,10 +332,10 @@ export class CustomEmojiService implements OnApplicationShutdown { } } @bindThis - public async draftDelete(id: MiEmojiDraft['id']) { - const emoji = await this.emojiDraftsRepository.findOneByOrFail({ id: id }); + public async RequestDelete(id: MiEmojiRequest['id']) { + const emoji = await this.emojiRequestsRepository.findOneByOrFail({ id: id }); - await this.emojiDraftsRepository.delete(emoji.id); + await this.emojiRequestsRepository.delete(emoji.id); } @bindThis public async deleteBulk(ids: MiEmoji['id'][], moderator?: MiUser) { @@ -458,8 +458,8 @@ export class CustomEmojiService implements OnApplicationShutdown { return this.emojisRepository.exist({ where: { name, host: IsNull() } }); } @bindThis - public checkDraftDuplicate(name: string): Promise { - return this.emojiDraftsRepository.exist({ where: { name } }); + public checkRequestDuplicate(name: string): Promise { + return this.emojiRequestsRepository.exist({ where: { name } }); } @bindThis @@ -468,8 +468,8 @@ export class CustomEmojiService implements OnApplicationShutdown { } @bindThis - public getEmojiDraftById(id: string): Promise { - return this.emojiDraftsRepository.findOneBy({ id }); + public getEmojiRequestById(id: string): Promise { + return this.emojiRequestsRepository.findOneBy({ id }); } @bindThis public dispose(): void { diff --git a/packages/backend/src/core/entities/EmojiDraftsEntityService.ts b/packages/backend/src/core/entities/EmojiRequestsEntityService.ts similarity index 71% rename from packages/backend/src/core/entities/EmojiDraftsEntityService.ts rename to packages/backend/src/core/entities/EmojiRequestsEntityService.ts index de1a621553..46308e654c 100644 --- a/packages/backend/src/core/entities/EmojiDraftsEntityService.ts +++ b/packages/backend/src/core/entities/EmojiRequestsEntityService.ts @@ -5,24 +5,24 @@ import { Inject, Injectable } from '@nestjs/common'; import { DI } from '@/di-symbols.js'; -import type { EmojiDraftsRepository } from '@/models/_.js'; +import type { EmojiRequestsRepository } from '@/models/_.js'; import type { Packed } from '@/misc/json-schema.js'; import { bindThis } from '@/decorators.js'; -import { MiEmojiDraft } from '@/models/EmojiDraft.js'; +import { MiEmojiRequest } from '@/models/EmojiRequest.js'; @Injectable() -export class EmojiDraftsEntityService { +export class EmojiRequestsEntityService { constructor( - @Inject(DI.emojiDraftsRepository) - private emojiDraftsRepository: EmojiDraftsRepository, + @Inject(DI.emojiRequestsRepository) + private emojiRequestsRepository: EmojiRequestsRepository, ) { } @bindThis public async packSimple( - src: MiEmojiDraft['id'] | MiEmojiDraft, - ): Promise> { - const emoji = typeof src === 'object' ? src : await this.emojiDraftsRepository.findOneByOrFail({ id: src }); + src: MiEmojiRequest['id'] | MiEmojiRequest, + ): Promise> { + const emoji = typeof src === 'object' ? src : await this.emojiRequestsRepository.findOneByOrFail({ id: src }); return { aliases: emoji.aliases, @@ -43,9 +43,9 @@ export class EmojiDraftsEntityService { @bindThis public async packDetailed( - src: MiEmojiDraft['id'] | MiEmojiDraft, - ): Promise> { - const emoji = typeof src === 'object' ? src : await this.emojiDraftsRepository.findOneByOrFail({ id: src }); + src: MiEmojiRequest['id'] | MiEmojiRequest, + ): Promise> { + const emoji = typeof src === 'object' ? src : await this.emojiRequestsRepository.findOneByOrFail({ id: src }); return { id: emoji.id, diff --git a/packages/backend/src/di-symbols.ts b/packages/backend/src/di-symbols.ts index 7da4e75ae7..8c56300750 100644 --- a/packages/backend/src/di-symbols.ts +++ b/packages/backend/src/di-symbols.ts @@ -40,7 +40,7 @@ export const DI = { followRequestsRepository: Symbol('followRequestsRepository'), instancesRepository: Symbol('instancesRepository'), emojisRepository: Symbol('emojisRepository'), - emojiDraftsRepository: Symbol('emojiDraftsRepository'), + emojiRequestsRepository: Symbol('emojiRequestsRepository'), driveFilesRepository: Symbol('driveFilesRepository'), driveFoldersRepository: Symbol('driveFoldersRepository'), metasRepository: Symbol('metasRepository'), diff --git a/packages/backend/src/misc/json-schema.ts b/packages/backend/src/misc/json-schema.ts index d203d5fa82..d99a3edac4 100644 --- a/packages/backend/src/misc/json-schema.ts +++ b/packages/backend/src/misc/json-schema.ts @@ -33,7 +33,7 @@ import { packedClipSchema } from '@/models/json-schema/clip.js'; import { packedFederationInstanceSchema } from '@/models/json-schema/federation-instance.js'; import { packedQueueCountSchema } from '@/models/json-schema/queue.js'; import { packedGalleryPostSchema } from '@/models/json-schema/gallery-post.js'; -import { packedEmojiDetailedSchema, packedEmojiDraftSimpleSchema, packedEmojiSimpleSchema, packedEmojiDraftDetailedSchema } from '@/models/json-schema/emoji.js'; +import { packedEmojiDetailedSchema, packedEmojiRequestSimpleSchema, packedEmojiSimpleSchema, packedEmojiRequestDetailedSchema } from '@/models/json-schema/emoji.js'; import { packedFlashSchema } from '@/models/json-schema/flash.js'; import { packedAnnouncementSchema } from '@/models/json-schema/announcement.js'; @@ -69,9 +69,9 @@ export const refs = { FederationInstance: packedFederationInstanceSchema, GalleryPost: packedGalleryPostSchema, EmojiSimple: packedEmojiSimpleSchema, - EmojiDraftSimple: packedEmojiDraftSimpleSchema, + EmojiRequestSimple: packedEmojiRequestSimpleSchema, EmojiDetailed: packedEmojiDetailedSchema, - EmojiDraftDetailed: packedEmojiDraftDetailedSchema, + EmojiRequestDetailed: packedEmojiRequestDetailedSchema, Flash: packedFlashSchema, }; diff --git a/packages/backend/src/models/EmojiDraft.ts b/packages/backend/src/models/EmojiRequest.ts similarity index 95% rename from packages/backend/src/models/EmojiDraft.ts rename to packages/backend/src/models/EmojiRequest.ts index 1d4ee95319..53a5563f7e 100644 --- a/packages/backend/src/models/EmojiDraft.ts +++ b/packages/backend/src/models/EmojiRequest.ts @@ -6,9 +6,9 @@ import { PrimaryColumn, Entity, Index, Column } from 'typeorm'; import { id } from './util/id.js'; -@Entity('emoji_draft') +@Entity('emoji_request') @Index(['name'], { unique: true }) -export class MiEmojiDraft { +export class MiEmojiRequest { @PrimaryColumn(id()) public id: string; diff --git a/packages/backend/src/models/RepositoryModule.ts b/packages/backend/src/models/RepositoryModule.ts index b8202c0f81..bc5c61c547 100644 --- a/packages/backend/src/models/RepositoryModule.ts +++ b/packages/backend/src/models/RepositoryModule.ts @@ -5,7 +5,7 @@ import { Module } from '@nestjs/common'; import { DI } from '@/di-symbols.js'; -import { MiAbuseUserReport, MiAccessToken, MiAd, MiAnnouncement, MiAnnouncementRead, MiAntenna, MiApp, MiAuthSession, MiAvatarDecoration, MiBlocking, MiChannel, MiChannelFavorite, MiChannelFollowing, MiClip, MiClipFavorite, MiClipNote, MiDriveFile, MiDriveFolder, MiEmoji, MiEmojiDraft, MiFlash, MiFlashLike, MiFollowRequest, MiFollowing, MiGalleryLike, MiGalleryPost, MiHashtag, MiInstance, MiMeta, MiModerationLog, MiMuting, MiNote, MiNoteFavorite, MiNoteReaction, MiNoteThreadMuting, MiNoteUnread, MiPage, MiPageLike, MiPasswordResetRequest, MiPoll, MiPollVote, MiPromoNote, MiPromoRead, MiRegistrationTicket, MiRegistryItem, MiRelay, MiRenoteMuting, MiRetentionAggregation, MiRole, MiRoleAssignment, MiSignin, MiSwSubscription, MiUsedUsername, MiUser, MiUserIp, MiUserKeypair, MiUserList, MiUserListFavorite, MiUserListMembership, MiUserMemo, MiUserNotePining, MiUserPending, MiUserProfile, MiUserPublickey, MiUserSecurityKey, MiWebhook } from './_.js'; +import { MiAbuseUserReport, MiAccessToken, MiAd, MiAnnouncement, MiAnnouncementRead, MiAntenna, MiApp, MiAuthSession, MiAvatarDecoration, MiBlocking, MiChannel, MiChannelFavorite, MiChannelFollowing, MiClip, MiClipFavorite, MiClipNote, MiDriveFile, MiDriveFolder, MiEmoji, MiEmojiRequest, MiFlash, MiFlashLike, MiFollowRequest, MiFollowing, MiGalleryLike, MiGalleryPost, MiHashtag, MiInstance, MiMeta, MiModerationLog, MiMuting, MiNote, MiNoteFavorite, MiNoteReaction, MiNoteThreadMuting, MiNoteUnread, MiPage, MiPageLike, MiPasswordResetRequest, MiPoll, MiPollVote, MiPromoNote, MiPromoRead, MiRegistrationTicket, MiRegistryItem, MiRelay, MiRenoteMuting, MiRetentionAggregation, MiRole, MiRoleAssignment, MiSignin, MiSwSubscription, MiUsedUsername, MiUser, MiUserIp, MiUserKeypair, MiUserList, MiUserListFavorite, MiUserListMembership, MiUserMemo, MiUserNotePining, MiUserPending, MiUserProfile, MiUserPublickey, MiUserSecurityKey, MiWebhook } from './_.js'; import type { DataSource } from 'typeorm'; import type { Provider } from '@nestjs/common'; @@ -171,9 +171,9 @@ const $emojisRepository: Provider = { inject: [DI.db], }; -const $emojiDraftsRepository: Provider = { - provide: DI.emojiDraftsRepository, - useFactory: (db: DataSource) => db.getRepository(MiEmojiDraft), +const $emojiRequestsRepository: Provider = { + provide: DI.emojiRequestsRepository, + useFactory: (db: DataSource) => db.getRepository(MiEmojiRequest), inject: [DI.db], }; @@ -436,7 +436,7 @@ const $userMemosRepository: Provider = { $followRequestsRepository, $instancesRepository, $emojisRepository, - $emojiDraftsRepository, + $emojiRequestsRepository, $driveFilesRepository, $driveFoldersRepository, $metasRepository, @@ -504,7 +504,7 @@ const $userMemosRepository: Provider = { $followRequestsRepository, $instancesRepository, $emojisRepository, - $emojiDraftsRepository, + $emojiRequestsRepository, $driveFilesRepository, $driveFoldersRepository, $metasRepository, diff --git a/packages/backend/src/models/_.ts b/packages/backend/src/models/_.ts index f72c7e1065..14b94e30fc 100644 --- a/packages/backend/src/models/_.ts +++ b/packages/backend/src/models/_.ts @@ -21,6 +21,7 @@ import { MiClipFavorite } from '@/models/ClipFavorite.js'; import { MiDriveFile } from '@/models/DriveFile.js'; import { MiDriveFolder } from '@/models/DriveFolder.js'; import { MiEmoji } from '@/models/Emoji.js'; +import { MiEmojiRequest } from '@/models/EmojiRequest.js'; import { MiFollowing } from '@/models/Following.js'; import { MiFollowRequest } from '@/models/FollowRequest.js'; import { MiGalleryLike } from '@/models/GalleryLike.js'; @@ -68,7 +69,6 @@ import { MiRoleAssignment } from '@/models/RoleAssignment.js'; import { MiFlash } from '@/models/Flash.js'; import { MiFlashLike } from '@/models/FlashLike.js'; import { MiUserListFavorite } from '@/models/UserListFavorite.js'; -import { MiEmojiDraft } from '@/models/EmojiDraft.js'; import type { Repository } from 'typeorm'; export { @@ -90,7 +90,7 @@ export { MiDriveFile, MiDriveFolder, MiEmoji, - MiEmojiDraft, + MiEmojiRequest, MiFollowing, MiFollowRequest, MiGalleryLike, @@ -158,7 +158,7 @@ export type ClipFavoritesRepository = Repository; export type DriveFilesRepository = Repository; export type DriveFoldersRepository = Repository; export type EmojisRepository = Repository; -export type EmojiDraftsRepository = Repository; +export type EmojiRequestsRepository = Repository; export type FollowingsRepository = Repository; export type FollowRequestsRepository = Repository; export type GalleryLikesRepository = Repository; diff --git a/packages/backend/src/models/json-schema/emoji.ts b/packages/backend/src/models/json-schema/emoji.ts index 70da8dc67f..56b888c62a 100644 --- a/packages/backend/src/models/json-schema/emoji.ts +++ b/packages/backend/src/models/json-schema/emoji.ts @@ -42,7 +42,7 @@ export const packedEmojiSimpleSchema = { }, }, } as const; -export const packedEmojiDraftSimpleSchema = { +export const packedEmojiRequestSimpleSchema = { type: 'object', properties: { aliases: { @@ -131,7 +131,7 @@ export const packedEmojiDetailedSchema = { }, } as const; -export const packedEmojiDraftDetailedSchema = { +export const packedEmojiRequestDetailedSchema = { type: 'object', properties: { id: { diff --git a/packages/backend/src/postgres.ts b/packages/backend/src/postgres.ts index d62ad62ba6..a22b39f766 100644 --- a/packages/backend/src/postgres.ts +++ b/packages/backend/src/postgres.ts @@ -29,7 +29,7 @@ import { MiClipFavorite } from '@/models/ClipFavorite.js'; import { MiDriveFile } from '@/models/DriveFile.js'; import { MiDriveFolder } from '@/models/DriveFolder.js'; import { MiEmoji } from '@/models/Emoji.js'; -import { MiEmojiDraft } from '@/models/EmojiDraft.js'; +import { MiEmojiRequest } from '@/models/EmojiRequest.js'; import { MiFollowing } from '@/models/Following.js'; import { MiFollowRequest } from '@/models/FollowRequest.js'; import { MiGalleryLike } from '@/models/GalleryLike.js'; @@ -163,7 +163,7 @@ export const entities = [ MiPoll, MiPollVote, MiEmoji, - MiEmojiDraft, + MiEmojiRequest, MiHashtag, MiSwSubscription, MiAbuseUserReport, diff --git a/packages/backend/src/server/api/EndpointsModule.ts b/packages/backend/src/server/api/EndpointsModule.ts index 6db60b456f..6a86447c42 100644 --- a/packages/backend/src/server/api/EndpointsModule.ts +++ b/packages/backend/src/server/api/EndpointsModule.ts @@ -29,20 +29,20 @@ import * as ep___admin_drive_files from './endpoints/admin/drive/files.js'; import * as ep___admin_drive_showFile from './endpoints/admin/drive/show-file.js'; import * as ep___admin_emoji_addAliasesBulk from './endpoints/admin/emoji/add-aliases-bulk.js'; import * as ep___admin_emoji_add from './endpoints/admin/emoji/add.js'; -import * as ep___admin_emoji_addDraft from './endpoints/admin/emoji/add-draft.js'; +import * as ep___admin_emoji_addRequest from './endpoints/admin/emoji/add-request.js'; import * as ep___admin_emoji_copy from './endpoints/admin/emoji/copy.js'; import * as ep___admin_emoji_deleteBulk from './endpoints/admin/emoji/delete-bulk.js'; import * as ep___admin_emoji_delete from './endpoints/admin/emoji/delete.js'; import * as ep___admin_emoji_importZip from './endpoints/admin/emoji/import-zip.js'; import * as ep___admin_emoji_listRemote from './endpoints/admin/emoji/list-remote.js'; import * as ep___admin_emoji_list from './endpoints/admin/emoji/list.js'; -import * as ep___admin_emoji_listDraft from './endpoints/admin/emoji/list-draft.js'; +import * as ep___admin_emoji_listRequest from './endpoints/admin/emoji/list-request.js'; import * as ep___admin_emoji_removeAliasesBulk from './endpoints/admin/emoji/remove-aliases-bulk.js'; import * as ep___admin_emoji_setAliasesBulk from './endpoints/admin/emoji/set-aliases-bulk.js'; import * as ep___admin_emoji_setCategoryBulk from './endpoints/admin/emoji/set-category-bulk.js'; import * as ep___admin_emoji_setLicenseBulk from './endpoints/admin/emoji/set-license-bulk.js'; import * as ep___admin_emoji_update from './endpoints/admin/emoji/update.js'; -import * as ep___admin_emoji_updateDraft from './endpoints/admin/emoji/update-draft.js'; +import * as ep___admin_emoji_updateRequest from './endpoints/admin/emoji/update-request.js'; import * as ep___admin_federation_deleteAllFiles from './endpoints/admin/federation/delete-all-files.js'; import * as ep___admin_federation_refreshRemoteInstanceMetadata from './endpoints/admin/federation/refresh-remote-instance-metadata.js'; import * as ep___admin_federation_removeAllFollowing from './endpoints/admin/federation/remove-all-following.js'; @@ -251,7 +251,7 @@ import * as ep___invite_list from './endpoints/invite/list.js'; import * as ep___invite_limit from './endpoints/invite/limit.js'; import * as ep___meta from './endpoints/meta.js'; import * as ep___emojis from './endpoints/emojis.js'; -import * as ep___emojiDrafts from './endpoints/emoji-drafts.js'; +import * as ep___emojiRequests from './endpoints/emoji-requests.js'; import * as ep___emoji from './endpoints/emoji.js'; import * as ep___miauth_genToken from './endpoints/miauth/gen-token.js'; import * as ep___mute_create from './endpoints/mute/create.js'; @@ -390,20 +390,20 @@ const $admin_drive_files: Provider = { provide: 'ep:admin/drive/files', useClass const $admin_drive_showFile: Provider = { provide: 'ep:admin/drive/show-file', useClass: ep___admin_drive_showFile.default }; const $admin_emoji_addAliasesBulk: Provider = { provide: 'ep:admin/emoji/add-aliases-bulk', useClass: ep___admin_emoji_addAliasesBulk.default }; const $admin_emoji_add: Provider = { provide: 'ep:admin/emoji/add', useClass: ep___admin_emoji_add.default }; -const $admin_emoji_addDraft: Provider = { provide: 'ep:admin/emoji/add-draft', useClass: ep___admin_emoji_addDraft.default }; +const $admin_emoji_addRequest: Provider = { provide: 'ep:admin/emoji/add-request', useClass: ep___admin_emoji_addRequest.default }; const $admin_emoji_copy: Provider = { provide: 'ep:admin/emoji/copy', useClass: ep___admin_emoji_copy.default }; const $admin_emoji_deleteBulk: Provider = { provide: 'ep:admin/emoji/delete-bulk', useClass: ep___admin_emoji_deleteBulk.default }; const $admin_emoji_delete: Provider = { provide: 'ep:admin/emoji/delete', useClass: ep___admin_emoji_delete.default }; const $admin_emoji_importZip: Provider = { provide: 'ep:admin/emoji/import-zip', useClass: ep___admin_emoji_importZip.default }; const $admin_emoji_listRemote: Provider = { provide: 'ep:admin/emoji/list-remote', useClass: ep___admin_emoji_listRemote.default }; const $admin_emoji_list: Provider = { provide: 'ep:admin/emoji/list', useClass: ep___admin_emoji_list.default }; -const $admin_emoji_listDraft: Provider = { provide: 'ep:admin/emoji/list-draft', useClass: ep___admin_emoji_listDraft.default }; +const $admin_emoji_listRequest: Provider = { provide: 'ep:admin/emoji/list-request', useClass: ep___admin_emoji_listRequest.default }; const $admin_emoji_removeAliasesBulk: Provider = { provide: 'ep:admin/emoji/remove-aliases-bulk', useClass: ep___admin_emoji_removeAliasesBulk.default }; const $admin_emoji_setAliasesBulk: Provider = { provide: 'ep:admin/emoji/set-aliases-bulk', useClass: ep___admin_emoji_setAliasesBulk.default }; const $admin_emoji_setCategoryBulk: Provider = { provide: 'ep:admin/emoji/set-category-bulk', useClass: ep___admin_emoji_setCategoryBulk.default }; const $admin_emoji_setLicenseBulk: Provider = { provide: 'ep:admin/emoji/set-license-bulk', useClass: ep___admin_emoji_setLicenseBulk.default }; const $admin_emoji_update: Provider = { provide: 'ep:admin/emoji/update', useClass: ep___admin_emoji_update.default }; -const $admin_emoji_updateDraft: Provider = { provide: 'ep:admin/emoji/update-draft', useClass: ep___admin_emoji_updateDraft.default }; +const $admin_emoji_updateRequest: Provider = { provide: 'ep:admin/emoji/update-request', useClass: ep___admin_emoji_updateRequest.default }; const $admin_federation_deleteAllFiles: Provider = { provide: 'ep:admin/federation/delete-all-files', useClass: ep___admin_federation_deleteAllFiles.default }; const $admin_federation_refreshRemoteInstanceMetadata: Provider = { provide: 'ep:admin/federation/refresh-remote-instance-metadata', useClass: ep___admin_federation_refreshRemoteInstanceMetadata.default }; const $admin_federation_removeAllFollowing: Provider = { provide: 'ep:admin/federation/remove-all-following', useClass: ep___admin_federation_removeAllFollowing.default }; @@ -612,7 +612,7 @@ const $invite_list: Provider = { provide: 'ep:invite/list', useClass: ep___invit const $invite_limit: Provider = { provide: 'ep:invite/limit', useClass: ep___invite_limit.default }; const $meta: Provider = { provide: 'ep:meta', useClass: ep___meta.default }; const $emojis: Provider = { provide: 'ep:emojis', useClass: ep___emojis.default }; -const $emoji_drafts: Provider = { provide: 'ep:emoji-drafts', useClass: ep___emojiDrafts.default }; +const $emoji_requests: Provider = { provide: 'ep:emoji-requests', useClass: ep___emojiRequests.default }; const $emoji: Provider = { provide: 'ep:emoji', useClass: ep___emoji.default }; const $miauth_genToken: Provider = { provide: 'ep:miauth/gen-token', useClass: ep___miauth_genToken.default }; const $mute_create: Provider = { provide: 'ep:mute/create', useClass: ep___mute_create.default }; @@ -755,20 +755,20 @@ const $retention: Provider = { provide: 'ep:retention', useClass: ep___retention $admin_drive_showFile, $admin_emoji_addAliasesBulk, $admin_emoji_add, - $admin_emoji_addDraft, + $admin_emoji_addRequest, $admin_emoji_copy, $admin_emoji_deleteBulk, $admin_emoji_delete, $admin_emoji_importZip, $admin_emoji_listRemote, $admin_emoji_list, - $admin_emoji_listDraft, + $admin_emoji_listRequest, $admin_emoji_removeAliasesBulk, $admin_emoji_setAliasesBulk, $admin_emoji_setCategoryBulk, $admin_emoji_setLicenseBulk, $admin_emoji_update, - $admin_emoji_updateDraft, + $admin_emoji_updateRequest, $admin_federation_deleteAllFiles, $admin_federation_refreshRemoteInstanceMetadata, $admin_federation_removeAllFollowing, @@ -977,7 +977,7 @@ const $retention: Provider = { provide: 'ep:retention', useClass: ep___retention $invite_limit, $meta, $emojis, - $emoji_drafts, + $emoji_requests, $emoji, $miauth_genToken, $mute_create, @@ -1114,20 +1114,20 @@ const $retention: Provider = { provide: 'ep:retention', useClass: ep___retention $admin_drive_showFile, $admin_emoji_addAliasesBulk, $admin_emoji_add, - $admin_emoji_addDraft, + $admin_emoji_addRequest, $admin_emoji_copy, $admin_emoji_deleteBulk, $admin_emoji_delete, $admin_emoji_importZip, $admin_emoji_listRemote, $admin_emoji_list, - $admin_emoji_listDraft, + $admin_emoji_listRequest, $admin_emoji_removeAliasesBulk, $admin_emoji_setAliasesBulk, $admin_emoji_setCategoryBulk, $admin_emoji_setLicenseBulk, $admin_emoji_update, - $admin_emoji_updateDraft, + $admin_emoji_updateRequest, $admin_federation_deleteAllFiles, $admin_federation_refreshRemoteInstanceMetadata, $admin_federation_removeAllFollowing, @@ -1336,7 +1336,7 @@ const $retention: Provider = { provide: 'ep:retention', useClass: ep___retention $invite_limit, $meta, $emojis, - $emoji_drafts, + $emoji_requests, $emoji, $miauth_genToken, $mute_create, diff --git a/packages/backend/src/server/api/endpoints.ts b/packages/backend/src/server/api/endpoints.ts index 37f60cf210..74df9a959a 100644 --- a/packages/backend/src/server/api/endpoints.ts +++ b/packages/backend/src/server/api/endpoints.ts @@ -29,20 +29,20 @@ import * as ep___admin_drive_files from './endpoints/admin/drive/files.js'; import * as ep___admin_drive_showFile from './endpoints/admin/drive/show-file.js'; import * as ep___admin_emoji_addAliasesBulk from './endpoints/admin/emoji/add-aliases-bulk.js'; import * as ep___admin_emoji_add from './endpoints/admin/emoji/add.js'; -import * as ep___admin_emoji_addDraft from './endpoints/admin/emoji/add-draft.js'; +import * as ep___admin_emoji_addRequest from './endpoints/admin/emoji/add-request.js'; import * as ep___admin_emoji_copy from './endpoints/admin/emoji/copy.js'; import * as ep___admin_emoji_deleteBulk from './endpoints/admin/emoji/delete-bulk.js'; import * as ep___admin_emoji_delete from './endpoints/admin/emoji/delete.js'; import * as ep___admin_emoji_importZip from './endpoints/admin/emoji/import-zip.js'; import * as ep___admin_emoji_listRemote from './endpoints/admin/emoji/list-remote.js'; import * as ep___admin_emoji_list from './endpoints/admin/emoji/list.js'; -import * as ep___admin_emoji_listDraft from './endpoints/admin/emoji/list-draft.js'; +import * as ep___admin_emoji_listRequest from './endpoints/admin/emoji/list-request.js'; import * as ep___admin_emoji_removeAliasesBulk from './endpoints/admin/emoji/remove-aliases-bulk.js'; import * as ep___admin_emoji_setAliasesBulk from './endpoints/admin/emoji/set-aliases-bulk.js'; import * as ep___admin_emoji_setCategoryBulk from './endpoints/admin/emoji/set-category-bulk.js'; import * as ep___admin_emoji_setLicenseBulk from './endpoints/admin/emoji/set-license-bulk.js'; import * as ep___admin_emoji_update from './endpoints/admin/emoji/update.js'; -import * as ep___admin_emoji_updateDraft from './endpoints/admin/emoji/update-draft.js'; +import * as ep___admin_emoji_updateRequest from './endpoints/admin/emoji/update-request.js'; import * as ep___admin_federation_deleteAllFiles from './endpoints/admin/federation/delete-all-files.js'; import * as ep___admin_federation_refreshRemoteInstanceMetadata from './endpoints/admin/federation/refresh-remote-instance-metadata.js'; import * as ep___admin_federation_removeAllFollowing from './endpoints/admin/federation/remove-all-following.js'; @@ -251,7 +251,7 @@ import * as ep___invite_list from './endpoints/invite/list.js'; import * as ep___invite_limit from './endpoints/invite/limit.js'; import * as ep___meta from './endpoints/meta.js'; import * as ep___emojis from './endpoints/emojis.js'; -import * as ep___emojiDrafts from './endpoints/emoji-drafts.js'; +import * as ep___emojiRequests from './endpoints/emoji-requests.js'; import * as ep___emoji from './endpoints/emoji.js'; import * as ep___miauth_genToken from './endpoints/miauth/gen-token.js'; import * as ep___mute_create from './endpoints/mute/create.js'; @@ -388,20 +388,20 @@ const eps = [ ['admin/drive/show-file', ep___admin_drive_showFile], ['admin/emoji/add-aliases-bulk', ep___admin_emoji_addAliasesBulk], ['admin/emoji/add', ep___admin_emoji_add], - ['admin/emoji/add-draft', ep___admin_emoji_addDraft], + ['admin/emoji/add-request', ep___admin_emoji_addRequest], ['admin/emoji/copy', ep___admin_emoji_copy], ['admin/emoji/delete-bulk', ep___admin_emoji_deleteBulk], ['admin/emoji/delete', ep___admin_emoji_delete], ['admin/emoji/import-zip', ep___admin_emoji_importZip], ['admin/emoji/list-remote', ep___admin_emoji_listRemote], - ['admin/emoji/list-draft', ep___admin_emoji_listDraft], ['admin/emoji/list', ep___admin_emoji_list], + ['admin/emoji/list-request', ep___admin_emoji_listRequest], ['admin/emoji/remove-aliases-bulk', ep___admin_emoji_removeAliasesBulk], ['admin/emoji/set-aliases-bulk', ep___admin_emoji_setAliasesBulk], ['admin/emoji/set-category-bulk', ep___admin_emoji_setCategoryBulk], ['admin/emoji/set-license-bulk', ep___admin_emoji_setLicenseBulk], ['admin/emoji/update', ep___admin_emoji_update], - ['admin/emoji/update-draft', ep___admin_emoji_updateDraft], + ['admin/emoji/update-request', ep___admin_emoji_updateRequest], ['admin/federation/delete-all-files', ep___admin_federation_deleteAllFiles], ['admin/federation/refresh-remote-instance-metadata', ep___admin_federation_refreshRemoteInstanceMetadata], ['admin/federation/remove-all-following', ep___admin_federation_removeAllFollowing], @@ -610,7 +610,7 @@ const eps = [ ['invite/limit', ep___invite_limit], ['meta', ep___meta], ['emojis', ep___emojis], - ['emoji-drafts', ep___emojiDrafts], + ['emoji-requests', ep___emojiRequests], ['emoji', ep___emoji], ['miauth/gen-token', ep___miauth_genToken], ['mute/create', ep___mute_create], diff --git a/packages/backend/src/server/api/endpoints/admin/emoji/add-draft.ts b/packages/backend/src/server/api/endpoints/admin/emoji/add-request.ts similarity index 90% rename from packages/backend/src/server/api/endpoints/admin/emoji/add-draft.ts rename to packages/backend/src/server/api/endpoints/admin/emoji/add-request.ts index af85b2c10a..50ffb89b06 100644 --- a/packages/backend/src/server/api/endpoints/admin/emoji/add-draft.ts +++ b/packages/backend/src/server/api/endpoints/admin/emoji/add-request.ts @@ -61,14 +61,14 @@ export default class extends Endpoint { ) { super(meta, paramDef, async (ps, me) => { const isDuplicate = await this.customEmojiService.checkDuplicate(ps.name); - const isDraftDuplicate = await this.customEmojiService.checkDraftDuplicate(ps.name); + const isRequestDuplicate = await this.customEmojiService.checkRequestDuplicate(ps.name); - if (isDuplicate || isDraftDuplicate) throw new ApiError(meta.errors.duplicateName); + if (isDuplicate || isRequestDuplicate) throw new ApiError(meta.errors.duplicateName); const driveFile = await this.driveFilesRepository.findOneBy({ id: ps.fileId }); if (driveFile == null) throw new ApiError(meta.errors.noSuchFile); - const emoji = await this.customEmojiService.draft({ + const emoji = await this.customEmojiService.Request({ driveFile, name: ps.name, category: ps.category ?? null, diff --git a/packages/backend/src/server/api/endpoints/admin/emoji/delete.ts b/packages/backend/src/server/api/endpoints/admin/emoji/delete.ts index b3ec350272..9711db5a11 100644 --- a/packages/backend/src/server/api/endpoints/admin/emoji/delete.ts +++ b/packages/backend/src/server/api/endpoints/admin/emoji/delete.ts @@ -37,12 +37,12 @@ export default class extends Endpoint { // eslint- ) { super(meta, paramDef, async (ps, me) => { const emoji = await this.customEmojiService.getEmojiById(ps.id); - const draftEmoji = await this.customEmojiService.getEmojiDraftById(ps.id); + const RequestEmoji = await this.customEmojiService.getEmojiRequestById(ps.id); if (emoji != null) { await this.customEmojiService.delete(ps.id, me); } - if (draftEmoji != null) { - await this.customEmojiService.draftDelete(ps.id); + if (RequestEmoji != null) { + await this.customEmojiService.RequestDelete(ps.id); } }); } diff --git a/packages/backend/src/server/api/endpoints/admin/emoji/list-draft.ts b/packages/backend/src/server/api/endpoints/admin/emoji/list-request.ts similarity index 79% rename from packages/backend/src/server/api/endpoints/admin/emoji/list-draft.ts rename to packages/backend/src/server/api/endpoints/admin/emoji/list-request.ts index 95dea00426..f5faca972f 100644 --- a/packages/backend/src/server/api/endpoints/admin/emoji/list-draft.ts +++ b/packages/backend/src/server/api/endpoints/admin/emoji/list-request.ts @@ -5,11 +5,11 @@ import { Inject, Injectable } from '@nestjs/common'; import { Endpoint } from '@/server/api/endpoint-base.js'; -import type { EmojiDraftsRepository } from '@/models/_.js'; -import type { MiEmojiDraft } from '@/models/EmojiDraft.js'; +import type { EmojiRequestsRepository } from '@/models/_.js'; +import type { MiEmojiRequest } from '@/models/EmojiRequest.js'; import { QueryService } from '@/core/QueryService.js'; import { DI } from '@/di-symbols.js'; -import { EmojiDraftsEntityService } from '@/core/entities/EmojiDraftsEntityService.js'; +import { EmojiRequestsEntityService } from '@/core/entities/EmojiRequestsEntityService.js'; //import { sqlLikeEscape } from '@/misc/sql-like-escape.js'; export const meta = { @@ -69,16 +69,16 @@ export const paramDef = { @Injectable() export default class extends Endpoint { // eslint-disable-line import/no-default-export constructor( - @Inject(DI.emojiDraftsRepository) - private emojiDraftsRepository: EmojiDraftsRepository, + @Inject(DI.emojiRequestsRepository) + private emojiRequestsRepository: EmojiRequestsRepository, - private emojiDraftsEntityService: EmojiDraftsEntityService, + private emojiRequestsEntityService: EmojiRequestsEntityService, private queryService: QueryService, ) { super(meta, paramDef, async (ps, me) => { - const q = this.queryService.makePaginationQuery(this.emojiDraftsRepository.createQueryBuilder('emoji'), ps.sinceId, ps.untilId); + const q = this.queryService.makePaginationQuery(this.emojiRequestsRepository.createQueryBuilder('emoji'), ps.sinceId, ps.untilId); - let emojis: MiEmojiDraft[]; + let emojis: MiEmojiRequest[]; if (ps.query) { //q.andWhere('emoji.name ILIKE :q', { q: `%${ sqlLikeEscape(ps.query) }%` }); @@ -102,7 +102,7 @@ export default class extends Endpoint { // eslint- emojis = await q.limit(ps.limit).getMany(); } - return this.emojiDraftsEntityService.packDetailedMany(emojis); + return this.emojiRequestsEntityService.packDetailedMany(emojis); }); } } diff --git a/packages/backend/src/server/api/endpoints/admin/emoji/update-draft.ts b/packages/backend/src/server/api/endpoints/admin/emoji/update-request.ts similarity index 89% rename from packages/backend/src/server/api/endpoints/admin/emoji/update-draft.ts rename to packages/backend/src/server/api/endpoints/admin/emoji/update-request.ts index 79eee1b019..98e50389cc 100644 --- a/packages/backend/src/server/api/endpoints/admin/emoji/update-draft.ts +++ b/packages/backend/src/server/api/endpoints/admin/emoji/update-request.ts @@ -56,7 +56,7 @@ export const paramDef = { roleIdsThatCanBeUsedThisEmojiAsReaction: { type: 'array', items: { type: 'string', } }, - draft: { type: 'boolean' }, + Request: { type: 'boolean' }, }, required: ['id', 'name', 'aliases'], } as const; @@ -72,22 +72,22 @@ export default class extends Endpoint { // eslint- ) { super(meta, paramDef, async (ps, me) => { let driveFile; - const isDraft = !!ps.draft; + const isRequest = !!ps.Request; if (ps.fileId) { driveFile = await this.driveFilesRepository.findOneBy({ id: ps.fileId }); if (driveFile == null) throw new ApiError(meta.errors.noSuchFile); } - const emoji = await this.customEmojiService.getEmojiDraftById(ps.id); + const emoji = await this.customEmojiService.getEmojiRequestById(ps.id); if (emoji != null) { if (ps.name !== emoji.name) { - const isDuplicate = await this.customEmojiService.checkDraftDuplicate(ps.name); + const isDuplicate = await this.customEmojiService.checkRequestDuplicate(ps.name); if (isDuplicate) throw new ApiError(meta.errors.sameNameEmojiExists); } } else { throw new ApiError(meta.errors.noSuchEmoji); } - if (!isDraft) { + if (!isRequest) { const file = await this.driveFileEntityService.getFromUrl(emoji.originalUrl); if (file === null) throw new ApiError(meta.errors.noSuchFile); await this.customEmojiService.add({ @@ -101,9 +101,9 @@ export default class extends Endpoint { // eslint- localOnly: ps.localOnly ?? false, roleIdsThatCanBeUsedThisEmojiAsReaction: [], }, me); - await this.customEmojiService.draftDelete(ps.id); + await this.customEmojiService.RequestDelete(ps.id); } else { - await this.customEmojiService.draftUpdate(ps.id, { + await this.customEmojiService.RequestUpdate(ps.id, { name: ps.name, category: ps.category ?? null, aliases: ps.aliases ?? [], diff --git a/packages/backend/src/server/api/endpoints/admin/emoji/update.ts b/packages/backend/src/server/api/endpoints/admin/emoji/update.ts index f996560ce1..7f7dc774d5 100644 --- a/packages/backend/src/server/api/endpoints/admin/emoji/update.ts +++ b/packages/backend/src/server/api/endpoints/admin/emoji/update.ts @@ -7,7 +7,7 @@ import { Inject, Injectable } from '@nestjs/common'; import { Endpoint } from '@/server/api/endpoint-base.js'; import { DriveFileEntityService } from '@/core/entities/DriveFileEntityService.js'; import { CustomEmojiService } from '@/core/CustomEmojiService.js'; -import type { DriveFilesRepository, EmojiDraftsRepository } from '@/models/_.js'; +import type { DriveFilesRepository } from '@/models/_.js'; import { DI } from '@/di-symbols.js'; import { ApiError } from '../../../error.js'; @@ -56,7 +56,7 @@ export const paramDef = { roleIdsThatCanBeUsedThisEmojiAsReaction: { type: 'array', items: { type: 'string', } }, - draft: { type: 'boolean' }, + Request: { type: 'boolean' }, }, required: ['id', 'name', 'aliases'], } as const; @@ -72,7 +72,7 @@ export default class extends Endpoint { // eslint- ) { super(meta, paramDef, async (ps, me) => { let driveFile; - const isDraft = !!ps.draft; + const isRequest = !!ps.Request; if (ps.fileId) { driveFile = await this.driveFilesRepository.findOneBy({ id: ps.fileId }); if (driveFile == null) throw new ApiError(meta.errors.noSuchFile); @@ -87,7 +87,7 @@ export default class extends Endpoint { // eslint- throw new ApiError(meta.errors.noSuchEmoji); } - if (!isDraft) { + if (!isRequest) { await this.customEmojiService.update(ps.id, { driveFile, name: ps.name, @@ -101,7 +101,7 @@ export default class extends Endpoint { // eslint- } else { const file = await this.driveFileEntityService.getFromUrl(emoji.originalUrl); if (file === null) throw new ApiError(meta.errors.noSuchFile); - await this.customEmojiService.draft({ + await this.customEmojiService.Request({ driveFile: file, name: ps.name, category: ps.category ?? null, diff --git a/packages/backend/src/server/api/endpoints/emoji-drafts.ts b/packages/backend/src/server/api/endpoints/emoji-requests.ts similarity index 66% rename from packages/backend/src/server/api/endpoints/emoji-drafts.ts rename to packages/backend/src/server/api/endpoints/emoji-requests.ts index 13afee2a08..63ca88e93e 100644 --- a/packages/backend/src/server/api/endpoints/emoji-drafts.ts +++ b/packages/backend/src/server/api/endpoints/emoji-requests.ts @@ -3,11 +3,10 @@ * SPDX-License-Identifier: AGPL-3.0-only */ -import { IsNull } from 'typeorm'; import { Inject, Injectable } from '@nestjs/common'; -import type { EmojiDraftsRepository } from '@/models/_.js'; +import type { EmojiRequestsRepository } from '@/models/_.js'; import { Endpoint } from '@/server/api/endpoint-base.js'; -import { EmojiDraftsEntityService } from '@/core/entities/EmojiDraftsEntityService.js'; +import { EmojiRequestsEntityService } from '@/core/entities/EmojiRequestsEntityService.js'; import { DI } from '@/di-symbols.js'; export const meta = { @@ -27,7 +26,7 @@ export const meta = { items: { type: 'object', optional: false, nullable: false, - ref: 'EmojiDraftSimple', + ref: 'EmojiRequestSimple', }, }, }, @@ -44,13 +43,13 @@ export const paramDef = { @Injectable() export default class extends Endpoint { // eslint-disable-line import/no-default-export constructor( - @Inject(DI.emojiDraftsRepository) - private emojiDraftsRepository: EmojiDraftsRepository, + @Inject(DI.emojiRequestsRepository) + private emojiRequestsRepository: EmojiRequestsRepository, - private emojiDraftsEntityService: EmojiDraftsEntityService, + private emojiRequestsEntityService: EmojiRequestsEntityService, ) { super(meta, paramDef, async () => { - const emojis = await this.emojiDraftsRepository.find({ + const emojis = await this.emojiRequestsRepository.find({ order: { category: 'ASC', name: 'ASC', @@ -58,7 +57,7 @@ export default class extends Endpoint { // eslint- }); return { - emojis: await this.emojiDraftsEntityService.packSimpleMany(emojis), + emojis: await this.emojiRequestsEntityService.packSimpleMany(emojis), }; }); } diff --git a/packages/frontend/src/components/MkCustomEmojiEditLocal.vue b/packages/frontend/src/components/MkCustomEmojiEditLocal.vue index 7112a38430..7060f2080b 100644 --- a/packages/frontend/src/components/MkCustomEmojiEditLocal.vue +++ b/packages/frontend/src/components/MkCustomEmojiEditLocal.vue @@ -20,10 +20,10 @@