Add on_teams_team_renamed "overload" - #1418
Conversation
| ) | ||
| if channel_data.event_type == "teamRenamed": | ||
| return await self.on_teams_team_renamed_activity( | ||
| return await self.on_teams_team_renamed( |
There was a problem hiding this comment.
This was actually a little trickier to implement than just using a simple overload because of this line. One of on_teams_team_renamed_activity() and on_teams_team_renamed() has to call the other (line 615). I tried to consider how this impacts backwards-compat (below), but please look it over and think it through, letting me know if I missed anything.
Regarding backwards-compat, there's really two ways to do this and I'm open to changing this
1. (current PR) Have on_conversation_update_activity() call on_teams_team_renamed()
The flow works like this:
- Activity comes in to
on_conversation_update_activity() on_conversation_update_activity()callson_teams_team_renamed()on_teams_team_renamed()callson_teams_team_renamed_activity(), if it hasn't been overridden
Works for developers who:
- Have already overridden
on_conversation_update_activity() - Have already overridden
on_teams_team_renamed_activity() - Have already overridden both
on_conversation_update_activity()andon_teams_team_renamed_activity() - Are writing a new bot and simply want to override
on_teams_team_renamed()
Does NOT work for developers who:
- Have created a method
on_teams_team_renamed()AND overriddenon_teams_team_renamed_activity(), sinceon_conversation_update_activity()will no longer callon_teams_team_renamed_activity()- This is pretty unlikely since creating
on_teams_team_renamed()would have accomplished nothing.
- This is pretty unlikely since creating
1. (alternative PR) Have on_conversation_update_activity() call on_teams_team_renamed_**activity**()
The difference is basically that there are no changes made to on_conversation_update_activity() and on_teams_team_renamed_activity() calls on_teams_team_renamed()
The flow would work like this:
- Activity comes in to
on_conversation_update_activity() on_conversation_update_activity()callson_teams_team_renamed_**activity**()on_teams_team_renamed_activity()callson_teams_team_renamed(), if it hasn't been overridden
Works for developers who:
- Have already overridden
on_conversation_update_activity() - Have already overridden
on_teams_team_renamed_activity() - Have already overridden both
on_conversation_update_activity()andon_teams_team_renamed_activity() - Are writing a new bot and simply want to override
on_teams_team_renamed()
Does NOT work for developers who:
- Works for all since if the developer has created
on_teams_team_renamed(), they're already going to use it how they please.
Summary
I went with the first option because it keeps on_conversation_update_activity() aligned through all the methods so that if future developers override it, it makes more "sense". However, option #1 also has potential backwards-compat issues, albeit very minimal. Open to changing things.
Fixes #1405
Description
on_teams_team_renamed_activity()was mistakenly named against the pattern of the rest of the activity handlers (which don't end in "activity"`Specific Changes
on_teams_team_renamed()on_teams_team_renamed_activity()