logo

mastofe

My custom branche(s) on git.pleroma.social/pleroma/mastofe git clone https://hacktivis.me/git/mastofe.git

feed_insert_worker.rb (883B)


  1. # frozen_string_literal: true
  2. class FeedInsertWorker
  3. include Sidekiq::Worker
  4. def perform(status_id, id, type = :home)
  5. @type = type.to_sym
  6. @status = Status.find(status_id)
  7. case @type
  8. when :home
  9. @follower = Account.find(id)
  10. when :list
  11. @list = List.find(id)
  12. @follower = @list.account
  13. end
  14. check_and_insert
  15. rescue ActiveRecord::RecordNotFound
  16. true
  17. end
  18. private
  19. def check_and_insert
  20. perform_push unless feed_filtered?
  21. end
  22. def feed_filtered?
  23. # Note: Lists are a variation of home, so the filtering rules
  24. # of home apply to both
  25. FeedManager.instance.filter?(:home, @status, @follower.id)
  26. end
  27. def perform_push
  28. case @type
  29. when :home
  30. FeedManager.instance.push_to_home(@follower, @status)
  31. when :list
  32. FeedManager.instance.push_to_list(@list, @status)
  33. end
  34. end
  35. end