Skip to content

Commit

Permalink
Add support for backward CHATHISTORY BETWEEN
Browse files Browse the repository at this point in the history
https://ircv3.net/specs/extensions/chathistory#between says
"This may be forwards or backwards in time."
  • Loading branch information
progval authored and spb committed Jul 2, 2024
1 parent 6dc4903 commit a4432bc
Showing 1 changed file with 25 additions and 9 deletions.
34 changes: 25 additions & 9 deletions sable_history/src/local_history.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,15 +109,31 @@ impl HistoryService for NetworkHistoryLog {
start_ts,
end_ts,
limit,
} => get_history_for_target(
self,
user,
target,
Some(start_ts),
Some(end_ts),
0, // Backward limit
limit,
),
} => {
if start_ts <= end_ts {
get_history_for_target(
self,
user,
target,
Some(start_ts),
Some(end_ts),
0, // Backward limit
limit,
)
} else {
// Search backward from start_ts instead of swapping start_ts and end_ts,
// because we want to match the last messages first in case we reach the limit
get_history_for_target(
self,
user,
target,
Some(start_ts),
Some(end_ts),
limit,
0, // Forward limit
)
}
}
}
}
}
Expand Down

0 comments on commit a4432bc

Please sign in to comment.