parent
e7aececf5e
commit
95a18edaac
8 changed files with 59 additions and 9 deletions
|
@ -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));
|
||||
|
|
|
@ -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 (
|
||||
<HotKeys handlers={this.getHandlers()}>
|
||||
<div className={classNames('notification notification-warning focusable', { unread })} tabIndex={0} aria-label={notificationForScreenReader(intl, intl.formatMessage(messages.statusReference, { name: notification.getIn(['account', 'acct']) }), notification.get('created_at'))}>
|
||||
<div className='notification__message'>
|
||||
<div className='notification__favourite-icon-wrapper'>
|
||||
<Icon id='exclamation-triangle' className='star-icon' fixedWidth />
|
||||
<Icon id='exclamation-triangle' icon={DangerousIcon} className='star-icon' fixedWidth />
|
||||
</div>
|
||||
|
||||
<span title={notification.get('created_at')}>
|
||||
<FormattedMessage id='notification.warning' defaultMessage='You have been warned and "{action}" has been executed. Check your mailbox' values={{action: notification.getIn(['account_warning', 'action'])}} />
|
||||
{intl.formatMessage(messages[messageKey])}
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div className='notification__warning-text'>
|
||||
{notification.getIn(['account_warning', 'text'])}
|
||||
</div>
|
||||
{text && <div className='notification__warning-text'>{text}</div>}
|
||||
|
||||
{notification.get('statuses').map((status_id) => (
|
||||
<StatusContainer
|
||||
key={status_id}
|
||||
id={status_id}
|
||||
muted
|
||||
withDismiss
|
||||
hidden={!!this.props.hidden}
|
||||
getScrollPosition={this.props.getScrollPosition}
|
||||
updateScrollBottom={this.props.updateScrollBottom}
|
||||
cachedMediaWidth={this.props.cachedMediaWidth}
|
||||
cacheMediaWidth={this.props.cacheMediaWidth}
|
||||
withoutEmojiReactions
|
||||
/>
|
||||
))}
|
||||
</div>
|
||||
</HotKeys>
|
||||
);
|
||||
|
|
|
@ -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:",
|
||||
|
|
|
@ -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}からの通知",
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
<svg xmlns="http://www.w3.org/2000/svg" height="24" viewBox="0 -960 960 960" width="24"><path d="M330-120 120-330v-300l210-210h300l210 210v300L630-120H330Zm36-190 114-114 114 114 56-56-114-114 114-114-56-56-114 114-114-114-56 56 114 114-114 114 56 56Z"/></svg>
|
After Width: | Height: | Size: 260 B |
1
app/javascript/material-icons/400-24px/dangerous.svg
Normal file
1
app/javascript/material-icons/400-24px/dangerous.svg
Normal file
|
@ -0,0 +1 @@
|
|||
<svg xmlns="http://www.w3.org/2000/svg" height="24" viewBox="0 -960 960 960" width="24"><path d="M330-120 120-330v-300l210-210h300l210 210v300L630-120H330Zm36-190 114-114 114 114 56-56-114-114 114-114-56-56-114 114-114-114-56 56 114 114-114 114 56 56Zm-2 110h232l164-164v-232L596-760H364L200-596v232l164 164Zm116-280Z"/></svg>
|
After Width: | Height: | Size: 326 B |
|
@ -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 @@ class REST::NotificationSerializer < ActiveModel::Serializer
|
|||
def relationship_severance_event?
|
||||
object.type == :severed_relationships
|
||||
end
|
||||
|
||||
def statuses
|
||||
Status.where(id: object.account_warning.status_ids).to_a
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue