10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
# File 'app/workers/newsmast_mastodon/reblog_channels_worker.rb', line 10
def perform(status_id, account_id)
admin_account = Account.find_by(id: account_id)
return false unless admin_account
= User.find_by(account_id: admin_account.id)
return false unless
= NewsmastMastodon::CommunityAdmin.includes(:community).find_by(account_id: admin_account.id, is_boost_bot: true)
return false unless
admin_access_token = NewsmastMastodon::FetchAdminAccessTokenService.new(.id).call
return false unless admin_access_token
= &.
return false unless
if &.channel_type == 'newsmast'
boost_by_newsmast_bot(, status_id)
else
begin
NewsmastMastodon::ReblogRequestService.new.call(admin_access_token, status_id)
channels = ENV.fetch('FOR_YOU_TIMELINE_CHANNELS', nil).presence&.split(/\s*,\s*/)&.reject(&:blank?)&.map(&:downcase) || []
NewsmastMastodon::CustomBoostBotService.new(status_id, &.username).call if channels.include?(&.username.downcase)
rescue => e
Rails.logger.error "ReblogRequestService failed: - #{e.message}"
false
end
end
end
|