2024-03-13 08:37:18 -05:00
|
|
|
/*
|
|
|
|
* SPDX-FileCopyrightText: syuilo and misskey-project
|
|
|
|
* SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
*/
|
|
|
|
|
2024-02-06 01:45:21 -06:00
|
|
|
import * as Misskey from 'misskey-js';
|
2024-09-09 06:57:36 -05:00
|
|
|
import { UnicodeEmojiDef } from '@@/js/emojilist.js';
|
2024-02-06 01:45:21 -06:00
|
|
|
|
2024-03-01 22:28:10 -06:00
|
|
|
export function checkReactionPermissions(me: Misskey.entities.MeDetailed, note: Misskey.entities.Note, emoji: Misskey.entities.EmojiSimple | UnicodeEmojiDef | string): boolean {
|
|
|
|
if (typeof emoji === 'string') return true; // UnicodeEmojiDefにも無い絵文字であれば文字列で来る。Unicode絵文字であることには変わりないので常にリアクション可能とする;
|
|
|
|
if ('char' in emoji) return true; // UnicodeEmojiDefなら常にリアクション可能
|
2024-02-23 19:22:23 -06:00
|
|
|
|
2024-03-01 22:28:10 -06:00
|
|
|
const roleIdsThatCanBeUsedThisEmojiAsReaction = emoji.roleIdsThatCanBeUsedThisEmojiAsReaction ?? [];
|
|
|
|
return !(emoji.localOnly && note.user.host !== me.host)
|
2024-02-06 01:45:21 -06:00
|
|
|
&& !(emoji.isSensitive && (note.reactionAcceptance === 'nonSensitiveOnly' || note.reactionAcceptance === 'nonSensitiveOnlyForLocalLikeOnlyForRemote'))
|
|
|
|
&& (roleIdsThatCanBeUsedThisEmojiAsReaction.length === 0 || me.roles.some(role => roleIdsThatCanBeUsedThisEmojiAsReaction.includes(role.id)));
|
|
|
|
}
|