Class: MessageRecipient
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- MessageRecipient
- Defined in:
- lib/has_messages/models/message_recipient.rb
Overview
Represents a recipient on a message. The kind of recipient (to, cc, or bcc) is determined by the kind attribute.
States
Recipients can be in 1 of 2 states:
-
unread- The message has been sent, but not yet read by the recipient. This is the initial state. -
read- The message has been read by the recipient
Interacting with the message
In order to perform actions on the message, such as viewing, you should always use the associated event action:
-
view- Marks the message as read by the recipient
Hiding messages
Although you can delete a recipient, it will also delete it from everyone else’s message, meaning that no one will know that person was ever a recipient of the message. Instead, you can change the visibility of the message. Messages have 1 of 2 states that define its visibility:
-
visible- The message is visible to the recipient -
hidden- The message is hidden from the recipient
The visibility of a message can be changed by running the associated action:
-
hide-Hides the message from the recipient -
unhide- Makes the message visible again
Instance Method Summary collapse
-
#forward ⇒ Object
Forwards this message, including the original subject and body in the new message.
-
#reply ⇒ Object
Replies to this message, including the original subject and body in the new message.
-
#reply_to_all ⇒ Object
Replies to all recipients on this message, including the original subject and body in the new message.
Instance Method Details
#forward ⇒ Object
Forwards this message, including the original subject and body in the new message
71 72 73 74 75 |
# File 'lib/has_messages/models/message_recipient.rb', line 71 def forward = self..class.new(:subject => subject, :body => body) .sender = receiver end |
#reply ⇒ Object
Replies to this message, including the original subject and body in the new message. Only the original direct receivers are added to the reply.
79 80 81 82 83 84 85 86 87 88 89 90 |
# File 'lib/has_messages/models/message_recipient.rb', line 79 def reply = self..class.new(:subject => subject, :body => body) .sender = receiver .to(sender) # use the very first message to anchor all replies if self.. . = self.. else . = self. end end |
#reply_to_all ⇒ Object
Replies to all recipients on this message, including the original subject and body in the new message. All receivers (sender, direct, cc, and bcc) are added to the reply.
95 96 97 98 99 100 101 102 103 104 105 106 107 |
# File 'lib/has_messages/models/message_recipient.rb', line 95 def reply_to_all = reply .to( (to + [sender]).uniq ) .cc(cc - [receiver]) .bcc(bcc - [receiver]) # use the very first message to anchor all replies if self.. . = self.. else . = self. end end |