Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: teams message update & message delete events #4374

Merged
merged 18 commits into from
Nov 30, 2022

Conversation

singhk97
Copy link
Collaborator

@singhk97 singhk97 commented Nov 23, 2022

This PR aims to extend the Bot SDK so that developers can consume newly added events that Teams will emit to the bot. They are:

TeamsMessageEdit - a user editing a message in Teams.
TeamsMessageUndelete - a user undo-ing a deleted message in Teams.
TeamsMessageSoftDelete - a user deleting a message in Teams.

Closes #4375

Description

  • Extended ActivityHandlerBase to handle MessageUpdate and MessageDelete activity types
  • Extended ActivityHandler to handle MessageUpdate and MessageDelete activity types and dispatch functions for subtypes.
  • Extended TeamsActivityHandler to handle MessageUpdate (with subtypes TeamsMessageEdit and TeamsMessageUndelete) and MessageDelete (with subtype TeamsMessageSoftDelete) teams events.

Specific Changes

  • Ran yarn build:rollup on both the botbuilder and botbuilder-core libraries to generate public api doc.

ActivityHandlerBase class

  • Updated switch statement to handle MessageUpdate and MessageDelete
  • Defined onMessageUpdateActivity and onMessageDeleteActivity methods
  • the changes conform to existing convention and are synonymous to the Message activity event.

ActivityHandler class

  • Implemented event handler registration methods onMessageUpdate and onMessageDelete
  • Implemented hooks onMessageUpdateActivity and onMessageDeleteActivity to mirror onConversationUpdateActivity
  • Implemented subtype dispatch functions dispatchMessageUpdateAcitivty and dispatchMessageDeleteActivity. They conform to existing convention (ex. onConversationUpdateActivity).

TeamsActivityHandler class

  • Extended dispatchMessageUpdateActivity to handle subtypes onTeamsMessageEdit & onTeamsMessageUndelete.
  • Extended dispatchMessageDeleteActivity to handle subtypes onTeamsSoftDelete.
  • Implemented event handler registration methods onTeamsMessageEditEvent, onTeamsMessageUndeleteEvent and onTeamsMessageSoftDeleteEvent.
  • Implemented methods onTeamsMessageEdit, onTeamsMessageUndelete and onTeamsMessageSoftDelete that are dispatched by the respective dispatch methods.

Testing

  • Added unit tests for changes in all the three classes.

@singhk97 singhk97 self-assigned this Nov 23, 2022
@singhk97 singhk97 requested a review from a team as a code owner November 23, 2022 01:05
@singhk97 singhk97 changed the title Kavin/teams message events feature feat: teams message update & delete events Nov 23, 2022
@singhk97 singhk97 changed the title feat: teams message update & delete events feat: teams message update & message delete events Nov 23, 2022
@coveralls
Copy link

coveralls commented Nov 23, 2022

Pull Request Test Coverage Report for Build 3570060710

  • 34 of 36 (94.44%) changed or added relevant lines in 3 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.01%) to 84.633%

Changes Missing Coverage Covered Lines Changed/Added Lines %
libraries/botbuilder-core/src/activityHandlerBase.ts 4 6 66.67%
Totals Coverage Status
Change from base Build 3519043752: 0.01%
Covered Lines: 19968
Relevant Lines: 22357

💛 - Coveralls

@singhk97
Copy link
Collaborator Author

singhk97 commented Nov 23, 2022

Pull Request Test Coverage Report for Build 3528369428

  • 32 of 36 (88.89%) changed or added relevant lines in 3 files are covered.
  • 1 unchanged line in 1 file lost coverage.
  • Overall coverage increased (+0.004%) to 84.625%

Changes Missing Coverage Covered Lines Changed/Added Lines %
libraries/botbuilder-core/src/activityHandlerBase.ts 4 6 66.67%
libraries/botbuilder/src/teamsActivityHandler.ts 20 22 90.91%
Files with Coverage Reduction New Missed Lines %
libraries/botbuilder-lg/src/templateExtensions.ts 1 84.48%
Totals Coverage Status
Change from base Build 3519043752: 0.004%
Covered Lines: 19966
Relevant Lines: 22357

💛 - Coveralls

The 2 lines in ActivityHandlerBase.ts that aren't covered are method definitions with empty implementation

@singhk97
Copy link
Collaborator Author

singhk97 commented Nov 23, 2022

@microsoft-github-policy-service agree company="Microsoft"

…TeamsSoftDeleteMessage to Teams MessageSoftDelete, TeamsEditMessage to TeamsMessageEdit
@yingduyingdu
Copy link

Hi @singhk97 , could you explain a bit why/how message update and message delete are related to OnConversationUpdateActivity? I am bit confused here.

image

@singhk97
Copy link
Collaborator Author

Hi @singhk97 , could you explain a bit why/how message update and message delete are related to OnConversationUpdateActivity? I am bit confused here.

image

ConversationUpdate is an activity type and MembersAdded and MembersRemoved is it's respective sub-type. When a ConversationUpdate event happens, we trigger the ConversationUpdate handlers, and then trigger its subtype's handlers (using a dispatch function). Because MessageUpdate is an activity type, while OnTeamsMessageEdit & OnTeamsMessageUndelete are their respective sub-types, It made sense to mirror the behavior of ConversationUpdate activity, implementation technique & naming convention. Same logic applies to MessageDelete. I hope this helps

@yingduyingdu
Copy link

Hi @singhk97 , could you explain a bit why/how message update and message delete are related to OnConversationUpdateActivity? I am bit confused here.
image

ConversationUpdate is an activity type and MembersAdded and MembersRemoved is it's respective sub-type. When a ConversationUpdate event happens, we trigger the ConversationUpdate handlers, and then trigger its subtype's handlers (using a dispatch function). Because MessageUpdate is an activity type, while OnTeamsMessageEdit & OnTeamsMessageUndelete are their respective sub-types, It made sense to mirror the behavior of ConversationUpdate activity, implementation technique & naming convention. Same logic applies to MessageDelete. I hope this helps

Make a lot more sense! Thanks for the clarification!

@tracyboehrer tracyboehrer merged commit e5f7e3a into main Nov 30, 2022
@tracyboehrer tracyboehrer deleted the kavin/teams-message-events-feature branch November 30, 2022 22:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

feat: teams message update and message delete events
6 participants