feature: show license info for custom emoji
This commit is contained in:
parent
58430cc28b
commit
3144ab1e23
|
@ -131,6 +131,7 @@ import * as ep___drive_folders_show from "./endpoints/drive/folders/show.js";
|
||||||
import * as ep___drive_folders_update from "./endpoints/drive/folders/update.js";
|
import * as ep___drive_folders_update from "./endpoints/drive/folders/update.js";
|
||||||
import * as ep___drive_stream from "./endpoints/drive/stream.js";
|
import * as ep___drive_stream from "./endpoints/drive/stream.js";
|
||||||
import * as ep___emailAddress_available from "./endpoints/email-address/available.js";
|
import * as ep___emailAddress_available from "./endpoints/email-address/available.js";
|
||||||
|
import * as ep___emoji from './endpoints/emoji.js';
|
||||||
import * as ep___endpoint from "./endpoints/endpoint.js";
|
import * as ep___endpoint from "./endpoints/endpoint.js";
|
||||||
import * as ep___endpoints from "./endpoints/endpoints.js";
|
import * as ep___endpoints from "./endpoints/endpoints.js";
|
||||||
import * as ep___exportCustomEmojis from "./endpoints/export-custom-emojis.js";
|
import * as ep___exportCustomEmojis from "./endpoints/export-custom-emojis.js";
|
||||||
|
@ -471,6 +472,7 @@ const eps = [
|
||||||
["drive/folders/update", ep___drive_folders_update],
|
["drive/folders/update", ep___drive_folders_update],
|
||||||
["drive/stream", ep___drive_stream],
|
["drive/stream", ep___drive_stream],
|
||||||
["email-address/available", ep___emailAddress_available],
|
["email-address/available", ep___emailAddress_available],
|
||||||
|
['emoji', ep___emoji],
|
||||||
["endpoint", ep___endpoint],
|
["endpoint", ep___endpoint],
|
||||||
["endpoints", ep___endpoints],
|
["endpoints", ep___endpoints],
|
||||||
["export-custom-emojis", ep___exportCustomEmojis],
|
["export-custom-emojis", ep___exportCustomEmojis],
|
||||||
|
|
|
@ -0,0 +1,56 @@
|
||||||
|
import { IsNull } from 'typeorm';
|
||||||
|
import { Inject, Injectable } from '@nestjs/common';
|
||||||
|
import type { EmojisRepository } from '@/models/index.js';
|
||||||
|
import { Endpoint } from '@/server/api/endpoint-base.js';
|
||||||
|
import { EmojiEntityService } from '@/core/entities/EmojiEntityService.js';
|
||||||
|
import type { Config } from '@/config.js';
|
||||||
|
import { DI } from '@/di-symbols.js';
|
||||||
|
|
||||||
|
export const meta = {
|
||||||
|
tags: ['meta'],
|
||||||
|
|
||||||
|
requireCredential: false,
|
||||||
|
allowGet: true,
|
||||||
|
cacheSec: 3600,
|
||||||
|
|
||||||
|
res: {
|
||||||
|
type: 'object',
|
||||||
|
optional: false, nullable: false,
|
||||||
|
ref: 'EmojiDetailed',
|
||||||
|
},
|
||||||
|
} as const;
|
||||||
|
|
||||||
|
export const paramDef = {
|
||||||
|
type: 'object',
|
||||||
|
properties: {
|
||||||
|
name: {
|
||||||
|
type: 'string',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
required: ['name'],
|
||||||
|
} as const;
|
||||||
|
|
||||||
|
// eslint-disable-next-line import/no-default-export
|
||||||
|
@Injectable()
|
||||||
|
export default class extends Endpoint<typeof meta, typeof paramDef> {
|
||||||
|
constructor(
|
||||||
|
@Inject(DI.config)
|
||||||
|
private config: Config,
|
||||||
|
|
||||||
|
@Inject(DI.emojisRepository)
|
||||||
|
private emojisRepository: EmojisRepository,
|
||||||
|
|
||||||
|
private emojiEntityService: EmojiEntityService,
|
||||||
|
) {
|
||||||
|
super(meta, paramDef, async (ps, me) => {
|
||||||
|
const emoji = await this.emojisRepository.findOneOrFail({
|
||||||
|
where: {
|
||||||
|
name: ps.name,
|
||||||
|
host: IsNull(),
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
return this.emojiEntityService.packDetailed(emoji);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
|
@ -28,7 +28,18 @@ function menu(ev) {
|
||||||
action: () => {
|
action: () => {
|
||||||
copyToClipboard(`:${props.emoji.name}:`);
|
copyToClipboard(`:${props.emoji.name}:`);
|
||||||
os.success();
|
os.success();
|
||||||
}
|
},
|
||||||
|
}, {
|
||||||
|
text: i18n.ts.info,
|
||||||
|
icon: 'ti ti-info-circle',
|
||||||
|
action: () => {
|
||||||
|
os.apiGet('emoji', { name: props.emoji.name }).then(res => {
|
||||||
|
os.alert({
|
||||||
|
type: 'info',
|
||||||
|
text: `License: ${res.license}`,
|
||||||
|
});
|
||||||
|
});
|
||||||
|
},
|
||||||
}], ev.currentTarget ?? ev.target);
|
}], ev.currentTarget ?? ev.target);
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
Loading…
Reference in New Issue