Skip to content
Snippets Groups Projects
Verified Commit 7ba85291 authored by Mar0xy's avatar Mar0xy
Browse files

fix: importing remote emojis with used name

Closes transfem-org/Sharkey#164
parent 04dbf7eb
No related branches found
No related tags found
No related merge requests found
......@@ -4,6 +4,7 @@
*/
import { Inject, Injectable } from '@nestjs/common';
import { IsNull } from 'typeorm';
import { Endpoint } from '@/server/api/endpoint-base.js';
import type { EmojisRepository } from '@/models/_.js';
import { IdService } from '@/core/IdService.js';
......@@ -26,6 +27,11 @@ export const meta = {
code: 'NO_SUCH_EMOJI',
id: 'e2785b66-dca3-4087-9cac-b93c541cc425',
},
duplicateName: {
message: 'Duplicate name.',
code: 'DUPLICATE_NAME',
id: 'f7a3462c-4e6e-4069-8421-b9bd4f4c3975',
},
},
res: {
......@@ -69,6 +75,9 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
throw new ApiError(meta.errors.noSuchEmoji);
}
const isDuplicate = await this.emojisRepository.findOneBy({ name: emoji.name, host: IsNull() } );
if (isDuplicate) throw new ApiError(meta.errors.duplicateName);
let driveFile: MiDriveFile;
try {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment