Module: Diaspora::Federated::Shareable::InstanceMethods

Defined in:
lib/diaspora/federated/shareable.rb

Instance Method Summary collapse

Instance Method Details

#diaspora_handleObject


27
28
29
# File 'lib/diaspora/federated/shareable.rb', line 27

def diaspora_handle
  read_attribute(:diaspora_handle) || self.author.diaspora_handle
end

#diaspora_handle=(author_handle) ⇒ Object


31
32
33
34
# File 'lib/diaspora/federated/shareable.rb', line 31

def diaspora_handle=(author_handle)
  self.author = Person.where(:diaspora_handle => author_handle).first
  write_attribute(:diaspora_handle, author_handle)
end

#receive(user, person) ⇒ void


39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/diaspora/federated/shareable.rb', line 39

def receive(user, person)
  #exists locally, but you dont know about it
  #does not exsist locally, and you dont know about it
  #exists_locally?
  #you know about it, and it is mutable
  #you know about it, and it is not mutable
  self.class.transaction do
    local_shareable = persisted_shareable

    if local_shareable && verify_persisted_shareable(local_shareable)
      self.receive_persisted(user, person, local_shareable)

    elsif !local_shareable
      self.receive_non_persisted(user, person)

    else
      Rails.logger.info("event=receive payload_type=#{self.class} update=true status=abort sender=#{self.diaspora_handle} reason='update not from shareable owner' existing_shareable=#{self.id}")
      false
    end
  end
end

#subscribers(user) ⇒ Array<Person>

The list of people that should receive this Shareable.


65
66
67
68
69
70
71
# File 'lib/diaspora/federated/shareable.rb', line 65

def subscribers(user)
  if self.public?
    user.contact_people
  else
    user.people_in_aspects(user.aspects_with_shareable(self.class, self.id))
  end
end