3
0
mirror of https://github.com/ergochat/ergo.git synced 2024-11-11 06:29:29 +01:00

Merge pull request #1324 from slingamn/chathistory_empty

fix #1322
This commit is contained in:
Shivaram Lingamneni 2020-10-13 06:22:51 -07:00 committed by GitHub
commit 38fe931656
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -550,25 +550,24 @@ func chathistoryHandler(server *Server, client *Client, msg ircmsg.IrcMessage, r
var sequence history.Sequence var sequence history.Sequence
var err error var err error
defer func() { defer func() {
// errors are sent either without a batch, or in a draft/labeled-response batch as usual
if unknown_command {
rb.Add(nil, server.name, "FAIL", "CHATHISTORY", "UNKNOWN_COMMAND", utils.SafeErrorParam(msg.Params[0]), client.t("Unknown command"))
} else if err == utils.ErrInvalidParams {
rb.Add(nil, server.name, "FAIL", "CHATHISTORY", "INVALID_PARAMS", msg.Params[0], client.t("Invalid parameters"))
} else if sequence == nil {
// send an empty batch as per the spec
batchID := rb.StartNestedHistoryBatch(utils.SafeErrorParam(target))
rb.EndNestedBatch(batchID)
} else if err != nil {
rb.Add(nil, server.name, "FAIL", "CHATHISTORY", "MESSAGE_ERROR", msg.Params[0], client.t("Messages could not be retrieved"))
} else {
// successful responses are sent as a chathistory or history batch // successful responses are sent as a chathistory or history batch
if err == nil {
if channel != nil { if channel != nil {
channel.replayHistoryItems(rb, items, false) channel.replayHistoryItems(rb, items, false)
} else { } else {
client.replayPrivmsgHistory(rb, items, target, true) client.replayPrivmsgHistory(rb, items, target, true)
} }
return
}
// errors are sent either without a batch, or in a draft/labeled-response batch as usual
if unknown_command {
rb.Add(nil, server.name, "FAIL", "CHATHISTORY", "UNKNOWN_COMMAND", utils.SafeErrorParam(msg.Params[0]), client.t("Unknown command"))
} else if err == utils.ErrInvalidParams {
rb.Add(nil, server.name, "FAIL", "CHATHISTORY", "INVALID_PARAMETERS", msg.Params[0], client.t("Invalid parameters"))
} else if err != nil {
rb.Add(nil, server.name, "FAIL", "CHATHISTORY", "MESSAGE_ERROR", msg.Params[0], client.t("Messages could not be retrieved"))
} else if sequence == nil {
rb.Add(nil, server.name, "FAIL", "CHATHISTORY", "NO_SUCH_CHANNEL", utils.SafeErrorParam(msg.Params[1]), client.t("No such channel"))
} }
}() }()