forked from mastodon/mastodon
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add in-app notifications for moderation actions/warnings (mastodon#30065
- Loading branch information
1 parent
0ec061a
commit 4ef0b48
Showing
13 changed files
with
189 additions
and
22 deletions.
There are no files selected for viewing
78 changes: 78 additions & 0 deletions
78
app/javascript/mastodon/features/notifications/components/moderation_warning.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
import { defineMessages, FormattedMessage, useIntl } from 'react-intl'; | ||
|
||
import WarningIcon from '@/material-icons/400-24px/warning-fill.svg?react'; | ||
import { Icon } from 'mastodon/components/icon'; | ||
|
||
// This needs to be kept in sync with app/models/account_warning.rb | ||
const messages = defineMessages({ | ||
none: { | ||
id: 'notification.moderation_warning.action_none', | ||
defaultMessage: 'Your account has received a moderation warning.', | ||
}, | ||
disable: { | ||
id: 'notification.moderation_warning.action_disable', | ||
defaultMessage: 'Your account has been disabled.', | ||
}, | ||
mark_statuses_as_sensitive: { | ||
id: 'notification.moderation_warning.action_mark_statuses_as_sensitive', | ||
defaultMessage: 'Some of your posts have been marked as sensitive.', | ||
}, | ||
delete_statuses: { | ||
id: 'notification.moderation_warning.action_delete_statuses', | ||
defaultMessage: 'Some of your posts have been removed.', | ||
}, | ||
sensitive: { | ||
id: 'notification.moderation_warning.action_sensitive', | ||
defaultMessage: 'Your posts will be marked as sensitive from now on.', | ||
}, | ||
silence: { | ||
id: 'notification.moderation_warning.action_silence', | ||
defaultMessage: 'Your account has been limited.', | ||
}, | ||
suspend: { | ||
id: 'notification.moderation_warning.action_suspend', | ||
defaultMessage: 'Your account has been suspended.', | ||
}, | ||
}); | ||
|
||
interface Props { | ||
action: | ||
| 'none' | ||
| 'disable' | ||
| 'mark_statuses_as_sensitive' | ||
| 'delete_statuses' | ||
| 'sensitive' | ||
| 'silence' | ||
| 'suspend'; | ||
id: string; | ||
hidden: boolean; | ||
} | ||
|
||
export const ModerationWarning: React.FC<Props> = ({ action, id, hidden }) => { | ||
const intl = useIntl(); | ||
|
||
if (hidden) { | ||
return null; | ||
} | ||
|
||
return ( | ||
<a | ||
href={`/disputes/strikes/${id}`} | ||
target='_blank' | ||
rel='noopener noreferrer' | ||
className='notification__moderation-warning' | ||
> | ||
<Icon id='warning' icon={WarningIcon} /> | ||
|
||
<div className='notification__moderation-warning__content'> | ||
<p>{intl.formatMessage(messages[action])}</p> | ||
<span className='link-button'> | ||
<FormattedMessage | ||
id='notification.moderation-warning.learn_more' | ||
defaultMessage='Learn more' | ||
/> | ||
</span> | ||
</div> | ||
</a> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# frozen_string_literal: true | ||
|
||
class REST::AccountWarningSerializer < ActiveModel::Serializer | ||
attributes :id, :action, :text, :status_ids, :created_at | ||
|
||
has_one :target_account, serializer: REST::AccountSerializer | ||
has_one :appeal, serializer: REST::AppealSerializer | ||
|
||
def id | ||
object.id.to_s | ||
end | ||
|
||
def status_ids | ||
object&.status_ids&.map(&:to_s) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# frozen_string_literal: true | ||
|
||
class REST::AppealSerializer < ActiveModel::Serializer | ||
attributes :text, :state | ||
|
||
def state | ||
if object.approved? | ||
'approved' | ||
elsif object.rejected? | ||
'rejected' | ||
else | ||
'pending' | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters