Skip to content

Commit

Permalink
Remove operator listing and verification
Browse files Browse the repository at this point in the history
Assume that the bot will only be added to rooms containing people that
should be able to make changes.
  • Loading branch information
DanNixon committed Nov 15, 2023
1 parent 1ed5416 commit 97451a7
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 41 deletions.
4 changes: 1 addition & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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'
```
13 changes: 0 additions & 13 deletions src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
14 changes: 0 additions & 14 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<OwnedUserId>,

/// Matrix rooms to send messages to and listen for commands from
#[clap(value_parser, long = "room")]
matrix_rooms: Vec<OwnedRoomId>,
Expand All @@ -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::<Vec<String>>()
.join(", ")
}
}

#[tokio::main]
async fn main() -> Result<()> {
tracing_subscriber::fmt::init();
Expand Down
13 changes: 2 additions & 11 deletions src/processing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,7 @@ pub(crate) fn run_task(
match event.try_into() {
Ok::<CommandEvent, _>(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: {}",
Expand Down Expand Up @@ -115,11 +110,9 @@ pub(crate) fn run_task(
"
[matrix-remote-closedown](https://github.com/DanNixon/matrix-remote-closedown) for station **{}**.<br>
Usage: !{} COMMAND<br>
Commands: help, shutdown, power on, power off, ptt enable, ptt disable<br>
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,
Expand Down Expand Up @@ -226,10 +219,8 @@ pub(crate) fn run_task(
&config,
&format!(
"
({})<br>
**{}** at {}<br>
Message: {}",
config.station_operators_string_list(),
config.station_name,
msg.timestamp,
m,
Expand Down

0 comments on commit 97451a7

Please sign in to comment.