From 97451a7a11f47b349a46ee78b02647b676444ad9 Mon Sep 17 00:00:00 2001 From: Dan Nixon Date: Wed, 15 Nov 2023 17:34:21 +0000 Subject: [PATCH] Remove operator listing and verification Assume that the bot will only be added to rooms containing people that should be able to make changes. --- README.md | 4 +--- src/command.rs | 13 ------------- src/main.rs | 14 -------------- src/processing.rs | 13 ++----------- 4 files changed, 3 insertions(+), 41 deletions(-) diff --git a/README.md b/README.md index 7a63c6c..03d8cfd 100644 --- a/README.md +++ b/README.md @@ -26,7 +26,5 @@ podman run \ --matrix-username '@mb7pmf:matrix.org' \ --matrix-password 'super_secret' \ --room '!some_room:matrix.org' \ - --room '!some_other_room:matrix.org' \ - --operator '@dannixon:matrix.org' - --operator '@someone_else:matrix.org' + --room '!some_other_room:matrix.org' ``` diff --git a/src/command.rs b/src/command.rs index 1c95614..38b8243 100644 --- a/src/command.rs +++ b/src/command.rs @@ -45,19 +45,6 @@ pub(crate) enum Operation { PttDisable, } -impl Operation { - pub(crate) fn is_operator_only(&self) -> bool { - match self { - Self::Help => false, - Self::Shutdown => true, - Self::PowerOff => true, - Self::PowerOn => true, - Self::PttEnable => true, - Self::PttDisable => true, - } - } -} - impl TryFrom<&[&str]> for Operation { type Error = Error; diff --git a/src/main.rs b/src/main.rs index 7350d04..4b0cae8 100644 --- a/src/main.rs +++ b/src/main.rs @@ -89,10 +89,6 @@ struct Cli { #[clap(value_parser, long, env = "STATION_NAME")] station_name: String, - /// Station operator Matrix IDs - #[clap(value_parser, long = "operator")] - station_operators: Vec, - /// Matrix rooms to send messages to and listen for commands from #[clap(value_parser, long = "room")] matrix_rooms: Vec, @@ -107,16 +103,6 @@ struct Cli { observability_address: SocketAddr, } -impl Cli { - pub(crate) fn station_operators_string_list(&self) -> String { - self.station_operators - .iter() - .map(|i| i.to_string()) - .collect::>() - .join(", ") - } -} - #[tokio::main] async fn main() -> Result<()> { tracing_subscriber::fmt::init(); diff --git a/src/processing.rs b/src/processing.rs index 3971fdd..d980326 100644 --- a/src/processing.rs +++ b/src/processing.rs @@ -70,12 +70,7 @@ pub(crate) fn run_task( match event.try_into() { Ok::(cmd_event) => { if cmd_event.cmd.station_name == config.station_name { - let op_only_command = cmd_event.cmd.op.is_operator_only(); - if !op_only_command || config.station_operators.contains(&sender) { - crate::send_event!(tx, Event::CommandReceive(cmd_event)); - } else { - log::info!("Ignoring operator only command issued by {}, who is not an operator", sender); - } + crate::send_event!(tx, Event::CommandReceive(cmd_event)); } else { log::debug!( "Ignoring command with unknown station name: {}", @@ -115,11 +110,9 @@ pub(crate) fn run_task( " [matrix-remote-closedown](https://github.com/DanNixon/matrix-remote-closedown) for station **{}**.
Usage: !{} COMMAND
- Commands: help, shutdown, power on, power off, ptt enable, ptt disable
- Station operators: {}", + Commands: help, shutdown, power on, power off, ptt enable, ptt disable", config.station_name, config.station_name, - config.station_operators_string_list(), ).unindent() ), None, @@ -226,10 +219,8 @@ pub(crate) fn run_task( &config, &format!( " - ({})
**{}** at {}
Message: {}", - config.station_operators_string_list(), config.station_name, msg.timestamp, m,