From 25974b6881112b30583cceeab8a3e5fd6cd7a817 Mon Sep 17 00:00:00 2001 From: Shivaram Lingamneni Date: Sun, 19 May 2019 02:14:36 -0400 Subject: [PATCH] fix #487 --- irc/client.go | 12 ++++++++++-- irc/handlers.go | 9 +++++++-- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/irc/client.go b/irc/client.go index 3bd371ca..33dfe9a1 100644 --- a/irc/client.go +++ b/irc/client.go @@ -600,7 +600,8 @@ func (client *Client) tryResumeChannels() { func (client *Client) replayPrivmsgHistory(rb *ResponseBuffer, items []history.Item, complete bool) { var batchID string - nick := client.Nick() + details := client.Details() + nick := details.nick if 0 < len(items) { batchID = rb.StartNestedHistoryBatch(nick) } @@ -626,7 +627,14 @@ func (client *Client) replayPrivmsgHistory(rb *ResponseBuffer, items []history.I if allowTags { tags = item.Tags } - rb.AddSplitMessageFromClient(item.Nick, item.AccountName, tags, command, nick, item.Message) + if item.Params[0] == "" { + // this message was sent *to* the client from another nick + rb.AddSplitMessageFromClient(item.Nick, item.AccountName, tags, command, nick, item.Message) + } else { + // this message was sent *from* the client to another nick; the target is item.Params[0] + // substitute the client's current nickmask in case they changed nick + rb.AddSplitMessageFromClient(details.nickMask, item.AccountName, tags, command, item.Params[0], item.Message) + } } rb.EndNestedBatch(batchID) diff --git a/irc/handlers.go b/irc/handlers.go index 0745074d..88abf70e 100644 --- a/irc/handlers.go +++ b/irc/handlers.go @@ -2060,12 +2060,17 @@ func messageHandler(server *Server, client *Client, msg ircmsg.IrcMessage, rb *R rb.Add(nil, server.name, RPL_AWAY, cnick, tnick, user.AwayMessage()) } - user.history.Add(history.Item{ + item := history.Item{ Type: histType, Message: splitMsg, Nick: nickMaskString, AccountName: accountName, - }) + } + // add to the target's history: + user.history.Add(item) + // add this to the client's history as well, recording the target: + item.Params[0] = tnick + client.history.Add(item) } } return false