From 9de74d05a93a9425d7dcd913820051f9bf90bc60 Mon Sep 17 00:00:00 2001 From: projectmoon Date: Fri, 21 May 2021 15:32:08 +0000 Subject: [PATCH] Add an is_secure attribute for commands. --- src/commands/basic_rolling.rs | 4 ++++ src/commands/cofd.rs | 4 ++++ src/commands/cthulhu.rs | 8 ++++++++ src/commands/management.rs | 4 ++++ src/commands/misc.rs | 4 ++++ src/commands/mod.rs | 1 + src/commands/variables.rs | 16 ++++++++++++++++ 7 files changed, 41 insertions(+) diff --git a/src/commands/basic_rolling.rs b/src/commands/basic_rolling.rs index ed74619..ae438b5 100644 --- a/src/commands/basic_rolling.rs +++ b/src/commands/basic_rolling.rs @@ -12,6 +12,10 @@ impl Command for RollCommand { "roll regular dice" } + fn is_secure(&self) -> bool { + false + } + async fn execute(&self, _ctx: &Context<'_>) -> ExecutionResult { let roll = self.0.roll(); let html = format!( diff --git a/src/commands/cofd.rs b/src/commands/cofd.rs index fed3b63..811b991 100644 --- a/src/commands/cofd.rs +++ b/src/commands/cofd.rs @@ -11,6 +11,10 @@ impl Command for PoolRollCommand { "roll dice pool" } + fn is_secure(&self) -> bool { + false + } + async fn execute(&self, ctx: &Context<'_>) -> ExecutionResult { let pool_with_ctx = DicePoolWithContext(&self.0, ctx); let rolled_pool = roll_pool(&pool_with_ctx).await?; diff --git a/src/commands/cthulhu.rs b/src/commands/cthulhu.rs index 86a83de..45aa4da 100644 --- a/src/commands/cthulhu.rs +++ b/src/commands/cthulhu.rs @@ -14,6 +14,10 @@ impl Command for CthRoll { "roll percentile dice" } + fn is_secure(&self) -> bool { + false + } + async fn execute(&self, ctx: &Context<'_>) -> ExecutionResult { let roll_with_ctx = DiceRollWithContext(&self.0, ctx); let executed_roll = regular_roll(&roll_with_ctx).await?; @@ -35,6 +39,10 @@ impl Command for CthAdvanceRoll { "roll skill advancement dice" } + fn is_secure(&self) -> bool { + false + } + async fn execute(&self, ctx: &Context<'_>) -> ExecutionResult { let roll_with_ctx = AdvancementRollWithContext(&self.0, ctx); let executed_roll = advancement_roll(&roll_with_ctx).await?; diff --git a/src/commands/management.rs b/src/commands/management.rs index eb3b13a..ce3a704 100644 --- a/src/commands/management.rs +++ b/src/commands/management.rs @@ -12,6 +12,10 @@ impl Command for ResyncCommand { "resync room information" } + fn is_secure(&self) -> bool { + false + } + async fn execute(&self, ctx: &Context<'_>) -> ExecutionResult { let our_username: Option = ctx.matrix_client.user_id().await; let our_username: &str = our_username.as_ref().map_or("", UserId::as_str); diff --git a/src/commands/misc.rs b/src/commands/misc.rs index 8666edb..0b10d68 100644 --- a/src/commands/misc.rs +++ b/src/commands/misc.rs @@ -11,6 +11,10 @@ impl Command for HelpCommand { "help information" } + fn is_secure(&self) -> bool { + false + } + async fn execute(&self, _ctx: &Context<'_>) -> ExecutionResult { let help = match &self.0 { Some(topic) => topic.message(), diff --git a/src/commands/mod.rs b/src/commands/mod.rs index 3979286..fd2d50e 100644 --- a/src/commands/mod.rs +++ b/src/commands/mod.rs @@ -96,6 +96,7 @@ impl ResponseExtractor for ExecutionResult { pub trait Command: Send + Sync { async fn execute(&self, ctx: &Context<'_>) -> ExecutionResult; fn name(&self) -> &'static str; + fn is_secure(&self) -> bool; } /// Attempt to execute a command, and return the content that should diff --git a/src/commands/variables.rs b/src/commands/variables.rs index 54e0649..fe7da5e 100644 --- a/src/commands/variables.rs +++ b/src/commands/variables.rs @@ -12,6 +12,10 @@ impl Command for GetAllVariablesCommand { "get all variables" } + fn is_secure(&self) -> bool { + false + } + async fn execute(&self, ctx: &Context<'_>) -> ExecutionResult { let variables = ctx .db @@ -43,6 +47,10 @@ impl Command for GetVariableCommand { "retrieve variable value" } + fn is_secure(&self) -> bool { + false + } + async fn execute(&self, ctx: &Context<'_>) -> ExecutionResult { let name = &self.0; let result = ctx @@ -69,6 +77,10 @@ impl Command for SetVariableCommand { "set variable value" } + fn is_secure(&self) -> bool { + false + } + async fn execute(&self, ctx: &Context<'_>) -> ExecutionResult { let name = &self.0; let value = self.1; @@ -91,6 +103,10 @@ impl Command for DeleteVariableCommand { "delete variable" } + fn is_secure(&self) -> bool { + false + } + async fn execute(&self, ctx: &Context<'_>) -> ExecutionResult { let name = &self.0; let result = ctx