2024-02-06 07:45:21 +00:00
|
|
|
import * as Misskey from 'misskey-js';
|
2024-02-24 01:22:23 +00:00
|
|
|
import { UnicodeEmojiDef } from './emojilist.js';
|
2024-02-06 07:45:21 +00:00
|
|
|
|
2024-02-24 01:22:23 +00:00
|
|
|
export function checkReactionPermissions(me: Misskey.entities.MeDetailed, note: Misskey.entities.Note, emoji: Misskey.entities.EmojiSimple | UnicodeEmojiDef): boolean {
|
|
|
|
if ('char' in emoji) return true; // UnicodeEmojiDefなら常にリアクション可能
|
|
|
|
|
|
|
|
emoji = emoji as Misskey.entities.EmojiSimple;
|
2024-02-06 07:45:21 +00:00
|
|
|
const roleIdsThatCanBeUsedThisEmojiAsReaction = emoji.roleIdsThatCanBeUsedThisEmojiAsReaction ?? [];
|
|
|
|
return !(emoji.localOnly && note.user.host !== me.host)
|
|
|
|
&& !(emoji.isSensitive && (note.reactionAcceptance === 'nonSensitiveOnly' || note.reactionAcceptance === 'nonSensitiveOnlyForLocalLikeOnlyForRemote'))
|
|
|
|
&& (roleIdsThatCanBeUsedThisEmojiAsReaction.length === 0 || me.roles.some(role => roleIdsThatCanBeUsedThisEmojiAsReaction.includes(role.id)));
|
|
|
|
}
|