Browse Source

allow history queries against PRIVMSG of other clients, if the accounts match

tags/v1.0.0-rc1
Shivaram Lingamneni 5 years ago
parent
commit
463de94610
2 changed files with 34 additions and 18 deletions
  1. 29
    15
      irc/handlers.go
  2. 5
    3
      irc/help.go

+ 29
- 15
irc/handlers.go View File

@@ -566,15 +566,20 @@ func chathistoryHandler(server *Server, client *Client, msg ircmsg.IrcMessage, r
566 566
 
567 567
 	target := msg.Params[0]
568 568
 	channel = server.channels.Get(target)
569
-	if channel == nil {
570
-		cftarget, _ := Casefold(target)
571
-		if cftarget == "me" || cftarget == "self" || cftarget == client.NickCasefolded() {
572
-			hist = client.history
573
-		} else {
574
-			return
575
-		}
576
-	} else {
569
+	if channel != nil {
577 570
 		hist = &channel.history
571
+	} else {
572
+		targetClient := server.clients.Get(target)
573
+		if targetClient != nil {
574
+			myAccount := client.Account()
575
+			targetAccount := targetClient.Account()
576
+			if myAccount != "" && targetAccount != "" && myAccount == targetAccount {
577
+				hist = targetClient.history
578
+			}
579
+		}
580
+	}
581
+	if hist == nil {
582
+		return
578 583
 	}
579 584
 
580 585
 	preposition := strings.ToLower(msg.Params[1])
@@ -1013,16 +1018,25 @@ func historyHandler(server *Server, client *Client, msg ircmsg.IrcMessage, rb *R
1013 1018
 	target := msg.Params[0]
1014 1019
 	var hist *history.Buffer
1015 1020
 	channel := server.channels.Get(target)
1016
-	if channel == nil {
1017
-		cftarget, _ := Casefold(target)
1018
-		if cftarget == "me" || cftarget == "self" || cftarget == client.NickCasefolded() {
1021
+	if channel != nil {
1022
+		hist = &channel.history
1023
+	} else {
1024
+		if strings.ToLower(target) == "me" {
1019 1025
 			hist = client.history
1020 1026
 		} else {
1021
-			rb.Add(nil, server.name, ERR_NOSUCHCHANNEL, client.Nick(), target, client.t("No such channel"))
1022
-			return false
1027
+			targetClient := server.clients.Get(target)
1028
+			if targetClient != nil {
1029
+				myAccount, targetAccount := client.Account(), targetClient.Account()
1030
+				if myAccount != "" && targetAccount != "" && myAccount == targetAccount {
1031
+					hist = targetClient.history
1032
+				}
1033
+			}
1023 1034
 		}
1024
-	} else {
1025
-		hist = &channel.history
1035
+	}
1036
+
1037
+	if hist == nil {
1038
+		rb.Add(nil, server.name, ERR_NOSUCHCHANNEL, client.Nick(), target, client.t("No such channel"))
1039
+		return false
1026 1040
 	}
1027 1041
 
1028 1042
 	limit := 10

+ 5
- 3
irc/help.go View File

@@ -196,10 +196,12 @@ Get an explanation of <argument>, or "index" for a list of help topics.`,
196 196
 Get an explanation of <argument>, or "index" for a list of help topics.`,
197 197
 	},
198 198
 	"history": {
199
-		text: `HISTSERV <target> [limit]
199
+		text: `HISTORY <target> [limit]
200 200
 
201
-Replay message history. <target> can be a channel name, or "self" or "me"
202
-to replay direct message history. At most [limit] messages will be replayed.`,
201
+Replay message history. <target> can be a channel name, "me" to replay direct
202
+message history, or a nickname to replay another client's direct message
203
+history (they must be logged into the same account as you). At most [limit]
204
+messages will be replayed.`,
203 205
 	},
204 206
 	"hostserv": {
205 207
 		text: `HOSTSERV <command> [params]

Loading…
Cancel
Save