diff --git a/app/javascript/mastodon/actions/notifications.js b/app/javascript/mastodon/actions/notifications.js index c8b1178d771dc2..6f6a3235ea1cfd 100644 --- a/app/javascript/mastodon/actions/notifications.js +++ b/app/javascript/mastodon/actions/notifications.js @@ -133,6 +133,9 @@ export function updateNotifications(notification, intlMessages, intlLocale) { if (notification.status) { dispatch(importFetchedStatus(notification.status)); } + if (notification.statuses) { + dispatch(importFetchedStatuses(notification.statuses)); + } if (notification.report) { dispatch(importFetchedAccount(notification.report.target_account)); @@ -179,6 +182,7 @@ const excludeTypesFromFilter = filter => { 'status', 'list_status', 'update', + 'account_warning', 'admin.sign_up', 'admin.report', ]); @@ -237,7 +241,10 @@ export function expandNotifications({ maxId, forceLoad } = {}, done = noOp) { const next = getLinks(response).refs.find(link => link.rel === 'next'); dispatch(importFetchedAccounts(response.data.map(item => item.account))); - dispatch(importFetchedStatuses(response.data.map(item => item.status).filter(status => !!status))); + dispatch(importFetchedStatuses( + response.data.map(item => item.status).filter(status => !!status) + .concat(response.data.flatMap(item => item.statuses || [])) + )); dispatch(importFetchedAccounts(response.data.filter(item => item.report).map(item => item.report.target_account))); dispatch(expandNotificationsSuccess(response.data, next ? next.uri : null, isLoadingMore, isLoadingRecent, isLoadingRecent && preferPendingItems)); diff --git a/app/javascript/mastodon/features/notifications/components/notification.jsx b/app/javascript/mastodon/features/notifications/components/notification.jsx index 5924f023855724..a3cb8c3934f980 100644 --- a/app/javascript/mastodon/features/notifications/components/notification.jsx +++ b/app/javascript/mastodon/features/notifications/components/notification.jsx @@ -10,6 +10,7 @@ import ImmutablePureComponent from 'react-immutable-pure-component'; import { HotKeys } from 'react-hotkeys'; +import DangerousIcon from '@/material-icons/400-24px/dangerous-fill.svg?react'; import EditIcon from '@/material-icons/400-24px/edit.svg?react'; import FlagIcon from '@/material-icons/400-24px/flag-fill.svg?react'; import HomeIcon from '@/material-icons/400-24px/home-fill.svg?react'; @@ -43,7 +44,15 @@ const messages = defineMessages({ listStatus: { id: 'notification.list_status', defaultMessage: '{name} post is added on {listName}' }, statusReference: { id: 'notification.status_reference', defaultMessage: '{name} refered your post' }, update: { id: 'notification.update', defaultMessage: '{name} edited a post' }, - warning: { id: 'notification.warning', defaultMessage: 'You have been warned and "{action}" has been executed. Check your mailbox' }, + warning: { id: 'notification.warning', defaultMessage: 'You have been warned and did something. Check your mailbox' }, + warning_none: { id: 'notification.warning.none', defaultMessage: 'You have been warned. Check your mailbox.' }, + warning_disable: { id: 'notification.warning.disable', defaultMessage: 'You have been warned and disabled account. Check your mailbox.' }, + warning_force_cw: { id: 'notification.warning.force_cw', defaultMessage: 'You have been warned and one or more statuses have been added warning messages. Check your mailbox.' }, + warning_mark_statuses_as_sensitive: { id: 'notification.warning.mark_statuses_as_sensitive', defaultMessage: 'You have been warned and some statuses have been marked as sensitive. Check your mailbox.' }, + warning_delete_statuses: { id: 'notification.warning.delete_statuses', defaultMessage: 'You have been warned and one or more statuses have been deleted. Check your mailbox.' }, + warning_sensitive: { id: 'notification.warning.sensitive', defaultMessage: 'You have been warned and your account has been marked as sensitive. Check your mailbox.' }, + warning_silence: { id: 'notification.warning.silence', defaultMessage: 'You have been warned and your account has been silenced. Check your mailbox.' }, + warning_suspend: { id: 'notification.warning.suspend', defaultMessage: 'You have been warned and your account has been suspended. Check your mailbox.' }, adminSignUp: { id: 'notification.admin.sign_up', defaultMessage: '{name} signed up' }, adminReport: { id: 'notification.admin.report', defaultMessage: '{name} reported {target}' }, relationshipsSevered: { id: 'notification.relationships_severance_event', defaultMessage: 'Lost connections with {name}' }, @@ -477,22 +486,39 @@ class Notification extends ImmutablePureComponent { renderWarning (notification) { const { intl, unread } = this.props; + const preMessageKey = `warning_${notification.getIn(['account_warning', 'action'])}`; + const messageKey = Object.keys(messages).includes(preMessageKey) ? preMessageKey : 'warning'; + const text = notification.getIn(['account_warning', 'text']); + return (
- +
- + {intl.formatMessage(messages[messageKey])}
-
- {notification.getIn(['account_warning', 'text'])} -
+ {text &&
{text}
} + + {notification.get('statuses').map((status_id) => ( +
); diff --git a/app/javascript/mastodon/locales/en.json b/app/javascript/mastodon/locales/en.json index 70a7961e67ccb2..8498a7b283aa51 100644 --- a/app/javascript/mastodon/locales/en.json +++ b/app/javascript/mastodon/locales/en.json @@ -600,7 +600,7 @@ "notification.status": "{name} just posted", "notification.status_reference": "{name} refered your post", "notification.update": "{name} edited a post", - "notification.warning": "You have been warned and \"{action}\" has been executed. Check your mailbox", + "notification.warning": "You have been warned and did something. Check your mailbox", "notifications.clear": "Clear notifications", "notifications.clear_confirmation": "Are you sure you want to permanently clear all your notifications?", "notifications.column_settings.admin.report": "New reports:", diff --git a/app/javascript/mastodon/locales/ja.json b/app/javascript/mastodon/locales/ja.json index e8fe546805e634..26284988ff483b 100644 --- a/app/javascript/mastodon/locales/ja.json +++ b/app/javascript/mastodon/locales/ja.json @@ -565,7 +565,15 @@ "notification.status": "{name}さんが投稿しました", "notification.status_reference": "{name}さんがあなたの投稿を参照しました", "notification.update": "{name}さんが投稿を編集しました", - "notification.warning": "あなたは警告を出され、「{action}」が実行されました。詳細はメールをご確認ください", + "notification.warning": "あなたは警告を出され、処分が実行されました。詳細はメールをご確認ください", + "notification.warning.none": "あなたは警告を出されました。詳細はメールをご確認ください。", + "notification.warning.delete_statuses": "あなたは警告を出され、1つまたは複数の投稿が削除されました。詳細はメールをご確認ください。", + "notification.warning.disable": "あなたは警告を出され、アカウントが無効化されました。詳細はメールをご確認ください。", + "notification.warning.force_cw": "あなたは警告を出され、投稿に警告文が追加されました。詳細はメールをご確認ください。", + "notification.warning.mark_statuses_as_sensitive": "あなたは警告を出され、投稿が閲覧注意としてマークされました。詳細はメールをご確認ください。", + "notification.warning.sensitive": "あなたは警告を出され、アカウントがセンシティブ指定されました。詳細はメールをご確認ください。", + "notification.warning.silence": "あなたは警告を出され、サイレンスされました。詳細はメールをご確認ください。", + "notification.warning.suspended": "あなたは警告を出され、サスペンドされました。詳細はメールをご確認ください。", "notification_requests.accept": "受け入れる", "notification_requests.dismiss": "無視", "notification_requests.notifications_from": "{name}からの通知", diff --git a/app/javascript/mastodon/reducers/notifications.js b/app/javascript/mastodon/reducers/notifications.js index f4219c449efa10..a19671cc409ecf 100644 --- a/app/javascript/mastodon/reducers/notifications.js +++ b/app/javascript/mastodon/reducers/notifications.js @@ -55,6 +55,7 @@ export const notificationToMap = notification => ImmutableMap({ created_at: notification.created_at, emoji_reaction: ImmutableMap(notification.emoji_reaction), status: notification.status ? notification.status.id : null, + statuses: notification.statuses ? notification.statuses.map((status) => status.id) : null, list: notification.list ? ImmutableMap(notification.list) : null, report: notification.report ? fromJS(notification.report) : null, account_warning: notification.account_warning ? ImmutableMap(notification.account_warning) : null, diff --git a/app/javascript/material-icons/400-24px/dangerous-fill.svg b/app/javascript/material-icons/400-24px/dangerous-fill.svg new file mode 100644 index 00000000000000..8120409141e986 --- /dev/null +++ b/app/javascript/material-icons/400-24px/dangerous-fill.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/app/javascript/material-icons/400-24px/dangerous.svg b/app/javascript/material-icons/400-24px/dangerous.svg new file mode 100644 index 00000000000000..18d93fbc544d7e --- /dev/null +++ b/app/javascript/material-icons/400-24px/dangerous.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/app/serializers/rest/notification_serializer.rb b/app/serializers/rest/notification_serializer.rb index e05249440bd12c..cd309820bdf97f 100644 --- a/app/serializers/rest/notification_serializer.rb +++ b/app/serializers/rest/notification_serializer.rb @@ -3,6 +3,8 @@ class REST::NotificationSerializer < ActiveModel::Serializer attributes :id, :type, :created_at + has_many :statuses, serializer: REST::StatusSerializer, if: :warning_type? + belongs_to :from_account_web, key: :account, serializer: REST::AccountSerializer belongs_to :target_status, key: :status, if: :status_type?, serializer: REST::StatusSerializer belongs_to :report, if: :report_type?, serializer: REST::ReportSerializer @@ -42,4 +44,8 @@ def list def relationship_severance_event? object.type == :severed_relationships end + + def statuses + Status.where(id: object.account_warning.status_ids).to_a + end end