app/models/federails/activity.rb in federails-0.1.0 vs app/models/federails/activity.rb in federails-0.2.0
- old
+ new
@@ -1,7 +1,9 @@
module Federails
class Activity < ApplicationRecord
+ include Federails::HasUuid
+
belongs_to :entity, polymorphic: true
belongs_to :actor
scope :feed_for, lambda { |actor|
actor_ids = []
@@ -11,25 +13,18 @@
where(actor_id: actor_ids)
}
after_create_commit :post_to_inboxes
- def recipients # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity
+ def recipients
return [] unless actor.local?
- actors = []
- case action
- when 'Create'
- actors.push(entity.target_actor) if entity_type == 'Federails::Following'
- # FIXME: Move this to dummy, somehow
- actors.push(*actor.followers) if entity_type == 'Note'
- when 'Accept'
- actors.push(entity.actor) if entity_type == 'Federails::Following'
- when 'Undo'
- actors.push(entity.target_actor) if entity_type == 'Federails::Following'
+ case entity_type
+ when 'Federails::Following'
+ [(action == 'Accept' ? entity.actor : entity.target_actor)]
+ else
+ actor.followers
end
-
- actors
end
private
def post_to_inboxes