Browse Source

fix Client.historyStatus

tags/v2.0.0-rc1
Shivaram Lingamneni 4 years ago
parent
commit
17a89838b8
3 changed files with 17 additions and 11 deletions
  1. 9
    6
      irc/client.go
  2. 2
    2
      irc/handlers.go
  3. 6
    3
      irc/server.go

+ 9
- 6
irc/client.go View File

@@ -353,7 +353,7 @@ func (server *Server) AddAlwaysOnClient(account ClientAccount, chnames []string)
353 353
 }
354 354
 
355 355
 func (client *Client) resizeHistory(config *Config) {
356
-	_, ephemeral := client.historyStatus(config)
356
+	_, ephemeral, _ := client.historyStatus(config)
357 357
 	if ephemeral {
358 358
 		client.history.Resize(config.History.ClientLength, config.History.AutoresizeWindow)
359 359
 	} else {
@@ -756,7 +756,7 @@ func (session *Session) playResume() {
756 756
 			}
757 757
 		}
758 758
 	}
759
-	_, cEphemeral := client.historyStatus(config)
759
+	_, cEphemeral, _ := client.historyStatus(config)
760 760
 	if cEphemeral {
761 761
 		lastDiscarded := client.history.LastDiscarded()
762 762
 		if oldestLostMessage.Before(lastDiscarded) {
@@ -1543,20 +1543,23 @@ func (client *Client) attemptAutoOper(session *Session) {
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 1547
 	if !config.History.Enabled {
1548
-		return false, false
1548
+		return
1549 1549
 	} else if !config.History.Persistent.Enabled {
1550
-		return false, true
1550
+		ephemeral = true
1551
+		return
1551 1552
 	}
1552 1553
 
1553 1554
 	client.stateMutex.RLock()
1554 1555
 	alwaysOn := client.alwaysOn
1555 1556
 	historyStatus := client.accountSettings.DMHistory
1557
+	target = client.nickCasefolded
1556 1558
 	client.stateMutex.RUnlock()
1557 1559
 
1558 1560
 	if !alwaysOn {
1559
-		return false, true
1561
+		ephemeral = true
1562
+		return
1560 1563
 	}
1561 1564
 
1562 1565
 	historyStatus = historyEnabled(config.History.Persistent.DirectMessages, historyStatus)

+ 2
- 2
irc/handlers.go View File

@@ -1975,8 +1975,8 @@ func dispatchMessageToTarget(client *Client, tags map[string]string, histType hi
1975 1975
 		}
1976 1976
 		targetedItem := item
1977 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 1980
 		// add to ephemeral history
1981 1981
 		if cEphemeral {
1982 1982
 			targetedItem.CfCorrespondent = tDetails.nickCasefolded

+ 6
- 3
irc/server.go View File

@@ -867,10 +867,13 @@ func (server *Server) GetHistorySequence(providedChannel *Channel, client *Clien
867 867
 	var sender, recipient string
868 868
 	var hist *history.Buffer
869 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 874
 			hist = &client.history
875
+		} else {
876
+			return
874 877
 		}
875 878
 	} else {
876 879
 		channel = providedChannel

Loading…
Cancel
Save