LTe / acts-as-messageable

Gem that allows communication between the models.

Home Page:http://lte.github.io/acts-as-messageable/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Bug in replying to conversation

johnroa opened this issue · comments

@john = User.first # id 1
@dave = User.last # id 2

msg = @dave.send_message(@john, "hello", "how are you?") # id 1, ancestry nil, sender 1, receiver 2
@john.reply_to(msg, "ohey", "working?") # id 2, ancestry 1, sender 2, receiver 1

# That part works fine. But, if you already have a conversation and do this...

msg = ActsAsMessageable::Message.find_by_id(1) # I could not find another way to pull up the root message of a conversation without doing a find for its ID?
@dave.reply_to(msg, "fail", "this is where it breaks") # id 3, ancestry 1 [correct], sender 2 [correct], receiver 2 [incorrect]

# In a nutshell, if you don't have the object stored from the result of a "send message" and have to query for it directly, it marks both the sender and the receiver as the same ID if you do a reply_to

To simply expound on this issue:

If "A" sends a message to "B". And then wants to send a second message. "A" is responding to their own first message (in order to keep it in a conversation), which makes "A" the sender and receiver of that message.

@johnroa thanks for this issue. I created today fix for this ;)