This commit is contained in:
CSDUMMI 2024-04-26 18:07:04 +00:00 committed by GitHub
commit 2b59eaab95
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 24 additions and 2 deletions

View File

@ -35,6 +35,9 @@ class FollowRequest < ApplicationRecord
follow = account.follow!(target_account, reblogs: show_reblogs, notify: notify, languages: languages, uri: uri, bypass_limit: true)
ListAccount.where(follow_request: self).update_all(follow_request_id: nil, follow_id: follow.id)
MergeWorker.perform_async(target_account.id, account.id) if account.local?
TriggerWebhookWorker.perform_async('follow.created', 'Follow', follow.id)
destroy!
end

View File

@ -23,6 +23,9 @@ class Webhook < ApplicationRecord
report.updated
status.created
status.updated
block.created
follow.created
mute.created
).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.created'
:manage_users
when 'report.created', 'report.updated'
:manage_reports
when 'block.created', 'mute.created'
:manage_blocks
when 'status.created', 'status.updated'
:view_devops
end

View File

@ -14,6 +14,8 @@ class BlockService < BaseService
block = account.block!(target_account)
trigger_webhooks block.id
BlockWorker.perform_async(account.id, target_account.id)
create_notification(block) if !target_account.local? && target_account.activitypub?
block
@ -28,4 +30,8 @@ class BlockService < BaseService
def build_json(block)
Oj.dump(serialize_payload(block, ActivityPub::BlockSerializer))
end
def trigger_webhooks(block_id)
TriggerWebhookWorker.perform_async('block.created', 'Block', block_id)
end
end

View File

@ -39,7 +39,9 @@ class FollowService < BaseService
if (@target_account.locked? && !@options[:bypass_locked]) || @source_account.silenced? || @target_account.activitypub?
request_follow!
elsif @target_account.local?
direct_follow!
follow = direct_follow!
trigger_webhooks follow.id
follow
end
end
@ -93,4 +95,8 @@ class FollowService < BaseService
def follow_options
@options.slice(:reblogs, :notify, :languages)
end
def trigger_webhooks(follow_id)
TriggerWebhookWorker.perform_async('follow.created', 'Follow', follow_id)
end
end

View File

@ -6,6 +6,8 @@ class MuteService < BaseService
mute = account.mute!(target_account, notifications: notifications, duration: duration)
TriggerWebhookWorker.perform_async('mute.created', 'Mute', mute.id)
if mute.hide_notifications?
BlockWorker.perform_async(account.id, target_account.id)
else