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