respect destination override for outbound messages
This commit is contained in:
@@ -188,12 +188,13 @@ impl LogHandler {
|
|||||||
|
|
||||||
// Send alert if we have formatted text
|
// Send alert if we have formatted text
|
||||||
if let Some(text) = formatted_text {
|
if let Some(text) = formatted_text {
|
||||||
// TODO: Use destination override from rate_limit_result.ok() if present
|
let destination_override = rate_limit_result.ok().flatten();
|
||||||
if let Err(_err) = self.admin_mq_tx.send(AdminMessage {
|
if let Err(_err) = self.admin_mq_tx.send(AdminMessage {
|
||||||
origin: Some(origin),
|
origin: Some(origin),
|
||||||
text,
|
text,
|
||||||
attachment_paths: Default::default(),
|
attachment_paths: Default::default(),
|
||||||
summary: None,
|
summary: None,
|
||||||
|
destination_override,
|
||||||
}) {
|
}) {
|
||||||
error!("Could not send alert message, queue is closed");
|
error!("Could not send alert message, queue is closed");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -170,6 +170,9 @@ struct AdminMessage {
|
|||||||
/// Short summary for logging (e.g., alert names for prometheus).
|
/// Short summary for logging (e.g., alert names for prometheus).
|
||||||
/// If None, the consumer will use a truncated slice of `text` for logging.
|
/// If None, the consumer will use a truncated slice of `text` for logging.
|
||||||
summary: Option<String>,
|
summary: Option<String>,
|
||||||
|
/// Optional destination override from route configuration.
|
||||||
|
/// If present, overrides the default alert destination.
|
||||||
|
destination_override: Option<Destination>,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The gateway manages sending messages to signal-cli and receiving messages from signal-cli.
|
/// The gateway manages sending messages to signal-cli and receiving messages from signal-cli.
|
||||||
@@ -390,11 +393,18 @@ impl Gateway {
|
|||||||
msg.text
|
msg.text
|
||||||
};
|
};
|
||||||
let attachments = msg.attachment_paths.into_iter().map(|p| p.to_str().unwrap().to_owned()).collect();
|
let attachments = msg.attachment_paths.into_iter().map(|p| p.to_str().unwrap().to_owned()).collect();
|
||||||
// Send to group if configured, otherwise to individual admins
|
// Use destination override if present, otherwise use configured default
|
||||||
let target = if let Some(group_id) = &self.config.alert_group_id {
|
let target = match msg.destination_override {
|
||||||
MessageTarget::Group(group_id.clone())
|
Some(Destination::Group(group_id)) => MessageTarget::Group(group_id),
|
||||||
} else {
|
Some(Destination::Recipients(recipients)) => MessageTarget::Recipients(recipients),
|
||||||
MessageTarget::Recipients(self.config.admin_uuids())
|
None => {
|
||||||
|
// Send to group if configured, otherwise to individual admins
|
||||||
|
if let Some(group_id) = &self.config.alert_group_id {
|
||||||
|
MessageTarget::Group(group_id.clone())
|
||||||
|
} else {
|
||||||
|
MessageTarget::Recipients(self.config.admin_uuids())
|
||||||
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
SignalMessage {
|
SignalMessage {
|
||||||
sender: self.config.signal_account.clone(),
|
sender: self.config.signal_account.clone(),
|
||||||
@@ -758,6 +768,7 @@ impl Gateway {
|
|||||||
text,
|
text,
|
||||||
attachment_paths,
|
attachment_paths,
|
||||||
summary: Some(summary),
|
summary: Some(summary),
|
||||||
|
destination_override: None,
|
||||||
})
|
})
|
||||||
.map_err(|_err| {
|
.map_err(|_err| {
|
||||||
error!("Could not send alert message, queue is closed");
|
error!("Could not send alert message, queue is closed");
|
||||||
|
|||||||
Reference in New Issue
Block a user