]> cat aescling's git repositories - mastodon.git/blob - app/workers/feed_insert_worker.rb
Add specs for UnreservedUsernameValidator (#9698)
[mastodon.git] / app / workers / feed_insert_worker.rb
1 # frozen_string_literal: true
2
3 class FeedInsertWorker
4 include Sidekiq::Worker
5
6 def perform(status_id, id, type = :home)
7 @type = type.to_sym
8 @status = Status.find(status_id)
9
10 case @type
11 when :home
12 @follower = Account.find(id)
13 when :list
14 @list = List.find(id)
15 @follower = @list.account
16 end
17
18 check_and_insert
19 rescue ActiveRecord::RecordNotFound
20 true
21 end
22
23 private
24
25 def check_and_insert
26 perform_push unless feed_filtered?
27 end
28
29 def feed_filtered?
30 # Note: Lists are a variation of home, so the filtering rules
31 # of home apply to both
32 FeedManager.instance.filter?(:home, @status, @follower.id)
33 end
34
35 def perform_push
36 case @type
37 when :home
38 FeedManager.instance.push_to_home(@follower, @status)
39 when :list
40 FeedManager.instance.push_to_list(@list, @status)
41 end
42 end
43 end
This page took 0.0759 seconds and 4 git commands to generate.