不明なリアクションのフォールバックに star を使うようにするオプション

This commit is contained in:
syuilo 2019-03-18 01:03:35 +09:00
parent 810ed50976
commit 08c176e549
No known key found for this signature in database
GPG Key ID: BDC4C49D06AB9D69
10 changed files with 26 additions and 16 deletions

View File

@ -1239,6 +1239,7 @@ admin/views/instance.vue:
disable-global-timeline: "グローバルタイムラインを無効にする" disable-global-timeline: "グローバルタイムラインを無効にする"
disabling-timelines-info: "これらのタイムラインを無効にしても、管理者およびモデレーターは引き続き利用できます。" disabling-timelines-info: "これらのタイムラインを無効にしても、管理者およびモデレーターは引き続き利用できます。"
enable-emoji-reaction: "リアクションに絵文字を使えるようにする" enable-emoji-reaction: "リアクションに絵文字を使えるようにする"
use-star-for-reaction-fallback: "不明なリアクションのフォールバックに star を使う"
invite: "招待" invite: "招待"
save: "保存" save: "保存"
saved: "保存しました" saved: "保存しました"

View File

@ -26,6 +26,7 @@
<ui-switch v-model="disableGlobalTimeline">{{ $t('disable-global-timeline') }}</ui-switch> <ui-switch v-model="disableGlobalTimeline">{{ $t('disable-global-timeline') }}</ui-switch>
<ui-info>{{ $t('disabling-timelines-info') }}</ui-info> <ui-info>{{ $t('disabling-timelines-info') }}</ui-info>
<ui-switch v-model="enableEmojiReaction">{{ $t('enable-emoji-reaction') }}</ui-switch> <ui-switch v-model="enableEmojiReaction">{{ $t('enable-emoji-reaction') }}</ui-switch>
<ui-switch v-model="useStarForReactionFallback">{{ $t('use-star-for-reaction-fallback') }}</ui-switch>
</section> </section>
<section class="fit-bottom"> <section class="fit-bottom">
<header><fa icon="cloud"/> {{ $t('drive-config') }}</header> <header><fa icon="cloud"/> {{ $t('drive-config') }}</header>
@ -157,6 +158,7 @@ export default Vue.extend({
disableLocalTimeline: false, disableLocalTimeline: false,
disableGlobalTimeline: false, disableGlobalTimeline: false,
enableEmojiReaction: true, enableEmojiReaction: true,
useStarForReactionFallback: false,
mascotImageUrl: null, mascotImageUrl: null,
bannerUrl: null, bannerUrl: null,
errorImageUrl: null, errorImageUrl: null,
@ -209,6 +211,7 @@ export default Vue.extend({
this.disableLocalTimeline = meta.disableLocalTimeline; this.disableLocalTimeline = meta.disableLocalTimeline;
this.disableGlobalTimeline = meta.disableGlobalTimeline; this.disableGlobalTimeline = meta.disableGlobalTimeline;
this.enableEmojiReaction = meta.enableEmojiReaction; this.enableEmojiReaction = meta.enableEmojiReaction;
this.useStarForReactionFallback = meta.useStarForReactionFallback;
this.mascotImageUrl = meta.mascotImageUrl; this.mascotImageUrl = meta.mascotImageUrl;
this.bannerUrl = meta.bannerUrl; this.bannerUrl = meta.bannerUrl;
this.errorImageUrl = meta.errorImageUrl; this.errorImageUrl = meta.errorImageUrl;
@ -271,6 +274,7 @@ export default Vue.extend({
disableLocalTimeline: this.disableLocalTimeline, disableLocalTimeline: this.disableLocalTimeline,
disableGlobalTimeline: this.disableGlobalTimeline, disableGlobalTimeline: this.disableGlobalTimeline,
enableEmojiReaction: this.enableEmojiReaction, enableEmojiReaction: this.enableEmojiReaction,
useStarForReactionFallback: this.useStarForReactionFallback,
mascotImageUrl: this.mascotImageUrl, mascotImageUrl: this.mascotImageUrl,
bannerUrl: this.bannerUrl, bannerUrl: this.bannerUrl,
errorImageUrl: this.errorImageUrl, errorImageUrl: this.errorImageUrl,

View File

@ -31,6 +31,7 @@ export default Vue.extend({
case 'confused': return '😥'; case 'confused': return '😥';
case 'rip': return '😇'; case 'rip': return '😇';
case 'pudding': return (this.$store.getters.isSignedIn && this.$store.state.settings.iLikeSushi) ? '🍣' : '🍮'; case 'pudding': return (this.$store.getters.isSignedIn && this.$store.state.settings.iLikeSushi) ? '🍣' : '🍮';
case 'star': return '⭐';
default: return this.reaction; default: return this.reaction;
} }
}, },

View File

@ -10,6 +10,7 @@ export default function(reaction: string): string {
case 'confused': return '😥'; case 'confused': return '😥';
case 'rip': return '😇'; case 'rip': return '😇';
case 'pudding': return '🍮'; case 'pudding': return '🍮';
default: return ''; case 'star': return '⭐';
default: return reaction;
} }
} }

View File

@ -1,5 +1,6 @@
import Emoji from '../models/emoji'; import Emoji from '../models/emoji';
import { emojiRegex } from './emoji-regex'; import { emojiRegex } from './emoji-regex';
import fetchMeta from './fetch-meta';
const basic10: Record<string, string> = { const basic10: Record<string, string> = {
'👍': 'like', '👍': 'like',
@ -15,7 +16,8 @@ const basic10: Record<string, string> = {
}; };
export async function getFallbackReaction(): Promise<string> { export async function getFallbackReaction(): Promise<string> {
return 'like'; const meta = await fetchMeta();
return meta.useStarForReactionFallback ? 'star' : 'like';
} }
export async function toDbReaction(reaction: string, enableEmoji = true): Promise<string> { export async function toDbReaction(reaction: string, enableEmoji = true): Promise<string> {

View File

@ -195,6 +195,7 @@ export type IMeta = {
disableLocalTimeline?: boolean; disableLocalTimeline?: boolean;
disableGlobalTimeline?: boolean; disableGlobalTimeline?: boolean;
enableEmojiReaction?: boolean; enableEmojiReaction?: boolean;
useStarForReactionFallback?: boolean;
hidedTags?: string[]; hidedTags?: string[];
mascotImageUrl?: string; mascotImageUrl?: string;
bannerUrl?: string; bannerUrl?: string;

View File

@ -20,19 +20,6 @@ export interface INoteReaction {
reaction: string; reaction: string;
} }
export const validateReaction = $.str.or([
'like',
'love',
'laugh',
'hmm',
'surprise',
'congrats',
'angry',
'confused',
'rip',
'pudding'
]);
/** /**
* Pack a reaction for API response * Pack a reaction for API response
*/ */

View File

@ -48,6 +48,13 @@ export const meta = {
} }
}, },
useStarForReactionFallback: {
validator: $.optional.nullable.bool,
desc: {
'ja-JP': '不明なリアクションのフォールバックに star リアクションを使うか'
}
},
hidedTags: { hidedTags: {
validator: $.optional.nullable.arr($.str), validator: $.optional.nullable.arr($.str),
desc: { desc: {
@ -362,6 +369,10 @@ export default define(meta, async (ps) => {
set.enableEmojiReaction = ps.enableEmojiReaction; set.enableEmojiReaction = ps.enableEmojiReaction;
} }
if (typeof ps.useStarForReactionFallback === 'boolean') {
set.useStarForReactionFallback = ps.useStarForReactionFallback;
}
if (Array.isArray(ps.hidedTags)) { if (Array.isArray(ps.hidedTags)) {
set.hidedTags = ps.hidedTags; set.hidedTags = ps.hidedTags;
} }

View File

@ -152,6 +152,7 @@ export default define(meta, async (ps, me) => {
} }
if (me && (me.isAdmin || me.isModerator)) { if (me && (me.isAdmin || me.isModerator)) {
response.useStarForReactionFallback = instance.useStarForReactionFallback;
response.hidedTags = instance.hidedTags; response.hidedTags = instance.hidedTags;
response.recaptchaSecretKey = instance.recaptchaSecretKey; response.recaptchaSecretKey = instance.recaptchaSecretKey;
response.proxyAccount = instance.proxyAccount; response.proxyAccount = instance.proxyAccount;

View File

@ -392,7 +392,8 @@ export const schemas = {
'angry', 'angry',
'confused', 'confused',
'rip', 'rip',
'pudding' 'pudding',
'star'
], ],
description: 'The reaction type.' description: 'The reaction type.'
}, },