rename admin safety numbers to admin_signal_uuids
This commit is contained in:
@@ -190,7 +190,7 @@ signal_account = "+15551234567"
|
|||||||
signal_cli_tcp_addr = "127.0.0.1:7583"
|
signal_cli_tcp_addr = "127.0.0.1:7583"
|
||||||
signal_cli_retry_delay = "10s"
|
signal_cli_retry_delay = "10s"
|
||||||
|
|
||||||
[admin_safety_numbers]
|
[admin_signal_uuids]
|
||||||
"abc-123-uuid" = ["12345 67890 12345 67890 12345 67890"]
|
"abc-123-uuid" = ["12345 67890 12345 67890 12345 67890"]
|
||||||
"def-456-uuid" = []
|
"def-456-uuid" = []
|
||||||
|
|
||||||
@@ -243,8 +243,8 @@ limits = [
|
|||||||
config.gateway.signal_cli_retry_delay,
|
config.gateway.signal_cli_retry_delay,
|
||||||
Duration::from_secs(10)
|
Duration::from_secs(10)
|
||||||
);
|
);
|
||||||
assert_eq!(config.gateway.admin_safety_numbers.len(), 2);
|
assert_eq!(config.gateway.admin_signal_uuids.len(), 2);
|
||||||
assert!(config.gateway.admin_safety_numbers.contains_key("abc-123-uuid"));
|
assert!(config.gateway.admin_signal_uuids.contains_key("abc-123-uuid"));
|
||||||
|
|
||||||
let syslog = config.syslog.expect("syslog should be present");
|
let syslog = config.syslog.expect("syslog should be present");
|
||||||
assert_eq!(syslog.listen_addr, "0.0.0.0:1514".parse().unwrap());
|
assert_eq!(syslog.listen_addr, "0.0.0.0:1514".parse().unwrap());
|
||||||
|
|||||||
@@ -69,7 +69,7 @@ pub struct GatewayConfig {
|
|||||||
/// Admin UUIDs mapped to their safety numbers (can be empty).
|
/// Admin UUIDs mapped to their safety numbers (can be empty).
|
||||||
/// Example: `{"uuid1": ["12345...", "67890..."], "uuid2": []}`
|
/// Example: `{"uuid1": ["12345...", "67890..."], "uuid2": []}`
|
||||||
#[conf(long, env, value_parser = serde_json::from_str)]
|
#[conf(long, env, value_parser = serde_json::from_str)]
|
||||||
pub admin_safety_numbers: HashMap<String, Vec<String>>,
|
pub admin_signal_uuids: HashMap<String, Vec<String>>,
|
||||||
/// If set, alerts are sent to this group instead of individual admins.
|
/// If set, alerts are sent to this group instead of individual admins.
|
||||||
#[conf(long, env)]
|
#[conf(long, env)]
|
||||||
pub alert_group_id: Option<String>,
|
pub alert_group_id: Option<String>,
|
||||||
@@ -84,12 +84,12 @@ pub struct GatewayConfig {
|
|||||||
impl GatewayConfig {
|
impl GatewayConfig {
|
||||||
/// Check if a UUID is a registered admin
|
/// Check if a UUID is a registered admin
|
||||||
pub fn is_admin(&self, uuid: &str) -> bool {
|
pub fn is_admin(&self, uuid: &str) -> bool {
|
||||||
self.admin_safety_numbers.contains_key(uuid)
|
self.admin_signal_uuids.contains_key(uuid)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Get all admin UUIDs
|
/// Get all admin UUIDs
|
||||||
pub fn admin_uuids(&self) -> Vec<String> {
|
pub fn admin_uuids(&self) -> Vec<String> {
|
||||||
self.admin_safety_numbers.keys().cloned().collect()
|
self.admin_signal_uuids.keys().cloned().collect()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -320,7 +320,7 @@ impl Gateway {
|
|||||||
/// 2. If any trusted identity is NOT in our config, remove the contact entirely and re-add only configured ones
|
/// 2. If any trusted identity is NOT in our config, remove the contact entirely and re-add only configured ones
|
||||||
/// 3. Otherwise, just trust any new safety numbers from config that aren't already trusted
|
/// 3. Otherwise, just trust any new safety numbers from config that aren't already trusted
|
||||||
async fn update_trust(&self, signal_cli: &impl RpcClient) {
|
async fn update_trust(&self, signal_cli: &impl RpcClient) {
|
||||||
for (uuid, safety_numbers) in &self.config.admin_safety_numbers {
|
for (uuid, safety_numbers) in &self.config.admin_signal_uuids {
|
||||||
if safety_numbers.is_empty() {
|
if safety_numbers.is_empty() {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user