@@ -205,16 +205,16 @@ async fn handle_command<'a>(
205
205
}
206
206
207
207
let cmd = parse_cli :: < ChatCommand , _ > ( words. into_iter ( ) ) ?;
208
- let output = match cmd {
208
+ let output = match & cmd {
209
209
ChatCommand :: Acknowledge { identifier } => {
210
- acknowledge ( & ctx, gh_id, ( & identifier) . into ( ) ) . await
210
+ acknowledge ( & ctx, gh_id, identifier. into ( ) ) . await
211
211
}
212
212
ChatCommand :: Add { url, description } => {
213
213
add_notification ( & ctx, gh_id, & url, & description. join ( " " ) ) . await
214
214
}
215
- ChatCommand :: Move { from, to } => move_notification ( & ctx, gh_id, from, to) . await ,
215
+ ChatCommand :: Move { from, to } => move_notification ( & ctx, gh_id, * from, * to) . await ,
216
216
ChatCommand :: Meta { index, description } => {
217
- add_meta_notification ( & ctx, gh_id, index, & description. join ( " " ) ) . await
217
+ add_meta_notification ( & ctx, gh_id, * index, & description. join ( " " ) ) . await
218
218
}
219
219
ChatCommand :: Whoami => whoami_cmd ( & ctx, gh_id) . await ,
220
220
ChatCommand :: Lookup ( cmd) => lookup_cmd ( & ctx, cmd) . await ,
@@ -223,8 +223,8 @@ async fn handle_command<'a>(
223
223
224
224
let output = output?;
225
225
226
- // Let the impersonated person know about the impersonation
227
- if impersonated {
226
+ // Let the impersonated person know about the impersonation if the command was sensitive
227
+ if impersonated && is_sensitive_command ( & cmd ) {
228
228
let impersonated_zulip_id = to_zulip_id ( & ctx. github , gh_id)
229
229
. await ?
230
230
. ok_or_else ( || anyhow:: anyhow!( "Zulip user for GitHub ID {gh_id} was not found" ) ) ?;
@@ -301,12 +301,30 @@ async fn handle_command<'a>(
301
301
}
302
302
}
303
303
304
+ /// Returns true if we should notify user who was impersonated by someone who executed this command.
305
+ /// More or less, the following holds: `sensitive` == `not read-only`.
306
+ fn is_sensitive_command ( cmd : & ChatCommand ) -> bool {
307
+ match cmd {
308
+ ChatCommand :: Acknowledge { .. }
309
+ | ChatCommand :: Add { .. }
310
+ | ChatCommand :: Move { .. }
311
+ | ChatCommand :: Meta { .. } => true ,
312
+ ChatCommand :: Whoami => false ,
313
+ ChatCommand :: Lookup ( _) => false ,
314
+ ChatCommand :: Work ( cmd) => match cmd {
315
+ WorkqueueCmd :: Show => false ,
316
+ WorkqueueCmd :: SetPrLimit { .. } => true ,
317
+ WorkqueueCmd :: SetRotationMode { .. } => true ,
318
+ } ,
319
+ }
320
+ }
321
+
304
322
/// Commands for working with the workqueue, e.g. showing how many PRs are assigned
305
323
/// or modifying the PR review assignment limit.
306
324
async fn workqueue_commands (
307
325
ctx : & Context ,
308
326
gh_id : u64 ,
309
- cmd : WorkqueueCmd ,
327
+ cmd : & WorkqueueCmd ,
310
328
) -> anyhow:: Result < Option < String > > {
311
329
let db_client = ctx. db . get ( ) . await ;
312
330
@@ -364,7 +382,7 @@ async fn workqueue_commands(
364
382
WorkqueueCmd :: SetPrLimit { limit } => {
365
383
let max_assigned_prs = match limit {
366
384
WorkqueueLimit :: Unlimited => None ,
367
- WorkqueueLimit :: Limit ( limit) => Some ( limit) ,
385
+ WorkqueueLimit :: Limit ( limit) => Some ( * limit) ,
368
386
} ;
369
387
upsert_review_prefs (
370
388
& db_client,
@@ -457,7 +475,7 @@ async fn whoami_cmd(ctx: &Context, gh_id: u64) -> anyhow::Result<Option<String>>
457
475
Ok ( Some ( output) )
458
476
}
459
477
460
- async fn lookup_cmd ( ctx : & Context , cmd : LookupCmd ) -> anyhow:: Result < Option < String > > {
478
+ async fn lookup_cmd ( ctx : & Context , cmd : & LookupCmd ) -> anyhow:: Result < Option < String > > {
461
479
let username = match & cmd {
462
480
LookupCmd :: Zulip { github_username } => github_username. clone ( ) ,
463
481
// Usernames could contain spaces, so rejoin everything to serve as the username.
0 commit comments