base/app/models/relation.rb in social_stream-2.0.4 vs base/app/models/relation.rb in social_stream-2.1.0
- old
+ new
@@ -42,12 +42,10 @@
#
class Relation < ActiveRecord::Base
Positive = %w{ custom public follow }
Negative = %w{ reject }
- belongs_to :actor
-
has_many :relation_permissions, :dependent => :destroy
has_many :permissions, :through => :relation_permissions
has_many :ties, :dependent => :destroy
has_many :contacts, :through => :ties
@@ -55,14 +53,10 @@
has_many :audiences, :dependent => :destroy
has_many :activities, :through => :audiences
has_many :activity_object_audiences, :dependent => :destroy
- scope :actor, lambda { |a|
- where(:actor_id => Actor.normalize_id(a))
- }
-
scope :mode, lambda { |st, rt|
where(:sender_type => st, :receiver_type => rt)
}
scope :positive, lambda {
@@ -72,12 +66,10 @@
scope :allowing, lambda { |action, object|
joins(:permissions).
merge(Permission.where(:action => action).where(:object => object))
}
- before_create :initialize_sender_type
-
class << self
# Get relation from object, if possible
#
# Options::
# sender:: The sender of the tie
@@ -171,10 +163,19 @@
end
def create_activity?
true
end
+
+ # Default extra relations that are displayed in {Actor}'s relation list,
+ # typically in /relation/customs
+ def extra_list subject
+ l = SocialStream.list_relations[subject.class.to_s.underscore]
+ return [] if l.blank?
+
+ l.map{ |r| "Relation::#{ r.to_s.classify }".constantize.instance }
+ end
end
# Relation class scoped in the same mode that this relation
def mode
Relation.mode(sender_type, receiver_type)
@@ -188,14 +189,12 @@
# Does this relation include the follow permission?
def follow?
permissions.follow.any?
end
- private
-
- # Before create callback
- def initialize_sender_type
- return if actor.blank?
-
- self.sender_type = actor.subject_type
+ # The permissions that can be assigned to this relation.
+ #
+ # They are principally used in the privacy form in /relation/customs form
+ def available_permissions
+ []
end
end