Last active
October 26, 2018 10:03
-
-
Save mankind/89b587af295a32717f3673d0ab0377c7 to your computer and use it in GitHub Desktop.
rails Mail-boxer notes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#send a message between two users. This will create a Mailoxer::Conversation behind the scene. | |
user_1 = User.where(email: 'user email').first | |
user_2 = User.where(email: 'user email').first | |
message_subject = "Review of work" | |
message_body = "Kindly look at my submitted work" | |
user_1.send_message(user_2, message_body , message_subject) | |
#starting Mail_boxer::Conversation | |
a = Mailboxer::Conversation.find(1) | |
yy = a.mesages | |
b = Mailboxer::Message.find(1) | |
c = b.sender | |
d = c.mailbox.sentbox | |
f = c.mailbox.sentbox.first | |
s = f.participants.reject { |u| u.id == c.id } | |
#get the participants id | |
h = s[0]['id'] | |
###s fetch conversation from user messages | |
a = user.find(1) | |
b = a.messages | |
c = b.each {|r| r.conversation } | |
##replying to conversation approach 1 | |
h = Mailboxer::Conversation.find(1) | |
g = h.messages | |
p = h.messages.last | |
a = User.find(1) | |
b = User.find(2) | |
tt = b.reply_to_conversation(h, 'great', 'hi') | |
###replying to conversation approach 2 | |
a = User.find(1) | |
b = User.find(2) | |
#note 'h' is a receipt object and belongs_to message | |
#which in turn belongs_to conversation | |
h = a.send_message(b, 'tutorial request', 'teach me chemistry') | |
g = h.message | |
f = g.conversation | |
b.reply_to_conversation(f, 'great', 'hi') | |
#fetch 1st conversation thru user | |
w = a.mailbox.inbox.first | |
#2 ways to get the participants in a conversation | |
z = w.participants | |
z = w.recipients | |
##Returns the receipts of the conversation for one participants | |
q = w.receipts_for(a) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment