Browse Source

fix #487

tags/v1.1.0-rc1
Shivaram Lingamneni 5 years ago
parent
commit
25974b6881
2 changed files with 17 additions and 4 deletions
  1. 10
    2
      irc/client.go
  2. 7
    2
      irc/handlers.go

+ 10
- 2
irc/client.go View File

600
 
600
 
601
 func (client *Client) replayPrivmsgHistory(rb *ResponseBuffer, items []history.Item, complete bool) {
601
 func (client *Client) replayPrivmsgHistory(rb *ResponseBuffer, items []history.Item, complete bool) {
602
 	var batchID string
602
 	var batchID string
603
-	nick := client.Nick()
603
+	details := client.Details()
604
+	nick := details.nick
604
 	if 0 < len(items) {
605
 	if 0 < len(items) {
605
 		batchID = rb.StartNestedHistoryBatch(nick)
606
 		batchID = rb.StartNestedHistoryBatch(nick)
606
 	}
607
 	}
626
 		if allowTags {
627
 		if allowTags {
627
 			tags = item.Tags
628
 			tags = item.Tags
628
 		}
629
 		}
629
-		rb.AddSplitMessageFromClient(item.Nick, item.AccountName, tags, command, nick, item.Message)
630
+		if item.Params[0] == "" {
631
+			// this message was sent *to* the client from another nick
632
+			rb.AddSplitMessageFromClient(item.Nick, item.AccountName, tags, command, nick, item.Message)
633
+		} else {
634
+			// this message was sent *from* the client to another nick; the target is item.Params[0]
635
+			// substitute the client's current nickmask in case they changed nick
636
+			rb.AddSplitMessageFromClient(details.nickMask, item.AccountName, tags, command, item.Params[0], item.Message)
637
+		}
630
 	}
638
 	}
631
 
639
 
632
 	rb.EndNestedBatch(batchID)
640
 	rb.EndNestedBatch(batchID)

+ 7
- 2
irc/handlers.go View File

2060
 				rb.Add(nil, server.name, RPL_AWAY, cnick, tnick, user.AwayMessage())
2060
 				rb.Add(nil, server.name, RPL_AWAY, cnick, tnick, user.AwayMessage())
2061
 			}
2061
 			}
2062
 
2062
 
2063
-			user.history.Add(history.Item{
2063
+			item := history.Item{
2064
 				Type:        histType,
2064
 				Type:        histType,
2065
 				Message:     splitMsg,
2065
 				Message:     splitMsg,
2066
 				Nick:        nickMaskString,
2066
 				Nick:        nickMaskString,
2067
 				AccountName: accountName,
2067
 				AccountName: accountName,
2068
-			})
2068
+			}
2069
+			// add to the target's history:
2070
+			user.history.Add(item)
2071
+			// add this to the client's history as well, recording the target:
2072
+			item.Params[0] = tnick
2073
+			client.history.Add(item)
2069
 		}
2074
 		}
2070
 	}
2075
 	}
2071
 	return false
2076
 	return false

Loading…
Cancel
Save