From e7aad03279cab68f2283a1b0dfbf776ce0ce652e Mon Sep 17 00:00:00 2001 From: Lim Chee Aun Date: Wed, 8 May 2024 10:28:34 +0800 Subject: [PATCH] Preliminary implementation of moderation_warning notifications --- src/components/notification.jsx | 41 +++++++++++++++++++++++++++++++-- src/pages/notifications.jsx | 11 +++++++++ 2 files changed, 50 insertions(+), 2 deletions(-) diff --git a/src/components/notification.jsx b/src/components/notification.jsx index beb2a202..d2eadfbd 100644 --- a/src/components/notification.jsx +++ b/src/components/notification.jsx @@ -28,6 +28,7 @@ const NOTIFICATION_ICONS = { 'admin.signup': 'account-edit', 'admin.report': 'account-warning', severed_relationships: 'heart-break', + moderation_warning: 'alert', emoji_reaction: 'emoji2', 'pleroma:emoji_reaction': 'emoji2', }; @@ -45,6 +46,8 @@ poll = A poll you have voted in or created has ended update = A status you interacted with has been edited admin.sign_up = Someone signed up (optionally sent to admins) admin.report = A new report has been filed +severed_relationships = Severed relationships +moderation_warning = Moderation warning */ function emojiText(emoji, emoji_url) { @@ -91,6 +94,7 @@ const contentText = { Lost connections with {name}. ), + moderation_warning: Moderation warning, emoji_reaction: emojiText, 'pleroma:emoji_reaction': emojiText, }; @@ -117,6 +121,17 @@ const SEVERED_RELATIONSHIPS_TEXT = { ), }; +const MODERATION_WARNING_TEXT = { + none: 'Your account has received a moderation warning.', + disable: 'Your account has been disabled.', + mark_statuses_as_sensitive: + 'Some of your posts have been marked as sensitive.', + delete_statuses: 'Some of your posts have been deleted.', + sensitive: 'Your posts will be marked as sensitive from now on.', + silence: 'Your account has been limited.', + suspend: 'Your account has been suspended.', +}; + const AVATARS_LIMIT = 50; function Notification({ @@ -125,8 +140,16 @@ function Notification({ isStatic, disableContextMenu, }) { - const { id, status, account, report, event, _accounts, _statuses } = - notification; + const { + id, + status, + account, + report, + event, + moderation_warning, + _accounts, + _statuses, + } = notification; let { type } = notification; // status = Attached when type of the notification is favourite, reblog, status, mention, poll, or update @@ -314,6 +337,20 @@ function Notification({ . )} + {type === 'moderation_warning' && !!moderation_warning && ( +
+ {MODERATION_WARNING_TEXT[moderation_warning.action]} +
+ + Learn more + + . +
+ )} )} {_accounts?.length > 1 && ( diff --git a/src/pages/notifications.jsx b/src/pages/notifications.jsx index e97d8aa1..cb68d4af 100644 --- a/src/pages/notifications.jsx +++ b/src/pages/notifications.jsx @@ -102,6 +102,17 @@ function Notifications({ columnMode }) { // }, // }); + // TEST: Slot in a fake notification to test 'moderation_warning' + // notifications.unshift({ + // id: '123123', + // type: 'moderation_warning', + // createdAt: new Date().toISOString(), + // moderation_warning: { + // id: '1231234', + // action: 'mark_statuses_as_sensitive', + // }, + // }); + // console.log({ notifications }); const groupedNotifications = groupNotifications(notifications);