Class: Message

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

Instance Method Summary collapse

Methods included from Diaspora::Relayable

#after_receive, #author_is_not_ignored, 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::Guid

included, #set_guid

Methods included from Diaspora::Federated::Base

included

Instance Method Details

#conversation_guidObject


41
42
43
# File 'app/models/message.rb', line 41

def conversation_guid
  self.conversation.guid
end

#conversation_guid=(guid) ⇒ Object


45
46
47
48
49
# File 'app/models/message.rb', line 45

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

#diaspora_handleObject


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

def diaspora_handle
  self.author.diaspora_handle
end

#diaspora_handle=(nh) ⇒ Object


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

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

#increase_unread(user) ⇒ Object


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

def increase_unread(user)
  if vis = ConversationVisibility.where(:conversation_id => self.conversation_id, :person_id => user.person.id).first
    vis.unread += 1
    vis.save
  end
end

#messageObject


74
75
76
# File 'app/models/message.rb', line 74

def message
  @message ||= Diaspora::MessageRenderer.new text
end

#notification_type(user, person) ⇒ Object


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

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

#parentObject


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

def parent
  self.conversation
end

#parent=(parent) ⇒ Object


59
60
61
# File 'app/models/message.rb', line 59

def parent= parent
  self.conversation = parent
end

#parent_classObject


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

def parent_class
  Conversation
end