@@ -302,6 +302,36 @@ export class ActivityHandler extends ActivityHandlerBase {
302
302
return this . on ( 'InstallationUpdate' , handler ) ;
303
303
}
304
304
305
+ /**
306
+ * Registers an activity event handler for the _installationupdate add_ activity.
307
+ *
308
+ * @param handler The event handler.
309
+ *
310
+ * @remarks
311
+ * Returns a reference to the [ActivityHandler](xref:botbuilder-core.ActivityHandler) object.
312
+ *
313
+ * To handle a InstallationUpdateAdd event, use the
314
+ * [onInstallationUpdateAdd](xref:botbuilder-core.ActivityHandler.onInstallationUpdateAdd) type-specific event handler.
315
+ */
316
+ public onInstallationUpdateAdd ( handler : BotHandler ) : this {
317
+ return this . on ( 'InstallationUpdateAdd' , handler ) ;
318
+ }
319
+
320
+ /**
321
+ * Registers an activity event handler for the _installationupdate remove_ activity.
322
+ *
323
+ * @param handler The event handler.
324
+ *
325
+ * @remarks
326
+ * Returns a reference to the [ActivityHandler](xref:botbuilder-core.ActivityHandler) object.
327
+ *
328
+ * To handle a InstallationUpdateRemove event, use the
329
+ * [onInstallationUpdateRemove](xref:botbuilder-core.ActivityHandler.onInstallationUpdateRemove) type-specific event handler.
330
+ */
331
+ public onInstallationUpdateRemove ( handler : BotHandler ) : this {
332
+ return this . on ( 'InstallationUpdateRemove' , handler ) ;
333
+ }
334
+
305
335
/**
306
336
* Registers an activity event handler for the _tokens-response_ event, emitted for any incoming
307
337
* `tokens/response` event activity. These are generated as part of the OAuth authentication flow.
@@ -526,9 +556,65 @@ export class ActivityHandler extends ActivityHandlerBase {
526
556
* and then continue by calling [defaultNextEvent](xref:botbuilder-core.ActivityHandler.defaultNextEvent).
527
557
*/
528
558
protected async onInstallationUpdateActivity ( context : TurnContext ) : Promise < void > {
529
- await this . handle ( context , 'InstallationUpdate' , this . defaultNextEvent ( context ) ) ;
559
+ await this . handle ( context , 'InstallationUpdate' , async ( ) => {
560
+ await this . dispatchInstallationUpdateActivity ( context ) ;
561
+ } ) ;
530
562
}
531
563
564
+ /**
565
+ * Runs the _installation update_ sub-type handlers, as appropriate, and then continues the event emission process.
566
+ *
567
+ * @param context The context object for the current turn.
568
+ *
569
+ * @remarks
570
+ * Overwrite this method to support channel-specific behavior across multiple channels or to add
571
+ * custom conversation update sub-type events.
572
+ *
573
+ * The default logic is:
574
+ * - If any members were added, call handlers registered via [onMembersAdded](xref:botbuilder-core.ActivityHandler.onMembersAdded).
575
+ * - If any members were removed, call handlers registered via [onMembersRemoved](xref:botbuilder-core.ActivityHandler.onMembersRemoved).
576
+ * - Continue by calling [defaultNextEvent](xref:botbuilder-core.ActivityHandler.defaultNextEvent).
577
+ */
578
+ protected async dispatchInstallationUpdateActivity ( context : TurnContext ) : Promise < void > {
579
+ if ( context . activity . action == 'add' || context . activity . action == 'remove' ) {
580
+ await super . onInstallationUpdateActivity ( context ) ;
581
+ } else {
582
+ await this . defaultNextEvent ( context ) ( ) ;
583
+ }
584
+ }
585
+
586
+ /**
587
+ * Runs all registered _installation update add_ handlers and then continues the event emission process.
588
+ *
589
+ * @param context The context object for the current turn.
590
+ *
591
+ * @remarks
592
+ * Overwrite this method to support channel-specific behavior across multiple channels.
593
+ *
594
+ * The default logic is to call any handlers registered via
595
+ * [onInstallationUpdateAdd](xref:botbuilder-core.ActivityHandler.onInstallationUpdateAdd),
596
+ * and then continue by calling [defaultNextEvent](xref:botbuilder-core.ActivityHandler.defaultNextEvent).
597
+ */
598
+ protected async onInstallationUpdateAddActivity ( context : TurnContext ) : Promise < void > {
599
+ await this . handle ( context , 'InstallationUpdateAdd' , this . defaultNextEvent ( context ) ) ;
600
+ }
601
+
602
+ /**
603
+ * Runs all registered _installation update remove_ handlers and then continues the event emission process.
604
+ *
605
+ * @param context The context object for the current turn.
606
+ *
607
+ * @remarks
608
+ * Overwrite this method to support channel-specific behavior across multiple channels.
609
+ *
610
+ * The default logic is to call any handlers registered via
611
+ * [onInstallationUpdateRemove](xref:botbuilder-core.ActivityHandler.onInstallationUpdateRemove),
612
+ * and then continue by calling [defaultNextEvent](xref:botbuilder-core.ActivityHandler.defaultNextEvent).
613
+ */
614
+ protected async onInstallationUpdateRemoveActivity ( context : TurnContext ) : Promise < void > {
615
+ await this . handle ( context , 'InstallationUpdateRemove' , this . defaultNextEvent ( context ) ) ;
616
+ }
617
+
532
618
/**
533
619
* Runs all registered _unrecognized activity type_ handlers and then continues the event emission process.
534
620
*
0 commit comments