hive-c0re: deliver scheduled prompts via push_todo, not a broker message
This commit is contained in:
parent
7c6f108716
commit
68560215bd
3 changed files with 114 additions and 134 deletions
|
|
@ -354,25 +354,6 @@ impl Broker {
|
|||
Ok(u64::try_from(n.max(0)).unwrap_or(0))
|
||||
}
|
||||
|
||||
/// Returns true when the recipient already has at least one
|
||||
/// undelivered message from `sender` with exactly `body` in the
|
||||
/// broker. Used by the scheduler to skip re-delivery of the same
|
||||
/// scheduled prompt without blocking distinct schedules whose
|
||||
/// bodies differ.
|
||||
pub fn has_pending_with_body(&self, recipient: &str, sender: &str, body: &str) -> Result<bool> {
|
||||
let conn = self.conn.lock().unwrap();
|
||||
// An `ack_until`-closed pending row is dead — it must not
|
||||
// suppress a fresh scheduled delivery of the same body.
|
||||
let n: i64 = conn.query_row(
|
||||
"SELECT COUNT(*) FROM messages
|
||||
WHERE recipient = ?1 AND sender = ?2 AND body = ?3
|
||||
AND delivered_at IS NULL AND acked_at IS NULL",
|
||||
params![recipient, sender, body],
|
||||
|row| row.get(0),
|
||||
)?;
|
||||
Ok(n > 0)
|
||||
}
|
||||
|
||||
/// Send a "your parent changed from X to Y" notification to `child`,
|
||||
/// coalescing with any existing undelivered one so that multiple moves
|
||||
/// while the agent is offline collapse into a single message spanning
|
||||
|
|
|
|||
Loading…
Reference in a new issue