Browse Source

fix #760

tags/v2.0.0-rc1
Shivaram Lingamneni 4 years ago
parent
commit
fd46874ad3
2 changed files with 11 additions and 8 deletions
  1. 1
    1
      irc/channel.go
  2. 10
    7
      irc/znc.go

+ 1
- 1
irc/channel.go View File

@@ -704,7 +704,7 @@ func (channel *Channel) autoReplayHistory(client *Client, rb *ResponseBuffer, sk
704 704
 	// autoreplay any messages as necessary
705 705
 	config := channel.server.Config()
706 706
 	var items []history.Item
707
-	if rb.session.zncPlaybackTimes != nil && (rb.session.zncPlaybackTimes.targets == nil || rb.session.zncPlaybackTimes.targets[channel.NameCasefolded()]) {
707
+	if rb.session.zncPlaybackTimes != nil && (rb.session.zncPlaybackTimes.targets == nil || rb.session.zncPlaybackTimes.targets.Has(channel.NameCasefolded())) {
708 708
 		items, _ = channel.history.Between(rb.session.zncPlaybackTimes.after, rb.session.zncPlaybackTimes.before, false, config.History.ChathistoryMax)
709 709
 	} else if !rb.session.HasHistoryCaps() {
710 710
 		var replayLimit int

+ 10
- 7
irc/znc.go View File

@@ -49,7 +49,7 @@ func zncWireTimeToTime(str string) (result time.Time) {
49 49
 type zncPlaybackTimes struct {
50 50
 	after   time.Time
51 51
 	before  time.Time
52
-	targets map[string]bool // nil for "*" (everything), otherwise the channel names
52
+	targets StringSet // nil for "*" (everything), otherwise the channel names
53 53
 }
54 54
 
55 55
 // https://wiki.znc.in/Playback
@@ -71,12 +71,13 @@ func zncPlaybackHandler(client *Client, command string, params []string, rb *Res
71 71
 		before = zncWireTimeToTime(params[3])
72 72
 	}
73 73
 
74
-	var targets map[string]bool
74
+	var targets StringSet
75 75
 
76 76
 	// three cases:
77 77
 	// 1. the user's PMs get played back immediately upon receiving this
78 78
 	// 2. if this is a new connection (from the server's POV), save the information
79
-	// and use it to process subsequent joins
79
+	// and use it to process subsequent joins. (This is the Textual behavior:
80
+	// first send the playback PRIVMSG, then send the JOIN lines.)
80 81
 	// 3. if this is a reattach (from the server's POV), immediately play back
81 82
 	// history for channels that the client is already joined to. In this scenario,
82 83
 	// there are three total attempts to play the history:
@@ -96,9 +97,9 @@ func zncPlaybackHandler(client *Client, command string, params []string, rb *Res
96 97
 		for _, targetName := range strings.Split(targetString, ",") {
97 98
 			if cfTarget, err := CasefoldChannel(targetName); err == nil {
98 99
 				if targets == nil {
99
-					targets = make(map[string]bool)
100
+					targets = make(StringSet)
100 101
 				}
101
-				targets[cfTarget] = true
102
+				targets.Add(cfTarget)
102 103
 			}
103 104
 		}
104 105
 	}
@@ -110,7 +111,9 @@ func zncPlaybackHandler(client *Client, command string, params []string, rb *Res
110 111
 	}
111 112
 
112 113
 	for _, channel := range client.Channels() {
113
-		channel.autoReplayHistory(client, rb, "")
114
-		rb.Flush(true)
114
+		if targets == nil || targets.Has(channel.NameCasefolded()) {
115
+			channel.autoReplayHistory(client, rb, "")
116
+			rb.Flush(true)
117
+		}
115 118
 	}
116 119
 }

Loading…
Cancel
Save