@@ -15,7 +15,7 @@ use crate::utils::pluralize;
1515use crate :: zulip:: api:: { MessageApiResponse , Recipient } ;
1616use crate :: zulip:: client:: ZulipClient ;
1717use crate :: zulip:: commands:: {
18- parse_cli, ChatCommand , LookupCmd , StreamCommand , WorkqueueCmd , WorkqueueLimit ,
18+ parse_cli, ChatCommand , LookupCmd , PingGoalsArgs , StreamCommand , WorkqueueCmd , WorkqueueLimit ,
1919} ;
2020use anyhow:: { format_err, Context as _} ;
2121use rust_team_data:: v1:: TeamKind ;
@@ -225,6 +225,8 @@ async fn handle_command<'a>(
225225 ChatCommand :: Whoami => whoami_cmd ( & ctx, gh_id) . await ,
226226 ChatCommand :: Lookup ( cmd) => lookup_cmd ( & ctx, cmd) . await ,
227227 ChatCommand :: Work ( cmd) => workqueue_commands ( ctx, gh_id, cmd) . await ,
228+ ChatCommand :: PingGoals ( args) => ping_goals_cmd ( ctx, gh_id, & args) . await ,
229+ ChatCommand :: DocsUpdate => trigger_docs_update ( message_data, & ctx. zulip ) ,
228230 } ;
229231
230232 let output = output?;
@@ -281,32 +283,35 @@ async fn handle_command<'a>(
281283 StreamCommand :: Read => post_waiter ( & ctx, message_data, WaitingMessage :: start_reading ( ) )
282284 . await
283285 . map_err ( |e| format_err ! ( "Failed to await at this time: {e:?}" ) ) ,
284- StreamCommand :: PingGoals {
285- threshold,
286- next_update,
287- } => {
288- if project_goals:: check_project_goal_acl ( & ctx. github , gh_id) . await ? {
289- ping_project_goals_owners (
290- & ctx. github ,
291- & ctx. zulip ,
292- false ,
293- threshold as i64 ,
294- & format ! ( "on {next_update}" ) ,
295- )
296- . await
297- . map_err ( |e| format_err ! ( "Failed to await at this time: {e:?}" ) ) ?;
298- Ok ( None )
299- } else {
300- Err ( format_err ! (
301- "That command is only permitted for those running the project-goal program." ,
302- ) )
303- }
304- }
286+ StreamCommand :: PingGoals ( args) => ping_goals_cmd ( ctx, gh_id, & args) . await ,
305287 StreamCommand :: DocsUpdate => trigger_docs_update ( message_data, & ctx. zulip ) ,
306288 }
307289 }
308290}
309291
292+ async fn ping_goals_cmd (
293+ ctx : & Context ,
294+ gh_id : u64 ,
295+ args : & PingGoalsArgs ,
296+ ) -> anyhow:: Result < Option < String > > {
297+ if project_goals:: check_project_goal_acl ( & ctx. github , gh_id) . await ? {
298+ ping_project_goals_owners (
299+ & ctx. github ,
300+ & ctx. zulip ,
301+ false ,
302+ args. threshold as i64 ,
303+ & format ! ( "on {}" , args. next_update) ,
304+ )
305+ . await
306+ . map_err ( |e| format_err ! ( "Failed to await at this time: {e:?}" ) ) ?;
307+ Ok ( None )
308+ } else {
309+ Err ( format_err ! (
310+ "That command is only permitted for those running the project-goal program." ,
311+ ) )
312+ }
313+ }
314+
310315/// Returns true if we should notify user who was impersonated by someone who executed this command.
311316/// More or less, the following holds: `sensitive` == `not read-only`.
312317fn is_sensitive_command ( cmd : & ChatCommand ) -> bool {
@@ -315,8 +320,10 @@ fn is_sensitive_command(cmd: &ChatCommand) -> bool {
315320 | ChatCommand :: Add { .. }
316321 | ChatCommand :: Move { .. }
317322 | ChatCommand :: Meta { .. } => true ,
318- ChatCommand :: Whoami => false ,
319- ChatCommand :: Lookup ( _) => false ,
323+ ChatCommand :: Whoami
324+ | ChatCommand :: DocsUpdate
325+ | ChatCommand :: PingGoals ( _)
326+ | ChatCommand :: Lookup ( _) => false ,
320327 ChatCommand :: Work ( cmd) => match cmd {
321328 WorkqueueCmd :: Show => false ,
322329 WorkqueueCmd :: SetPrLimit { .. } => true ,
0 commit comments