瀏覽代碼

fix Client.historyStatus

tags/v2.0.0-rc1
Shivaram Lingamneni 4 年之前
父節點
當前提交
17a89838b8
共有 3 個文件被更改,包括 17 次插入11 次删除
  1. 9
    6
      irc/client.go
  2. 2
    2
      irc/handlers.go
  3. 6
    3
      irc/server.go

+ 9
- 6
irc/client.go 查看文件

353
 }
353
 }
354
 
354
 
355
 func (client *Client) resizeHistory(config *Config) {
355
 func (client *Client) resizeHistory(config *Config) {
356
-	_, ephemeral := client.historyStatus(config)
356
+	_, ephemeral, _ := client.historyStatus(config)
357
 	if ephemeral {
357
 	if ephemeral {
358
 		client.history.Resize(config.History.ClientLength, config.History.AutoresizeWindow)
358
 		client.history.Resize(config.History.ClientLength, config.History.AutoresizeWindow)
359
 	} else {
359
 	} else {
756
 			}
756
 			}
757
 		}
757
 		}
758
 	}
758
 	}
759
-	_, cEphemeral := client.historyStatus(config)
759
+	_, cEphemeral, _ := client.historyStatus(config)
760
 	if cEphemeral {
760
 	if cEphemeral {
761
 		lastDiscarded := client.history.LastDiscarded()
761
 		lastDiscarded := client.history.LastDiscarded()
762
 		if oldestLostMessage.Before(lastDiscarded) {
762
 		if oldestLostMessage.Before(lastDiscarded) {
1543
 	}
1543
 	}
1544
 }
1544
 }
1545
 
1545
 
1546
-func (client *Client) historyStatus(config *Config) (persistent, ephemeral bool) {
1546
+func (client *Client) historyStatus(config *Config) (persistent, ephemeral bool, target string) {
1547
 	if !config.History.Enabled {
1547
 	if !config.History.Enabled {
1548
-		return false, false
1548
+		return
1549
 	} else if !config.History.Persistent.Enabled {
1549
 	} else if !config.History.Persistent.Enabled {
1550
-		return false, true
1550
+		ephemeral = true
1551
+		return
1551
 	}
1552
 	}
1552
 
1553
 
1553
 	client.stateMutex.RLock()
1554
 	client.stateMutex.RLock()
1554
 	alwaysOn := client.alwaysOn
1555
 	alwaysOn := client.alwaysOn
1555
 	historyStatus := client.accountSettings.DMHistory
1556
 	historyStatus := client.accountSettings.DMHistory
1557
+	target = client.nickCasefolded
1556
 	client.stateMutex.RUnlock()
1558
 	client.stateMutex.RUnlock()
1557
 
1559
 
1558
 	if !alwaysOn {
1560
 	if !alwaysOn {
1559
-		return false, true
1561
+		ephemeral = true
1562
+		return
1560
 	}
1563
 	}
1561
 
1564
 
1562
 	historyStatus = historyEnabled(config.History.Persistent.DirectMessages, historyStatus)
1565
 	historyStatus = historyEnabled(config.History.Persistent.DirectMessages, historyStatus)

+ 2
- 2
irc/handlers.go 查看文件

1975
 		}
1975
 		}
1976
 		targetedItem := item
1976
 		targetedItem := item
1977
 		targetedItem.Params[0] = tnick
1977
 		targetedItem.Params[0] = tnick
1978
-		cPersistent, cEphemeral := client.historyStatus(config)
1979
-		tPersistent, tEphemeral := user.historyStatus(config)
1978
+		cPersistent, cEphemeral, _ := client.historyStatus(config)
1979
+		tPersistent, tEphemeral, _ := user.historyStatus(config)
1980
 		// add to ephemeral history
1980
 		// add to ephemeral history
1981
 		if cEphemeral {
1981
 		if cEphemeral {
1982
 			targetedItem.CfCorrespondent = tDetails.nickCasefolded
1982
 			targetedItem.CfCorrespondent = tDetails.nickCasefolded

+ 6
- 3
irc/server.go 查看文件

867
 	var sender, recipient string
867
 	var sender, recipient string
868
 	var hist *history.Buffer
868
 	var hist *history.Buffer
869
 	if target == "*" {
869
 	if target == "*" {
870
-		if client.AlwaysOn() {
871
-			recipient = client.NickCasefolded()
872
-		} else {
870
+		persistent, ephemeral, target := client.historyStatus(config)
871
+		if persistent {
872
+			recipient = target
873
+		} else if ephemeral {
873
 			hist = &client.history
874
 			hist = &client.history
875
+		} else {
876
+			return
874
 		}
877
 		}
875
 	} else {
878
 	} else {
876
 		channel = providedChannel
879
 		channel = providedChannel

Loading…
取消
儲存