mirror of
https://github.com/mastodon/mastodon.git
synced 2024-08-20 21:08:15 -07:00
Compare commits
4 commits
6e0e844704
...
65ffd7c89b
Author | SHA1 | Date | |
---|---|---|---|
|
65ffd7c89b | ||
|
a50c8e951f | ||
|
2c1e75727d | ||
|
c40cc9e2f8 |
10 changed files with 37 additions and 35 deletions
|
@ -60,7 +60,7 @@ export interface BaseNotificationGroupJSON {
|
|||
|
||||
interface NotificationGroupWithStatusJSON extends BaseNotificationGroupJSON {
|
||||
type: NotificationWithStatusType;
|
||||
status: ApiStatusJSON;
|
||||
status_id: string;
|
||||
}
|
||||
|
||||
interface NotificationWithStatusJSON extends BaseNotificationJSON {
|
||||
|
|
|
@ -49,21 +49,14 @@ export const FilteredNotificationsBanner: React.FC = () => {
|
|||
<span>
|
||||
<FormattedMessage
|
||||
id='filtered_notifications_banner.pending_requests'
|
||||
defaultMessage='Notifications from {count, plural, =0 {no one} one {one person} other {# people}} you may know'
|
||||
defaultMessage='From {count, plural, =0 {no one} one {one person} other {# people}} you may know'
|
||||
values={{ count: policy.summary.pending_requests_count }}
|
||||
/>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div className='filtered-notifications-banner__badge'>
|
||||
<div className='filtered-notifications-banner__badge__badge'>
|
||||
{toCappedNumber(policy.summary.pending_notifications_count)}
|
||||
</div>
|
||||
<FormattedMessage
|
||||
id='filtered_notifications_banner.mentions'
|
||||
defaultMessage='{count, plural, one {mention} other {mentions}}'
|
||||
values={{ count: policy.summary.pending_notifications_count }}
|
||||
/>
|
||||
{toCappedNumber(policy.summary.pending_notifications_count)}
|
||||
</div>
|
||||
</Link>
|
||||
);
|
||||
|
|
|
@ -300,8 +300,7 @@
|
|||
"filter_modal.select_filter.subtitle": "Use an existing category or create a new one",
|
||||
"filter_modal.select_filter.title": "Filter this post",
|
||||
"filter_modal.title.status": "Filter a post",
|
||||
"filtered_notifications_banner.mentions": "{count, plural, one {mention} other {mentions}}",
|
||||
"filtered_notifications_banner.pending_requests": "Notifications from {count, plural, =0 {no one} one {one person} other {# people}} you may know",
|
||||
"filtered_notifications_banner.pending_requests": "From {count, plural, =0 {no one} one {one person} other {# people}} you may know",
|
||||
"filtered_notifications_banner.title": "Filtered notifications",
|
||||
"firehose.all": "All",
|
||||
"firehose.local": "This server",
|
||||
|
|
|
@ -124,9 +124,9 @@ export function createNotificationGroupFromJSON(
|
|||
case 'mention':
|
||||
case 'poll':
|
||||
case 'update': {
|
||||
const { status, ...groupWithoutStatus } = group;
|
||||
const { status_id: statusId, ...groupWithoutStatus } = group;
|
||||
return {
|
||||
statusId: status.id,
|
||||
statusId,
|
||||
sampleAccountIds,
|
||||
...groupWithoutStatus,
|
||||
};
|
||||
|
|
|
@ -10171,25 +10171,10 @@ noscript {
|
|||
}
|
||||
|
||||
&__badge {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
border-radius: 999px;
|
||||
background: var(--background-border-color);
|
||||
color: $darker-text-color;
|
||||
padding: 4px;
|
||||
padding-inline-end: 8px;
|
||||
gap: 6px;
|
||||
font-weight: 500;
|
||||
font-size: 11px;
|
||||
line-height: 16px;
|
||||
word-break: keep-all;
|
||||
|
||||
&__badge {
|
||||
background: $ui-button-background-color;
|
||||
color: $white;
|
||||
border-radius: 100px;
|
||||
padding: 2px 8px;
|
||||
}
|
||||
background: $ui-button-background-color;
|
||||
color: $white;
|
||||
border-radius: 100px;
|
||||
padding: 2px 8px;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -23,6 +23,9 @@ class Webhook < ApplicationRecord
|
|||
report.updated
|
||||
status.created
|
||||
status.updated
|
||||
follow.removed
|
||||
block.removed
|
||||
mute.removed
|
||||
).freeze
|
||||
|
||||
attr_writer :current_account
|
||||
|
@ -58,10 +61,12 @@ class Webhook < ApplicationRecord
|
|||
|
||||
def self.permission_for_event(event)
|
||||
case event
|
||||
when 'account.approved', 'account.created', 'account.updated'
|
||||
when 'account.approved', 'account.created', 'account.updated', 'follow.removed'
|
||||
:manage_users
|
||||
when 'report.created', 'report.updated'
|
||||
:manage_reports
|
||||
when 'block.removed', 'mute.removed'
|
||||
:manage_blocks
|
||||
when 'status.created', 'status.updated'
|
||||
:view_devops
|
||||
end
|
||||
|
|
|
@ -7,6 +7,9 @@ class UnblockService < BaseService
|
|||
return unless account.blocking?(target_account)
|
||||
|
||||
unblock = account.unblock!(target_account)
|
||||
|
||||
TriggerWebhookWithObjectWorker.perform_async('block.removed', Oj.to_json({ 'account_id': unblock.account_id, 'target_account_id': unblock.target_account_id, 'id': unblock.id }))
|
||||
|
||||
create_notification(unblock) if !target_account.local? && target_account.activitypub?
|
||||
unblock
|
||||
end
|
||||
|
|
|
@ -29,6 +29,8 @@ class UnfollowService < BaseService
|
|||
|
||||
follow.destroy!
|
||||
|
||||
TriggerWebhookWithObjectWorker.perform_async('follow.removed', Oj.to_json({ 'account_id': follow.account_id, 'target_account_id': follow.target_account_id, 'id': follow.id }))
|
||||
|
||||
create_notification(follow) if !@target_account.local? && @target_account.activitypub?
|
||||
create_reject_notification(follow) if @target_account.local? && !@source_account.local? && @source_account.activitypub?
|
||||
UnmergeWorker.perform_async(@target_account.id, @source_account.id) unless @options[:skip_unmerge]
|
||||
|
|
|
@ -4,7 +4,9 @@ class UnmuteService < BaseService
|
|||
def call(account, target_account)
|
||||
return unless account.muting?(target_account)
|
||||
|
||||
account.unmute!(target_account)
|
||||
unmute = account.unmute!(target_account)
|
||||
|
||||
TriggerWebhookWithObjectWorker.perform_async('mute.removed', Oj.to_json({ 'account_id': unmute.account_id, 'target_account_id': unmute.target_account_id, 'id': unmute.id }))
|
||||
|
||||
MergeWorker.perform_async(target_account.id, account.id) if account.following?(target_account)
|
||||
end
|
||||
|
|
13
app/workers/trigger_webhook_with_object_worker.rb
Normal file
13
app/workers/trigger_webhook_with_object_worker.rb
Normal file
|
@ -0,0 +1,13 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class TriggerWebhookWithObjectWorker
|
||||
include Sidekiq::Worker
|
||||
|
||||
# Triggers a webhook for a destructive event (e.g. an unfollow),
|
||||
# where the object cannot be queried from the database.
|
||||
# @param event [String] type of the event
|
||||
# @param object [String] event payload serialized with JSON
|
||||
def perform(event, object)
|
||||
WebhookService.new.call(event, Oj.load(object))
|
||||
end
|
||||
end
|
Loading…
Reference in a new issue