Skip to content

Commit

Permalink
chathistory: Fix order of entries on LATEST/BEFORE/AROUND subcommand
Browse files Browse the repository at this point in the history
  • Loading branch information
progval authored and spb committed Apr 14, 2024
1 parent 251e1f9 commit fe337a0
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions sable_ircd/src/command/handlers/chathistory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@ fn send_history_for_target_forward(
}
}

send_history_entries(into, subcommand, target, entries)
send_history_entries(into, subcommand, target, entries.into_iter())
}

// As above, but work backwards
Expand Down Expand Up @@ -408,16 +408,19 @@ fn send_history_for_target_reverse(
}
}

send_history_entries(into, subcommand, target, entries)
// "The order of returned messages within the batch is implementation-defined, but SHOULD be
// ascending time order or some approximation thereof, regardless of the subcommand used."
// -- https://ircv3.net/specs/extensions/chathistory#returned-message-notes
send_history_entries(into, subcommand, target, entries.into_iter().rev())
}

fn send_history_entries(
fn send_history_entries<'a>(
into: impl MessageSink,
subcommand: &str,
target: &str,
entries: Vec<&HistoryLogEntry>,
entries: impl ExactSizeIterator<Item = &'a HistoryLogEntry>,
) -> CommandResult {
if entries.is_empty() {
if entries.len() == 0 {
into.send(message::Fail::new(
"CHATHISTORY",
"INVALID_TARGET",
Expand Down

0 comments on commit fe337a0

Please sign in to comment.