Skip to content
This repository was archived by the owner on Dec 4, 2023. It is now read-only.

Commit 75e065d

Browse files
authored
Merge pull request #319 from fredrikluo/add-team-information-to-activity
Add access to Microsoft teams information in activity
2 parents 0cdaa62 + 588e37b commit 75e065d

File tree

8 files changed

+572
-1
lines changed

8 files changed

+572
-1
lines changed

libraries/bot-schema/src/main/java/com/microsoft/bot/schema/Activity.java

Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33

44
package com.microsoft.bot.schema;
55

6+
import com.microsoft.bot.schema.teams.TeamChannelData;
7+
68
import com.fasterxml.jackson.annotation.JsonAnyGetter;
79
import com.fasterxml.jackson.annotation.JsonAnySetter;
810
import com.fasterxml.jackson.annotation.JsonFormat;
@@ -1504,4 +1506,44 @@ public static String removeMentionTextImmutable(Activity activity, String id) {
15041506

15051507
return text;
15061508
}
1507-
}
1509+
1510+
/**
1511+
* Check if this actvity is from microsoft teams.
1512+
* @return true if the activity is from microsoft teams.
1513+
*/
1514+
public boolean isTeamsActivity() {
1515+
return "msteams".equals(channelId);
1516+
}
1517+
1518+
/**
1519+
* Get unique identifier representing a channel.
1520+
*
1521+
* @throws JsonProcessingException when channel data can't be parsed to TeamChannelData
1522+
* @return Unique identifier representing a channel
1523+
*/
1524+
public String teamsGetChannelId() throws JsonProcessingException {
1525+
TeamChannelData teamsChannelData = getChannelData(TeamChannelData.class);
1526+
String teamsChannelId = teamsChannelData.getTeamsChannelId();
1527+
if (teamsChannelId == null && teamsChannelData.getChannel() != null) {
1528+
teamsChannelId = teamsChannelData.getChannel().getId();
1529+
}
1530+
1531+
return teamsChannelId;
1532+
}
1533+
1534+
/**
1535+
* Get unique identifier representing a team.
1536+
*
1537+
* @throws JsonProcessingException when channel data can't be parsed to TeamChannelData
1538+
* @return Unique identifier representing a team.
1539+
*/
1540+
public String teamsGetTeamId() throws JsonProcessingException {
1541+
TeamChannelData teamsChannelData = getChannelData(TeamChannelData.class);
1542+
String teamId = teamsChannelData.getTeamsTeamId();
1543+
if (teamId == null && teamsChannelData.getTeam() != null) {
1544+
teamId = teamsChannelData.getTeam().getId();
1545+
}
1546+
1547+
return teamId;
1548+
}
1549+
}
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
package com.microsoft.bot.schema.teams;
2+
3+
import com.fasterxml.jackson.annotation.JsonProperty;
4+
5+
6+
/**
7+
* A channel info object which describes the channel.
8+
*/
9+
public class ChannelInfo {
10+
@JsonProperty(value = "id")
11+
private String id;
12+
13+
/**
14+
* name of the channel.
15+
*/
16+
@JsonProperty(value = "name")
17+
private String name;
18+
19+
/**
20+
* Get the unique identifier representing a channel.
21+
* @return the unique identifier representing a channel.
22+
*/
23+
public final String getId() {
24+
return id;
25+
}
26+
27+
/**
28+
* Set unique identifier representing a channel.
29+
* @param withId the unique identifier representing a channel.
30+
*/
31+
public void setId(String withId) {
32+
this.id = withId;
33+
}
34+
35+
/**
36+
* Get the name of the channel.
37+
* @return name of the channel.
38+
*/
39+
public String getName() {
40+
return name;
41+
}
42+
43+
/**
44+
* Sets name of the channel.
45+
* @param withName the name of the channel.
46+
*/
47+
public void setName(String withName) {
48+
this.name = withName;
49+
}
50+
51+
/**
52+
* Initializes a new instance of the ChannelInfo class.
53+
* @param withId identifier representing a channel.
54+
* @param withName Name of the channel.
55+
*/
56+
public ChannelInfo(String withId, String withName) {
57+
this.id = withId;
58+
this.name = withName;
59+
}
60+
61+
/**
62+
* Initializes a new instance of the ChannelInfo class.
63+
*/
64+
public ChannelInfo() {
65+
}
66+
}
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
package com.microsoft.bot.schema.teams;
2+
3+
import com.fasterxml.jackson.annotation.JsonProperty;
4+
/**
5+
* Specifies if a notification is to be sent for the mentions.
6+
*/
7+
public class NotificationInfo {
8+
/**
9+
* Gets or sets true if notification is to be sent to the user, false.
10+
*/
11+
@JsonProperty(value = "alert")
12+
private Boolean alert;
13+
14+
/**
15+
* Getter for alert.
16+
* @return return the alter value.
17+
*/
18+
public Boolean getAlert() {
19+
return alert;
20+
}
21+
22+
/**
23+
* Setter for alert.
24+
* @param withAlert the value to set.
25+
*/
26+
public void setAlert(Boolean withAlert) {
27+
alert = withAlert;
28+
}
29+
30+
/**
31+
* A new instance of NotificationInfo.
32+
* @param withAlert alert value to set.
33+
*/
34+
public NotificationInfo(Boolean withAlert) {
35+
alert = withAlert;
36+
}
37+
38+
/**
39+
* A new instance of NotificationInfo.
40+
*/
41+
public NotificationInfo() {
42+
}
43+
}
Lines changed: 197 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,197 @@
1+
package com.microsoft.bot.schema.teams;
2+
3+
import com.fasterxml.jackson.annotation.JsonProperty;
4+
5+
6+
/**
7+
* Channel data specific to messages received in Microsoft Teams.
8+
*/
9+
public class TeamChannelData {
10+
@JsonProperty(value = "teamsChannelId")
11+
private String teamsChannelId;
12+
13+
@JsonProperty(value = "teamsTeamId")
14+
private String teamsTeamId;
15+
16+
@JsonProperty(value = "channel")
17+
private ChannelInfo channel;
18+
19+
/// Gets or sets type of event.
20+
@JsonProperty(value = "eventType")
21+
private String eventType;
22+
23+
/// Gets or sets information about the team in which the message was
24+
/// sent
25+
@JsonProperty(value = "team")
26+
private TeamInfo team;
27+
28+
/// Gets or sets notification settings for the message
29+
@JsonProperty(value = "notification")
30+
private NotificationInfo notification;
31+
32+
/// Gets or sets information about the tenant in which the message was
33+
/// sent
34+
@JsonProperty(value = "tenant")
35+
private TenantInfo tenant;
36+
37+
/**
38+
* Get unique identifier representing a channel.
39+
* @return Unique identifier representing a channel.
40+
*/
41+
public String getTeamsChannelId() {
42+
return teamsChannelId;
43+
}
44+
45+
/**
46+
* Set unique identifier representing a channel.
47+
* @param withTeamsChannelId Unique identifier representing a channel.
48+
*/
49+
public void setTeamsChannelId(String withTeamsChannelId) {
50+
this.teamsChannelId = withTeamsChannelId;
51+
}
52+
53+
/**
54+
* Get unique identifier representing a team.
55+
* @return Unique identifier representing a team.
56+
*/
57+
public String getTeamsTeamId() {
58+
return teamsTeamId;
59+
}
60+
/**
61+
* Set unique identifier representing a team.
62+
* @param withTeamsTeamId Unique identifier representing a team.
63+
*/
64+
public void setTeamsTeamId(String withTeamsTeamId) {
65+
this.teamsTeamId = withTeamsTeamId;
66+
}
67+
68+
/**
69+
* Gets information about the channel in which the message was
70+
* sent.
71+
*
72+
* @return information about the channel in which the message was
73+
* sent.
74+
*/
75+
public ChannelInfo getChannel() {
76+
return channel;
77+
}
78+
79+
/**
80+
* Sets information about the channel in which the message was
81+
* sent.
82+
*
83+
* @param withChannel information about the channel in which the message was
84+
* sent.
85+
*/
86+
public void setChannel(ChannelInfo withChannel) {
87+
this.channel = withChannel;
88+
}
89+
90+
/**
91+
* Gets type of event.
92+
*
93+
* @return type of event.
94+
*/
95+
public String getEventType() {
96+
return eventType;
97+
}
98+
99+
/**
100+
* Sets type of event.
101+
*
102+
* @param withEventType type of event.
103+
*/
104+
public void setEventType(String withEventType) {
105+
this.eventType = withEventType;
106+
}
107+
108+
/**
109+
* Gets information about the team in which the message was
110+
* sent.
111+
*
112+
* @return information about the team in which the message was
113+
* sent.
114+
*/
115+
public TeamInfo getTeam() {
116+
return team;
117+
}
118+
119+
/**
120+
* Sets information about the team in which the message was
121+
* sent.
122+
*
123+
* @param withTeam information about the team in which the message was
124+
* sent.
125+
*/
126+
public void setTeam(TeamInfo withTeam) {
127+
this.team = withTeam;
128+
}
129+
130+
/**
131+
* Gets notification settings for the message.
132+
*
133+
* @return notification settings for the message.
134+
*/
135+
public NotificationInfo getNotification() {
136+
return notification;
137+
}
138+
139+
/**
140+
* Sets notification settings for the message.
141+
*
142+
* @param withNotification settings for the message.
143+
*/
144+
public void setNotification(NotificationInfo withNotification) {
145+
this.notification = withNotification;
146+
}
147+
148+
/**
149+
* Gets information about the tenant in which the message was.
150+
* @return information about the tenant in which the message was.
151+
*/
152+
public TenantInfo getTenant() {
153+
return tenant;
154+
}
155+
156+
/**
157+
* Sets information about the tenant in which the message was.
158+
* @param withTenant information about the tenant in which the message was.
159+
*/
160+
public void setTenant(TenantInfo withTenant) {
161+
this.tenant = withTenant;
162+
}
163+
164+
/**
165+
* A new instance of TeamChannelData.
166+
* @param withTeamsChannelId the channelId in Teams
167+
* @param withTeamsTeamId the teamId in Teams
168+
* @param withChannel information about the channel in which the message was sent.
169+
* @param withEventType type of event.
170+
* @param withTeam information about the team in which the message was
171+
* sent.
172+
* @param withNotification Notification settings for the message.
173+
* @param withTenant Information about the tenant in which the message was.
174+
*/
175+
public TeamChannelData(String withTeamsChannelId,
176+
String withTeamsTeamId,
177+
ChannelInfo withChannel,
178+
String withEventType,
179+
TeamInfo withTeam,
180+
NotificationInfo withNotification,
181+
TenantInfo withTenant) {
182+
this.teamsChannelId = withTeamsChannelId;
183+
this.teamsTeamId = withTeamsTeamId;
184+
this.channel = withChannel;
185+
this.eventType = withEventType;
186+
this.team = withTeam;
187+
this.notification = withNotification;
188+
this.tenant = withTenant;
189+
}
190+
191+
/**
192+
* A new instance of TeamChannelData.
193+
*/
194+
public TeamChannelData() {
195+
}
196+
197+
}

0 commit comments

Comments
 (0)