3
0
mirror of https://github.com/ergochat/ergo.git synced 2024-11-26 13:59:44 +01:00

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

This commit is contained in:
Shivaram Lingamneni 2019-02-04 12:31:44 -05:00
parent 51fcedc5a1
commit 463de94610
2 changed files with 34 additions and 18 deletions

View File

@ -566,15 +566,20 @@ func chathistoryHandler(server *Server, client *Client, msg ircmsg.IrcMessage, r
target := msg.Params[0] target := msg.Params[0]
channel = server.channels.Get(target) channel = server.channels.Get(target)
if channel == nil { if channel != nil {
cftarget, _ := Casefold(target)
if cftarget == "me" || cftarget == "self" || cftarget == client.NickCasefolded() {
hist = client.history
} else {
return
}
} else {
hist = &channel.history hist = &channel.history
} else {
targetClient := server.clients.Get(target)
if targetClient != nil {
myAccount := client.Account()
targetAccount := targetClient.Account()
if myAccount != "" && targetAccount != "" && myAccount == targetAccount {
hist = targetClient.history
}
}
}
if hist == nil {
return
} }
preposition := strings.ToLower(msg.Params[1]) preposition := strings.ToLower(msg.Params[1])
@ -1013,16 +1018,25 @@ func historyHandler(server *Server, client *Client, msg ircmsg.IrcMessage, rb *R
target := msg.Params[0] target := msg.Params[0]
var hist *history.Buffer var hist *history.Buffer
channel := server.channels.Get(target) channel := server.channels.Get(target)
if channel == nil { if channel != nil {
cftarget, _ := Casefold(target) hist = &channel.history
if cftarget == "me" || cftarget == "self" || cftarget == client.NickCasefolded() { } else {
if strings.ToLower(target) == "me" {
hist = client.history hist = client.history
} else { } else {
rb.Add(nil, server.name, ERR_NOSUCHCHANNEL, client.Nick(), target, client.t("No such channel")) targetClient := server.clients.Get(target)
return false if targetClient != nil {
myAccount, targetAccount := client.Account(), targetClient.Account()
if myAccount != "" && targetAccount != "" && myAccount == targetAccount {
hist = targetClient.history
}
}
} }
} else { }
hist = &channel.history
if hist == nil {
rb.Add(nil, server.name, ERR_NOSUCHCHANNEL, client.Nick(), target, client.t("No such channel"))
return false
} }
limit := 10 limit := 10

View File

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