feat(reaction): ロールでリアクションの制御をできるように (MisskeyIO#660)

This commit is contained in:
まっちゃてぃー。 2024-07-13 02:08:56 +09:00 committed by GitHub
parent 5ab83ff9d8
commit bb913ee00a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 40 additions and 7 deletions

View file

@ -116,10 +116,10 @@ export class ReactionService {
if (!await this.noteEntityService.isVisibleForMe(note, user.id)) {
throw new IdentifiableError('68e9d2d1-48bf-42c2-b90a-b20e09fd3d48', 'Note not accessible for you.');
}
const policies = await this.roleService.getUserPolicies(user.id);
let reaction = _reaction ?? FALLBACK;
if (note.reactionAcceptance === 'likeOnly' || ((note.reactionAcceptance === 'likeOnlyForRemote' || note.reactionAcceptance === 'nonSensitiveOnlyForLocalLikeOnlyForRemote') && (user.host != null))) {
if (note.reactionAcceptance === 'likeOnly' || !policies.canUseReaction || ((note.reactionAcceptance === 'likeOnlyForRemote' || note.reactionAcceptance === 'nonSensitiveOnlyForLocalLikeOnlyForRemote') && (user.host != null))) {
reaction = '\u2764';
} else if (_reaction) {
const custom = reaction.match(isCustomEmojiRegexp);

View file

@ -53,6 +53,7 @@ export type RolePolicies = {
canSearchNotes: boolean;
canUseTranslator: boolean;
canUseDriveFileInSoundSettings: boolean;
canUseReaction: boolean;
canHideAds: boolean;
driveCapacityMb: number;
alwaysMarkNsfw: boolean;
@ -91,6 +92,7 @@ export const DEFAULT_POLICIES: RolePolicies = {
canSearchNotes: false,
canUseTranslator: true,
canUseDriveFileInSoundSettings: false,
canUseReaction: true,
canHideAds: false,
driveCapacityMb: 100,
alwaysMarkNsfw: false,
@ -402,6 +404,7 @@ export class RoleService implements OnApplicationShutdown, OnModuleInit {
canSearchNotes: calc('canSearchNotes', vs => vs.some(v => v === true)),
canUseTranslator: calc('canUseTranslator', vs => vs.some(v => v === true)),
canUseDriveFileInSoundSettings: calc('canUseDriveFileInSoundSettings', vs => vs.some(v => v === true)),
canUseReaction: calc('canUseReaction', vs => vs.some(v => v === true)),
canHideAds: calc('canHideAds', vs => vs.some(v => v === true)),
driveCapacityMb: calc('driveCapacityMb', vs => Math.max(...vs)),
alwaysMarkNsfw: calc('alwaysMarkNsfw', vs => vs.some(v => v === true)),