@@ -15,7 +15,7 @@ use crate::utils::pluralize;
15
15
use crate :: zulip:: api:: { MessageApiResponse , Recipient } ;
16
16
use crate :: zulip:: client:: ZulipClient ;
17
17
use crate :: zulip:: commands:: {
18
- parse_cli, ChatCommand , LookupCmd , StreamCommand , WorkqueueCmd , WorkqueueLimit ,
18
+ parse_cli, ChatCommand , LookupCmd , PingGoalsArgs , StreamCommand , WorkqueueCmd , WorkqueueLimit ,
19
19
} ;
20
20
use anyhow:: { format_err, Context as _} ;
21
21
use rust_team_data:: v1:: TeamKind ;
@@ -225,6 +225,8 @@ async fn handle_command<'a>(
225
225
ChatCommand :: Whoami => whoami_cmd ( & ctx, gh_id) . await ,
226
226
ChatCommand :: Lookup ( cmd) => lookup_cmd ( & ctx, cmd) . await ,
227
227
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 ) ,
228
230
} ;
229
231
230
232
let output = output?;
@@ -281,32 +283,35 @@ async fn handle_command<'a>(
281
283
StreamCommand :: Read => post_waiter ( & ctx, message_data, WaitingMessage :: start_reading ( ) )
282
284
. await
283
285
. 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 ,
305
287
StreamCommand :: DocsUpdate => trigger_docs_update ( message_data, & ctx. zulip ) ,
306
288
}
307
289
}
308
290
}
309
291
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
+
310
315
/// Returns true if we should notify user who was impersonated by someone who executed this command.
311
316
/// More or less, the following holds: `sensitive` == `not read-only`.
312
317
fn is_sensitive_command ( cmd : & ChatCommand ) -> bool {
@@ -315,8 +320,10 @@ fn is_sensitive_command(cmd: &ChatCommand) -> bool {
315
320
| ChatCommand :: Add { .. }
316
321
| ChatCommand :: Move { .. }
317
322
| ChatCommand :: Meta { .. } => true ,
318
- ChatCommand :: Whoami => false ,
319
- ChatCommand :: Lookup ( _) => false ,
323
+ ChatCommand :: Whoami
324
+ | ChatCommand :: DocsUpdate
325
+ | ChatCommand :: PingGoals ( _)
326
+ | ChatCommand :: Lookup ( _) => false ,
320
327
ChatCommand :: Work ( cmd) => match cmd {
321
328
WorkqueueCmd :: Show => false ,
322
329
WorkqueueCmd :: SetPrLimit { .. } => true ,
0 commit comments