8000 Add settings.selectedChannel to TeamsChannelData and Type to ChannelI… · VictorErmakov/botbuilder-python@d4a1867 · GitHub
[go: up one dir, main page]

Skip to content

Commit d4a1867

Browse files
authored
Add settings.selectedChannel to TeamsChannelData and Type to ChannelInfo and TeamDetails (microsoft#2173)
1 parent fddd368 commit d4a1867

File tree

5 files changed

+88
-1
lines changed

5 files changed

+88
-1
lines changed

libraries/botbuilder-core/botbuilder/core/teams/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
from .teams_info import TeamsInfo
1010
from .teams_activity_extensions import (
1111
teams_get_channel_id,
12+
teams_get_selected_channel_id,
1213
teams_get_team_info,
1314
teams_notify_user,
1415
)
@@ -19,6 +20,7 @@
1920
"TeamsInfo",
2021
"TeamsSSOTokenExchangeMiddleware",
2122
"teams_get_channel_id",
23+
"teams_get_selected_channel_id",
2224
"teams_get_team_info",
2325
"teams_notify_user",
2426
]

libraries/botbuilder-core/botbuilder/core/teams/teams_activity_extensions.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,23 @@ def teams_get_channel_id(activity: Activity) -> str:
3131
return None
3232

3333

34+
def teams_get_selected_channel_id(activity: Activity) -> str:
35+
if not activity:
36+
return None
37+
38+
if activity.channel_data:
39+
channel_data = TeamsChannelData().deserialize(activity.channel_data)
40+
return (
41+
channel_data.settings.selected_channel.id
42+
if channel_data
43+
and channel_data.settings
44+
and channel_data.settings.selected_channel
45+
else None
46+
)
47+
48+
return None
49+
50+
3451
def teams_get_team_info(activity: Activity) -> TeamInfo:
3552
if not activity:
3653
return None

libraries/botbuilder-core/tests/teams/test_teams_extension.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
from botbuilder.schema.teams import TeamInfo
88
from botbuilder.core.teams import (
99
teams_get_channel_id,
10+
teams_get_selected_channel_id,
1011
teams_get_team_info,
1112
teams_notify_user,
1213
)
@@ -26,6 +27,35 @@ def test_teams_get_channel_id(self):
2627
# Assert
2728
assert result == "id123"
2829

30+
def test_teams_get_selected_channel_id(self):
31+
# Arrange
32+
activity = Activity(
33+
channel_data={
34+
"channel": {"id": "id123", "name": "channel_name"},
35+
"settings": {
36+
"selectedChannel": {"id": "id12345", "name": "channel_name"}
37+
},
38+
}
39+
)
40+
41+
# Act
42+
result = teams_get_selected_channel_id(activity)
43+
44+
# Assert
45+
assert result == "id12345"
46+
47+
def test_teams_get_selected_channel_id_with_no_selected_channel(self):
48+
# Arrange
49+
activity = Activity(
50+
channel_data={"channel": {"id": "id123", "name": "channel_name"}}
51+
)
52+
53+
# Act
54+
result = teams_get_selected_channel_id(activity)
55+
56+
# Assert
57+
assert result is None
58+
2959
def test_teams_get_channel_id_with_no_channel(self):
3060
# Arrange
3161
activity = Activity(

libraries/botbuilder-schema/botbuilder/schema/teams/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@
5959
from ._models_py3 import TeamDetails
6060
from ._models_py3 import TeamInfo
6161
from ._models_py3 import TeamsChannelAccount
62+
from ._models_py3 import TeamsChannelDataSettings
6263
from ._models_py3 import TeamsChannelData
6364
from ._models_py3 import TeamsPagedMembersResult
6465
from ._models_py3 import TenantInfo
@@ -145,6 +146,7 @@
145146
"TeamDetails",
146147
"TeamInfo",
147148
"TeamsChannelAccount",
149+
"TeamsChannelDataSettings",
148150
"TeamsChannelData",
149151
"TeamsPagedMembersResult",
150152
"TenantInfo",

libraries/botbuilder-schema/botbuilder/schema/teams/_models_py3.py

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,17 +87,23 @@ class ChannelInfo(Model):
8787
:type id: str
8888
:param name: Name of the channel
8989
:type name: str
90+
:param type: The channel type
91+
:type type: str
9092
"""
9193

9294
_attribute_map = {
9395
"id": {"key": "id", "type": "str"},
9496
"name": {"key": "name", "type": "str"},
97+
"type": {"key": "type", "type": "str"},
9598
}
9699

97-
def __init__(self, *, id: str = None, name: str = None, **kwargs) -> None:
100+
def __init__(
101+
self, *, id: str = None, name: str = None, type: str = None, **kwargs
102+
) -> None:
98103
super(ChannelInfo, self).__init__(**kwargs)
99104
self.id = id
100105
self.name = name
106+
self.type = type
101107

102108

103109
class CacheInfo(Model):
@@ -1820,6 +1826,8 @@ class TeamDetails(Model):
18201826
:type channel_count: int
18211827
:param member_count: The count of members in the team.
18221828
:type member_count: int
1829+
:param type: The team type
1830+
:type type: str
18231831
"""
18241832

18251833
_attribute_map = {
@@ -1828,6 +1836,7 @@ class TeamDetails(Model):
18281836
"aad_group_id": {"key": "aadGroupId", "type": "str"},
18291837
"channel_count": {"key": "channelCount", "type": "int"},
18301838
"member_count": {"key": "memberCount", "type": "int"},
1839+
"type": {"key": "type", "type": "str"},
18311840
}
18321841

18331842
def __init__(
@@ -1838,6 +1847,7 @@ def __init__(
18381847
aad_group_id: str = None,
18391848
member_count: int = None,
18401849
channel_count: int = None,
1850+
type: str = None,
18411851
**kwargs
18421852
) -> None:
18431853
super(TeamDetails, self).__init__(**kwargs)
@@ -1846,6 +1856,7 @@ def __init__(
18461856
self.aad_group_id = aad_group_id
18471857
self.channel_count = channel_count
18481858
self.member_count = member_count
1859+
self.type = type
18491860

18501861

18511862
class TeamInfo(Model):
@@ -1958,6 +1969,26 @@ def __init__(
19581969
self.members = members
19591970

19601971

1972+
class TeamsChannelDataSettings(Model):
1973+
"""
1974+
Represents the settings information for a Teams channel data.
1975+
1976+
:param selected_channel: Information about the selected Teams channel.
1977+
:type selected_channel: ~botframework.connector.teams.models.ChannelInfo
1978+
:param additional_properties: Gets or sets properties that are not otherwise defined by the
1979+
type but that might appear in the REST JSON object.
1980+
:type additional_properties: object
1981+
"""
1982+
1983+
_attribute_map = {
1984+
"selected_channel": {"key": "selectedChannel", "type": "ChannelInfo"},
1985+
}
1986+
1987+
def __init__(self, *, selected_channel=None, **kwargs) -> None:
1988+
super(TeamsChannelDataSettings, self).__init__(**kwargs)
1989+
self.selected_channel = selected_channel
1990+
1991+
19611992
class TeamsChannelData(Model):
19621993
"""Channel data specific to messages received in Microsoft Teams.
19631994
@@ -1974,6 +2005,8 @@ class TeamsChannelData(Model):
19742005
:type tenant: ~botframework.connector.teams.models.TenantInfo
19752006
:param meeting: Information about the meeting in which the message was sent
19762007
:type meeting: ~botframework.connector.teams.models.TeamsMeetingInfo
2008+
:param meeting: Information about the about the settings in which the message was sent
2009+
:type meeting: ~botframework.connector.teams.models.TeamsChannelDataSettings
19772010
"""
19782011

19792012
_attribute_map = {
@@ -1983,6 +2016,7 @@ class TeamsChannelData(Model):
19832016
"notification": {"key": "notification", "type": "NotificationInfo"},
19842017
"tenant": {"key": "tenant", "type": "TenantInfo"},
19852018
"meeting": {"key": "meeting", "type": "TeamsMeetingInfo"},
2019+
"settings": {"key": "settings", "type": "TeamsChannelDataSettings"},
19862020
}
19872021

19882022
def __init__(
@@ -1994,6 +2028,7 @@ def __init__(
19942028
notification=None,
19952029
tenant=None,
19962030
meeting=None,
2031+
settings: TeamsChannelDataSettings = None,
19972032
**kwargs
19982033
) -> None:
19992034
super(TeamsChannelData, self).__init__(**kwargs)
@@ -2004,6 +2039,7 @@ def __init__(
20042039
self.notification = notification
20052040
self.tenant = tenant
20062041
self.meeting = meeting
2042+
self.settings = settings
20072043

20082044

20092045
class TenantInfo(Model):

0 commit comments

Comments
 (0)
0