Class: Message

Inherits:
ActiveRecord::Base
  • Object
show all
Includes:
Diaspora::Guid, Diaspora::Relayable, Diaspora::Webhooks, ROXML
Defined in:
app/models/message.rb

Instance Method Summary (collapse)

Methods included from Diaspora::Relayable

included, #initialize_signatures, #parent_guid, #parent_guid=, #receive, #relayable?, #signature_valid?, #subscribers, #verify_parent_author_signature

Methods included from Diaspora::Encryptable

#sign_with_key, #signable_accessors, #signable_string, #verify_signature

Methods included from Diaspora::Webhooks

#receive, #subscribers, #to_diaspora_xml, #x

Methods included from Diaspora::Guid

included, #set_guid

Instance Method Details

- (Object) after_receive(user, person)



60
61
62
63
64
65
66
67
68
# File 'app/models/message.rb', line 60

def after_receive(user, person)
  if vis = ConversationVisibility.where(:conversation_id => self.conversation_id, :person_id => user.person.id).first
    vis.unread += 1
    vis.save
    self
  else
    raise NotVisibleException("Attempting to access a ConversationVisibility that does not exist!")
  end
end

- (Object) conversation_guid



38
39
40
# File 'app/models/message.rb', line 38

def conversation_guid
  self.conversation.guid
end

- (Object) conversation_guid=(guid)



42
43
44
45
46
# File 'app/models/message.rb', line 42

def conversation_guid= guid
  if cnv = Conversation.find_by_guid(guid)
    self.conversation_id = cnv.id
  end
end

- (Object) diaspora_handle



30
31
32
# File 'app/models/message.rb', line 30

def diaspora_handle
  self.author.diaspora_handle
end

- (Object) diaspora_handle=(nh)



34
35
36
# File 'app/models/message.rb', line 34

def diaspora_handle= nh
  self.author = Webfinger.new(nh).fetch
end

- (Object) notification_type(user, person)



70
71
72
# File 'app/models/message.rb', line 70

def notification_type(user, person)
  Notifications::PrivateMessage unless user.person == person
end

- (Object) parent



52
53
54
# File 'app/models/message.rb', line 52

def parent
  self.conversation
end

- (Object) parent=(parent)



56
57
58
# File 'app/models/message.rb', line 56

def parent= parent
  self.conversation = parent
end

- (Object) parent_class



48
49
50
# File 'app/models/message.rb', line 48

def parent_class
  Conversation
end