type Message.from as Ident
This commit is contained in:
parent
76647415af
commit
4989bcdb5e
6 changed files with 43 additions and 24 deletions
|
|
@ -277,12 +277,12 @@ impl Broker {
|
|||
// Operator messages get elevated priority so they surface before
|
||||
// queued wakes (bash completions, forge events, etc.) when the
|
||||
// harness pops the next turn driver. All other senders stay at 0.
|
||||
let priority: i64 = i64::from(message.from == "operator");
|
||||
let priority: i64 = i64::from(message.from.as_str() == hive_sh4re::OPERATOR_RECIPIENT);
|
||||
conn.execute(
|
||||
"INSERT INTO messages (sender, recipient, body, sent_at, in_reply_to, priority) \
|
||||
VALUES (?1, ?2, ?3, ?4, ?5, ?6)",
|
||||
params![
|
||||
message.from,
|
||||
message.from.as_str(),
|
||||
message.to,
|
||||
message.body,
|
||||
now,
|
||||
|
|
@ -294,7 +294,7 @@ impl Broker {
|
|||
drop(conn);
|
||||
let _ = self.events.send(MessageEvent::Sent {
|
||||
id: row_id,
|
||||
from: message.from.clone(),
|
||||
from: message.from.to_string(),
|
||||
to: message.to.clone(),
|
||||
body: message.body.clone(),
|
||||
at: now,
|
||||
|
|
@ -664,7 +664,7 @@ impl Broker {
|
|||
id,
|
||||
redelivered,
|
||||
message: Message {
|
||||
from,
|
||||
from: hive_sh4re::trusted_sender(&from),
|
||||
to,
|
||||
body,
|
||||
in_reply_to,
|
||||
|
|
@ -678,7 +678,7 @@ impl Broker {
|
|||
for d in &deliveries {
|
||||
let _ = self.events.send(MessageEvent::Delivered {
|
||||
id: d.id,
|
||||
from: d.message.from.clone(),
|
||||
from: d.message.from.to_string(),
|
||||
to: d.message.to.clone(),
|
||||
body: d.message.body.clone(),
|
||||
at: now,
|
||||
|
|
@ -1187,7 +1187,7 @@ mod tests {
|
|||
|
||||
fn msg(from: &str, to: &str, body: &str) -> Message {
|
||||
Message {
|
||||
from: from.to_owned(),
|
||||
from: hive_types::Ident::parse(from).expect("test sender must be a valid ident"),
|
||||
to: to.to_owned(),
|
||||
body: body.to_owned(),
|
||||
in_reply_to: None,
|
||||
|
|
@ -1475,7 +1475,7 @@ mod tests {
|
|||
assert_eq!(batch.len(), 3);
|
||||
// Operator message surfaces first despite arriving last.
|
||||
assert_eq!(batch[0].message.body, "stop what you're doing");
|
||||
assert_eq!(batch[0].message.from, "operator");
|
||||
assert_eq!(batch[0].message.from.as_str(), "operator");
|
||||
// Remaining two in FIFO order.
|
||||
assert_eq!(batch[1].message.body, "task done");
|
||||
assert_eq!(batch[2].message.body, "new pr");
|
||||
|
|
|
|||
Loading…
Reference in a new issue