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

Commit 3ac65f1

Browse files
authored
Merge pull request #811 from microsoft/trboehre/meetingalert
Meeting notification alert bubble
2 parents 70e1f73 + 07d70bc commit 3ac65f1

File tree

3 files changed

+76
-24
lines changed

3 files changed

+76
-24
lines changed

libraries/bot-connector/src/test/java/com/microsoft/bot/connector/JwtTokenValidationTests.java

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -582,27 +582,17 @@ public void GovernmentChannelValidation_WrongServiceClaimValue_Fails() {
582582
}
583583

584584
private void JwtTokenValidation_ValidateAuthHeader_WithChannelService_Succeeds(String appId, String pwd, String channelService) throws IOException, ExecutionException, InterruptedException {
585-
ChannelProvider channel = new SimpleChannelProvider(channelService);
586-
String header = channel.isGovernment() ? getGovHeaderToken() : getHeaderToken();
587-
588-
JwtTokenValidation_ValidateAuthHeader_WithChannelService_Succeeds(header, appId, pwd, channel);
585+
String header = "Bearer " + new MicrosoftAppCredentials(appId, pwd).getToken().join();
586+
JwtTokenValidation_ValidateAuthHeader_WithChannelService_Succeeds(header, appId, pwd, channelService);
589587
}
590588

591-
private void JwtTokenValidation_ValidateAuthHeader_WithChannelService_Succeeds(String header, String appId, String pwd, ChannelProvider channel) {
589+
private void JwtTokenValidation_ValidateAuthHeader_WithChannelService_Succeeds(String header, String appId, String pwd, String channelService) {
592590
CredentialProvider credentials = new SimpleCredentialProvider(appId, pwd);
591+
ChannelProvider channel = new SimpleChannelProvider(channelService);
593592

594-
try {
595-
ClaimsIdentity identity = JwtTokenValidation.validateAuthHeader(
596-
header,
597-
credentials,
598-
channel,
599-
"",
600-
"https://webchat.botframework.com/").join();
593+
ClaimsIdentity identity = JwtTokenValidation.validateAuthHeader(header, credentials, channel, null, "https://webchat.botframework.com/").join();
601594

602-
Assert.assertTrue(identity.isAuthenticated());
603-
} catch (Exception e) {
604-
Assert.fail("Should not have thrown " + e.getClass().getName());
605-
}
595+
Assert.assertTrue(identity.isAuthenticated());
606596
}
607597

608598
private void JwtTokenValidation_ValidateAuthHeader_WithChannelService_Throws(String header, String appId, String pwd, String channelService) throws ExecutionException, InterruptedException {

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

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1820,6 +1820,28 @@ public void teamsNotifyUser() {
18201820
teamsChannelData.setNotification(new NotificationInfo(true));
18211821
}
18221822

1823+
/**
1824+
* Sets the notification of a meeting in the TeamsChannelData.
1825+
* @param alertInMeeting True if this is a meeting alert.
1826+
* @param externalResourceUrl The external resource Url.
1827+
*/
1828+
public void teamsNotifyUser(boolean alertInMeeting, String externalResourceUrl) {
1829+
TeamsChannelData teamsChannelData;
1830+
1831+
try {
1832+
teamsChannelData = getChannelData(TeamsChannelData.class);
1833+
} catch (JsonProcessingException jpe) {
1834+
teamsChannelData = null;
1835+
}
1836+
1837+
if (teamsChannelData == null) {
1838+
teamsChannelData = new TeamsChannelData();
1839+
setChannelData(teamsChannelData);
1840+
}
1841+
1842+
teamsChannelData.setNotification(new NotificationInfo(true, externalResourceUrl));
1843+
}
1844+
18231845
/**
18241846
* Returns this activity as a Message Activity; or null, if this is not that type of activity.
18251847
*

libraries/bot-schema/src/main/java/com/microsoft/bot/schema/teams/NotificationInfo.java

Lines changed: 48 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,11 @@ public class NotificationInfo {
1515
@JsonProperty(value = "alert")
1616
private Boolean alert;
1717

18-
/**
19-
* Initialize new NotificationInfo.
20-
*
21-
* @param withAlert initial alert value.
22-
*/
23-
public NotificationInfo(boolean withAlert) {
24-
setAlert(withAlert);
25-
}
18+
@JsonProperty(value = "alertInMeeting")
19+
private Boolean alertInMeeting;
20+
21+
@JsonProperty(value = "externalResourceUrl")
22+
private String externalResourceUrl;
2623

2724
/**
2825
* Getter for alert.
@@ -42,6 +39,38 @@ public void setAlert(Boolean withAlert) {
4239
alert = withAlert;
4340
}
4441

42+
/**
43+
* Indicates if this is a meeting alert.
44+
* @return True if this is a meeting alert.
45+
*/
46+
public Boolean getAlertInMeeting() {
47+
return alertInMeeting;
48+
}
49+
50+
/**
51+
* Indicates if this is a meeting alert.
52+
* @param withAlertInMeeting True if this is a meeting alert.
53+
*/
54+
public void setAlertInMeeting(Boolean withAlertInMeeting) {
55+
alertInMeeting = withAlertInMeeting;
56+
}
57+
58+
/**
59+
* Gets the resource Url of a meeting alert.
60+
* @return The external resource url.
61+
*/
62+
public String getExternalResourceUrl() {
63+
return externalResourceUrl;
64+
}
65+
66+
/**
67+
* The resource Url of a meeting alert.
68+
* @param withExternalResourceUrl The external resource Url.
69+
*/
70+
public void setExternalResourceUrl(String withExternalResourceUrl) {
71+
externalResourceUrl = withExternalResourceUrl;
72+
}
73+
4574
/**
4675
* A new instance of NotificationInfo.
4776
*
@@ -51,6 +80,17 @@ public NotificationInfo(Boolean withAlert) {
5180
alert = withAlert;
5281
}
5382

83+
/**
84+
* A new instance of a meeting alert.
85+
* @param withAlertInMeeting True if this is a meeting alert.
86+
* @param withExternalResourceUrl The external resource Url.
87+
*/
88+
public NotificationInfo(boolean withAlertInMeeting, String withExternalResourceUrl) {
89+
setAlert(true);
90+
setAlertInMeeting(withAlertInMeeting);
91+
setExternalResourceUrl(withExternalResourceUrl);
92+
}
93+
5494
/**
5595
* A new instance of NotificationInfo.
5696
*/

0 commit comments

Comments
 (0)