Module: NewsmastMastodon::Overrides::ReblogServiceExtension

Defined in:
app/services/newsmast_mastodon/overrides/reblog_service_extension.rb

Instance Method Summary collapse

Instance Method Details

#call(account, reblogged_status, options = {}) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'app/services/newsmast_mastodon/overrides/reblog_service_extension.rb', line 8

def call(, reblogged_status, options = {})
  reblogged_status = reblogged_status.reblog if reblogged_status.reblog?

  authorize_with , reblogged_status, :reblog?

  reblog = .statuses.find_by(reblog: reblogged_status)

  return reblog unless reblog.nil?

  visibility = if reblogged_status.hidden?
                 reblogged_status.visibility
               else
                 options[:visibility] || .user&.setting_default_privacy
               end

  reblog = .statuses.create!(reblog: reblogged_status, text: '', visibility: visibility, rate_limit: options[:with_rate_limit])

  Trends.register!(reblog)
  DistributionWorker.perform_async(reblog.id)
  ActivityPub::DistributionWorker.perform_async(reblog.id) unless reblogged_status.local_only?

  create_notification(reblog)
  increment_statistics

  reblog
end