Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: 激しい動きを含むカスタム絵文字を手動で指定できるように #14

Draft
wants to merge 5 commits into
base: hanami
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions locales/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10328,6 +10328,18 @@ export interface Locale extends ILocale {
* いつでも花びらを降らせる
*/
"flowerEffect": string;
/**
* 激しい動きあり
*/
"hasMovement": string;
/**
* 激しい動きを含むカスタム絵文字のアニメーションだけを止める
*/
"stopAnimatingEmojisWithMovement": string;
/**
* 激しい動きを含むとモデレーターが判断したものだけ、アニメーションを停止します。その他の絵文字(動きがゆるいもの等)は通常通りアニメーションされます。絵文字のアニメーションを完全に停止させたい場合は、「アニメーション画像を再生しない」を利用してください。
*/
"stopAnimatingEmojisWithMovementDescription": string;
"_inDevelopment": {
/**
* この機能は開発中です
Expand Down
3 changes: 3 additions & 0 deletions locales/ja-JP.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2754,6 +2754,9 @@ _hana:
hanaModeShort: "はな"
hanaModeTutorialDescription: "はなみすきーの主要な独自機能として「はなモード」があります。はなモードを有効にするかどうかで、はなみすきーでのSNS体験は大きく変わってきます。以下に主な違いとおすすめのユースケースを挙げますので、どちらか選択して進んでください。"
flowerEffect: "いつでも花びらを降らせる"
hasMovement: "激しい動きあり"
stopAnimatingEmojisWithMovement: "激しい動きを含むカスタム絵文字のアニメーションだけを止める"
stopAnimatingEmojisWithMovementDescription: "激しい動きを含むとモデレーターが判断したものだけ、アニメーションを停止します。その他の絵文字(動きがゆるいもの等)は通常通りアニメーションされます。絵文字のアニメーションを完全に停止させたい場合は、「アニメーション画像を再生しない」を利用してください。"
_inDevelopment:
title: "この機能は開発中です"
description: "はなみすきーは新規機能盛りだくさんで鋭意開発中です!\nどんな機能が実装されるかはお楽しみ。"
Expand Down
11 changes: 11 additions & 0 deletions packages/backend/migration/1723367092501-EmojiHasMovement.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
export class EmojiHasMovement1723367092501 {
name = 'EmojiHasMovement1723367092501'

async up(queryRunner) {
await queryRunner.query(`ALTER TABLE "emoji" ADD "hasMovement" boolean NOT NULL DEFAULT false`);
}

async down(queryRunner) {
await queryRunner.query(`ALTER TABLE "emoji" DROP COLUMN "hasMovement"`);
}
}
4 changes: 4 additions & 0 deletions packages/backend/src/core/CustomEmojiService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ export class CustomEmojiService implements OnApplicationShutdown {
isSensitive: boolean;
localOnly: boolean;
roleIdsThatCanBeUsedThisEmojiAsReaction: MiRole['id'][];
hasMovement: boolean;
}, moderator?: MiUser): Promise<MiEmoji> {
const emoji = await this.emojisRepository.insertOne({
id: this.idService.gen(),
Expand All @@ -82,6 +83,7 @@ export class CustomEmojiService implements OnApplicationShutdown {
isSensitive: data.isSensitive,
localOnly: data.localOnly,
roleIdsThatCanBeUsedThisEmojiAsReaction: data.roleIdsThatCanBeUsedThisEmojiAsReaction,
hasMovement: data.hasMovement,
});

if (data.host == null) {
Expand Down Expand Up @@ -112,6 +114,7 @@ export class CustomEmojiService implements OnApplicationShutdown {
isSensitive?: boolean;
localOnly?: boolean;
roleIdsThatCanBeUsedThisEmojiAsReaction?: MiRole['id'][];
hasMovement?: boolean;
}, moderator?: MiUser): Promise<void> {
const emoji = await this.emojisRepository.findOneByOrFail({ id: id });
const sameNameEmoji = await this.emojisRepository.findOneBy({ name: data.name, host: IsNull() });
Expand All @@ -129,6 +132,7 @@ export class CustomEmojiService implements OnApplicationShutdown {
publicUrl: data.driveFile != null ? (data.driveFile.webpublicUrl ?? data.driveFile.url) : undefined,
type: data.driveFile != null ? (data.driveFile.webpublicType ?? data.driveFile.type) : undefined,
roleIdsThatCanBeUsedThisEmojiAsReaction: data.roleIdsThatCanBeUsedThisEmojiAsReaction ?? undefined,
hasMovement: data.hasMovement,
});

this.localEmojisCache.refresh();
Expand Down
4 changes: 4 additions & 0 deletions packages/backend/src/core/entities/EmojiEntityService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ export class EmojiEntityService {
localOnly: emoji.localOnly ? true : undefined,
isSensitive: emoji.isSensitive ? true : undefined,
roleIdsThatCanBeUsedThisEmojiAsReaction: emoji.roleIdsThatCanBeUsedThisEmojiAsReaction.length > 0 ? emoji.roleIdsThatCanBeUsedThisEmojiAsReaction : undefined,

hasMovement: emoji.hasMovement,
};
}

Expand Down Expand Up @@ -62,6 +64,8 @@ export class EmojiEntityService {
isSensitive: emoji.isSensitive,
localOnly: emoji.localOnly,
roleIdsThatCanBeUsedThisEmojiAsReaction: emoji.roleIdsThatCanBeUsedThisEmojiAsReaction,

hasMovement: emoji.hasMovement,
};
}

Expand Down
5 changes: 5 additions & 0 deletions packages/backend/src/models/Emoji.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,4 +81,9 @@ export class MiEmoji {
array: true, length: 128, default: '{}',
})
public roleIdsThatCanBeUsedThisEmojiAsReaction: string[];

@Column('boolean', {
default: false,
})
public hasMovement: boolean;
}
10 changes: 10 additions & 0 deletions packages/backend/src/models/json-schema/emoji.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,11 @@ export const packedEmojiSimpleSchema = {
format: 'id',
},
},

hasMovement: {
type: 'boolean',
optional: true, nullable: false,
},
},
} as const;

Expand Down Expand Up @@ -102,5 +107,10 @@ export const packedEmojiDetailedSchema = {
format: 'id',
},
},

hasMovement: {
type: 'boolean',
optional: true, nullable: false,
},
},
} as const;
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ export class ImportCustomEmojisProcessorService {
isSensitive: emojiInfo.isSensitive,
localOnly: emojiInfo.localOnly,
roleIdsThatCanBeUsedThisEmojiAsReaction: [],
hasMovement: emojiInfo.hasMovement,
});
}

Expand Down
2 changes: 2 additions & 0 deletions packages/backend/src/server/api/endpoints/admin/emoji/add.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ export const paramDef = {
roleIdsThatCanBeUsedThisEmojiAsReaction: { type: 'array', items: {
type: 'string',
} },
hasMovement: { type: 'boolean' },
},
required: ['name', 'fileId'],
} as const;
Expand Down Expand Up @@ -88,6 +89,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
isSensitive: ps.isSensitive ?? false,
localOnly: ps.localOnly ?? false,
roleIdsThatCanBeUsedThisEmojiAsReaction: ps.roleIdsThatCanBeUsedThisEmojiAsReaction ?? [],
hasMovement: ps.hasMovement ?? false,
}, me);

return this.emojiEntityService.packDetailed(emoji);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
isSensitive: emoji.isSensitive,
localOnly: emoji.localOnly,
roleIdsThatCanBeUsedThisEmojiAsReaction: emoji.roleIdsThatCanBeUsedThisEmojiAsReaction,
hasMovement: emoji.hasMovement,
}, me);

return this.emojiEntityService.packDetailed(addedEmoji);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ export const paramDef = {
roleIdsThatCanBeUsedThisEmojiAsReaction: { type: 'array', items: {
type: 'string',
} },
hasMovement: { type: 'boolean' },
},
anyOf: [
{ required: ['id'] },
Expand Down Expand Up @@ -103,6 +104,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
isSensitive: ps.isSensitive,
localOnly: ps.localOnly,
roleIdsThatCanBeUsedThisEmojiAsReaction: ps.roleIdsThatCanBeUsedThisEmojiAsReaction,
hasMovement: ps.hasMovement,
}, me);
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ SPDX-License-Identifier: AGPL-3.0-only
<template #key>{{ i18n.ts.localOnly }}</template>
<template #value>{{ emoji.localOnly ? i18n.ts.yes : i18n.ts.no }}</template>
</MkKeyValue>
<MkKeyValue>
<template #key>{{ i18n.ts._hana.hasMovement }}</template>
<template #value>{{ emoji.hasMovement ? i18n.ts.yes : i18n.ts.no }}</template>
</MkKeyValue>
<MkKeyValue>
<template #key>{{ i18n.ts.license }}</template>
<template #value><Mfm :text="emoji.license ?? i18n.ts.none"/></template>
Expand Down
10 changes: 9 additions & 1 deletion packages/frontend/src/components/global/MkCustomEmoji.vue
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ SPDX-License-Identifier: AGPL-3.0-only
import { computed, inject, ref } from 'vue';
import { getProxiedImageUrl, getStaticImageUrl } from '@/scripts/media-proxy.js';
import { defaultStore } from '@/store.js';
import { hanaStore } from '@/hana/store.js';
import { customEmojisMap } from '@/custom-emojis.js';
import * as os from '@/os.js';
import { misskeyApiGet } from '@/scripts/misskey-api.js';
Expand Down Expand Up @@ -63,6 +64,13 @@ const rawUrl = computed(() => {
return props.host ? `/emoji/${customEmojiName.value}@${props.host}.webp` : `/emoji/${customEmojiName.value}.webp`;
});

const shouldStopAnimatingByHanaHasMovement = computed(() => {
return (
hanaStore.reactiveState.stopAnimatingEmojisWithMovement.value &&
customEmojisMap.get(customEmojiName.value)?.hasMovement
);
});

const url = computed(() => {
if (rawUrl.value == null) return undefined;

Expand All @@ -75,7 +83,7 @@ const url = computed(() => {
false,
true,
);
return defaultStore.reactiveState.disableShowingAnimatedImages.value
return (defaultStore.reactiveState.disableShowingAnimatedImages.value || shouldStopAnimatingByHanaHasMovement.value)
? getStaticImageUrl(proxied)
: proxied;
});
Expand Down
4 changes: 4 additions & 0 deletions packages/frontend/src/hana/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,8 @@ export const hanaStore = markRaw(new Storage('hanaMain', {
where: 'device',
default: false,
},
stopAnimatingEmojisWithMovement: {
where: 'device',
default: true,
},
}));
3 changes: 3 additions & 0 deletions packages/frontend/src/pages/emoji-edit-dialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ SPDX-License-Identifier: AGPL-3.0-only
</MkFolder>
<MkSwitch v-model="isSensitive">isSensitive</MkSwitch>
<MkSwitch v-model="localOnly">{{ i18n.ts.localOnly }}</MkSwitch>
<MkSwitch v-model="hasMovement">{{ i18n.ts._hana.hasMovement }}</MkSwitch>
<MkButton v-if="emoji" danger @click="del()"><i class="ti ti-trash"></i> {{ i18n.ts.delete }}</MkButton>
</div>
</MkSpacer>
Expand Down Expand Up @@ -108,6 +109,7 @@ const localOnly = ref(props.emoji ? props.emoji.localOnly : false);
const roleIdsThatCanBeUsedThisEmojiAsReaction = ref(props.emoji ? props.emoji.roleIdsThatCanBeUsedThisEmojiAsReaction : []);
const rolesThatCanBeUsedThisEmojiAsReaction = ref<Misskey.entities.Role[]>([]);
const file = ref<Misskey.entities.DriveFile>();
const hasMovement = ref(props.emoji ? props.emoji.hasMovement : false);

watch(roleIdsThatCanBeUsedThisEmojiAsReaction, async () => {
rolesThatCanBeUsedThisEmojiAsReaction.value = (await Promise.all(roleIdsThatCanBeUsedThisEmojiAsReaction.value.map((id) => misskeyApi('admin/roles/show', { roleId: id }).catch(() => null)))).filter(x => x != null);
Expand Down Expand Up @@ -153,6 +155,7 @@ async function done() {
isSensitive: isSensitive.value,
localOnly: localOnly.value,
roleIdsThatCanBeUsedThisEmojiAsReaction: rolesThatCanBeUsedThisEmojiAsReaction.value.map(x => x.id),
hasMovement: hasMovement.value,
};

if (file.value) {
Expand Down
8 changes: 8 additions & 0 deletions packages/frontend/src/pages/settings/general.vue
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,12 @@ SPDX-License-Identifier: AGPL-3.0-only
<MkSwitch v-model="flowerEffect">{{ i18n.ts._hana.flowerEffect }}</MkSwitch>
<MkSwitch v-model="useNativeUIForVideoAudioPlayer">{{ i18n.ts.useNativeUIForVideoAudioPlayer }}</MkSwitch>
</div>
<div class="_gaps_s">
<MkSwitch v-model="stopAnimatingEmojisWithMovement">
<template #label>{{ i18n.ts._hana.stopAnimatingEmojisWithMovement }}</template>
<template #caption>{{ i18n.ts._hana.stopAnimatingEmojisWithMovementDescription }}</template>
</MkSwitch>
</div>
<div>
<MkRadios v-model="emojiStyle">
<template #label>{{ i18n.ts.emojiStyle }}</template>
Expand Down Expand Up @@ -328,6 +334,8 @@ const confirmWhenRevealingSensitiveMedia = computed(defaultStore.makeGetterSette
const contextMenu = computed(defaultStore.makeGetterSetter('contextMenu'));
const flowerEffect = computed(hanaStore.makeGetterSetter('flowerEffect'));

const stopAnimatingEmojisWithMovement = computed(hanaStore.makeGetterSetter('stopAnimatingEmojisWithMovement'));

watch(lang, () => {
miLocalStorage.setItem('lang', lang.value as string);
miLocalStorage.removeItem('locale');
Expand Down
4 changes: 4 additions & 0 deletions packages/misskey-js/src/autogen/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4662,6 +4662,7 @@ export type components = {
localOnly?: boolean;
isSensitive?: boolean;
roleIdsThatCanBeUsedThisEmojiAsReaction?: string[];
hasMovement?: boolean;
};
EmojiDetailed: {
/** Format: id */
Expand All @@ -4676,6 +4677,7 @@ export type components = {
isSensitive: boolean;
localOnly: boolean;
roleIdsThatCanBeUsedThisEmojiAsReaction: string[];
hasMovement?: boolean;
};
Flash: {
/**
Expand Down Expand Up @@ -6983,6 +6985,7 @@ export type operations = {
isSensitive?: boolean;
localOnly?: boolean;
roleIdsThatCanBeUsedThisEmojiAsReaction?: string[];
hasMovement?: boolean;
};
};
};
Expand Down Expand Up @@ -7613,6 +7616,7 @@ export type operations = {
isSensitive?: boolean;
localOnly?: boolean;
roleIdsThatCanBeUsedThisEmojiAsReaction?: string[];
hasMovement?: boolean;
};
};
};
Expand Down
Loading