Ver código fonte

fix #1449

INVITE playback (#1409) was buggy, due to the double use of (Item).Params[0]
for the channel name and the recipient nick. Stuff the channel name in
(Item).Message.Message instead.
tags/v2.5.0-rc1
Shivaram Lingamneni 3 anos atrás
pai
commit
853bb12c29
2 arquivos alterados com 16 adições e 10 exclusões
  1. 1
    2
      irc/channel.go
  2. 15
    8
      irc/client.go

+ 1
- 2
irc/channel.go Ver arquivo

@@ -1537,11 +1537,10 @@ func (channel *Channel) Invite(invitee *Client, inviter *Client, rb *ResponseBuf
1537 1537
 	details := inviter.Details()
1538 1538
 	tDetails := invitee.Details()
1539 1539
 	tnick := invitee.Nick()
1540
-	message := utils.MakeMessage("")
1540
+	message := utils.MakeMessage(chname)
1541 1541
 	item := history.Item{
1542 1542
 		Type:    history.Invite,
1543 1543
 		Message: message,
1544
-		Params:  [1]string{chname},
1545 1544
 	}
1546 1545
 
1547 1546
 	for _, member := range channel.Members() {

+ 15
- 8
irc/client.go Ver arquivo

@@ -1058,16 +1058,28 @@ func (client *Client) replayPrivmsgHistory(rb *ResponseBuffer, items []history.I
1058 1058
 	}
1059 1059
 	batchID = rb.StartNestedHistoryBatch(target)
1060 1060
 
1061
+	isSelfMessage := func(item *history.Item) bool {
1062
+		// XXX: Params[0] is the message target. if the source of this message is an in-memory
1063
+		// buffer, then it's "" for an incoming message and the recipient's nick for an outgoing
1064
+		// message. if the source of the message is mysql, then mysql only sees one copy of the
1065
+		// message, and it's the version with the recipient's nick filled in. so this is an
1066
+		// incoming message if Params[0] (the recipient's nick) equals the client's nick:
1067
+		return item.Params[0] != "" && item.Params[0] != nick
1068
+	}
1069
+
1061 1070
 	hasEventPlayback := rb.session.capabilities.Has(caps.EventPlayback)
1062 1071
 	hasTags := rb.session.capabilities.Has(caps.MessageTags)
1063 1072
 	for _, item := range items {
1064 1073
 		var command string
1065 1074
 		switch item.Type {
1066 1075
 		case history.Invite:
1076
+			if isSelfMessage(&item) {
1077
+				continue
1078
+			}
1067 1079
 			if hasEventPlayback {
1068
-				rb.AddFromClient(item.Message.Time, item.Message.Msgid, item.Nick, item.AccountName, nil, "INVITE", item.Params[0])
1080
+				rb.AddFromClient(item.Message.Time, item.Message.Msgid, item.Nick, item.AccountName, nil, "INVITE", nick, item.Message.Message)
1069 1081
 			} else {
1070
-				rb.AddFromClient(item.Message.Time, utils.MungeSecretToken(item.Message.Msgid), histservService.prefix, "*", nil, "PRIVMSG", fmt.Sprintf(client.t("%[1]s invited you to channel %[2]s"), stripMaskFromNick(item.Nick), item.Params[0]))
1082
+				rb.AddFromClient(item.Message.Time, utils.MungeSecretToken(item.Message.Msgid), histservService.prefix, "*", nil, "PRIVMSG", fmt.Sprintf(client.t("%[1]s invited you to channel %[2]s"), stripMaskFromNick(item.Nick), item.Message.Message))
1071 1083
 			}
1072 1084
 			continue
1073 1085
 		case history.Privmsg:
@@ -1087,12 +1099,7 @@ func (client *Client) replayPrivmsgHistory(rb *ResponseBuffer, items []history.I
1087 1099
 		if hasTags {
1088 1100
 			tags = item.Tags
1089 1101
 		}
1090
-		// XXX: Params[0] is the message target. if the source of this message is an in-memory
1091
-		// buffer, then it's "" for an incoming message and the recipient's nick for an outgoing
1092
-		// message. if the source of the message is mysql, then mysql only sees one copy of the
1093
-		// message, and it's the version with the recipient's nick filled in. so this is an
1094
-		// incoming message if Params[0] (the recipient's nick) equals the client's nick:
1095
-		if item.Params[0] == "" || item.Params[0] == nick {
1102
+		if !isSelfMessage(&item) {
1096 1103
 			rb.AddSplitMessageFromClient(item.Nick, item.AccountName, tags, command, nick, item.Message)
1097 1104
 		} else {
1098 1105
 			// this message was sent *from* the client to another nick; the target is item.Params[0]

Carregando…
Cancelar
Salvar