feature: show license info for custom emoji

This commit is contained in:
syuilo 2023-03-17 20:24:47 +09:00 committed by Gitea
parent 58430cc28b
commit 3144ab1e23
3 changed files with 70 additions and 1 deletions

View File

@ -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_stream from "./endpoints/drive/stream.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___endpoints from "./endpoints/endpoints.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/stream", ep___drive_stream],
["email-address/available", ep___emailAddress_available],
['emoji', ep___emoji],
["endpoint", ep___endpoint],
["endpoints", ep___endpoints],
["export-custom-emojis", ep___exportCustomEmojis],

View File

@ -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);
});
}
}

View File

@ -28,7 +28,18 @@ function menu(ev) {
action: () => {
copyToClipboard(`:${props.emoji.name}:`);
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);
}
</script>