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

Teams Meeting Participant api updates #4826

Merged
merged 2 commits into from
Oct 21, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion libraries/Microsoft.Bot.Builder/Teams/TeamsInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public static class TeamsInfo
/// <remarks>InvalidOperationException will be thrown if meetingId, participantId or tenantId have not been
/// provided, and also cannot be retrieved from turnContext.Activity.</remarks>
/// <returns>Team participant channel account.</returns>
public static async Task<TeamsParticipantChannelAccount> GetMeetingParticipantAsync(ITurnContext turnContext, string meetingId = null, string participantId = null, string tenantId = null, CancellationToken cancellationToken = default)
public static async Task<TeamsMeetingParticipant> GetMeetingParticipantAsync(ITurnContext turnContext, string meetingId = null, string participantId = null, string tenantId = null, CancellationToken cancellationToken = default)
EricDahlvang marked this conversation as resolved.
Show resolved Hide resolved
{
meetingId ??= turnContext.Activity.TeamsGetMeetingInfo()?.Id ?? throw new InvalidOperationException("This method is only valid within the scope of a MS Teams Meeting.");
participantId ??= turnContext.Activity.From.AadObjectId ?? throw new InvalidOperationException($"{nameof(participantId)} is required.");
Expand Down
4 changes: 2 additions & 2 deletions libraries/Microsoft.Bot.Connector/Teams/TeamsOperations.cs
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ public TeamsOperations(TeamsConnectorClient client)
/// <return>
/// A response object containing the response body and response headers.
/// </return>
public async Task<HttpOperationResponse<TeamsParticipantChannelAccount>> FetchParticipantWithHttpMessagesAsync(string meetingId, string participantId, string tenantId, Dictionary<string, List<string>> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken))
public async Task<HttpOperationResponse<TeamsMeetingParticipant>> FetchParticipantWithHttpMessagesAsync(string meetingId, string participantId, string tenantId, Dictionary<string, List<string>> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken))
{
if (meetingId == null)
{
Expand Down Expand Up @@ -227,7 +227,7 @@ public TeamsOperations(TeamsConnectorClient client)
_url = _url.Replace("{participantId}", System.Uri.EscapeDataString(participantId));
_url = _url.Replace("{tenantId}", System.Uri.EscapeDataString(tenantId));

return await GetResponseAsync<TeamsParticipantChannelAccount>(_url, _shouldTrace, _invocationId).ConfigureAwait(false);
return await GetResponseAsync<TeamsMeetingParticipant>(_url, _shouldTrace, _invocationId).ConfigureAwait(false);
}

private async Task<HttpOperationResponse<T>> GetResponseAsync<T>(string url, bool shouldTrace, string invocationId, Dictionary<string, List<string>> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public static partial class TeamsOperationsExtensions
/// <param name='cancellationToken'>
/// The cancellation token.
/// </param>
public static async Task<TeamsParticipantChannelAccount> FetchParticipantAsync(this ITeamsOperations operations, string meetingId, string participantId, string tenantId, CancellationToken cancellationToken = default(CancellationToken))
public static async Task<TeamsMeetingParticipant> FetchParticipantAsync(this ITeamsOperations operations, string meetingId, string participantId, string tenantId, CancellationToken cancellationToken = default(CancellationToken))
{
if(operations is TeamsOperations teamsOperations)
{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for
// license information.

namespace Microsoft.Bot.Schema.Teams
{
using Newtonsoft.Json;

/// <summary>
/// Teams meeting participant details.
/// </summary>
public partial class MeetingParticipantInfo
{
/// <summary>
/// Initializes a new instance of the <see cref="MeetingParticipantInfo"/> class.
/// </summary>
public MeetingParticipantInfo()
{
CustomInit();
}

/// <summary>
/// Initializes a new instance of the <see cref="MeetingParticipantInfo"/> class.
/// </summary>
/// <param name="role">Role of the participant in the current meeting.</param>
/// <param name="inMeeting">True, if the participant is in the meeting.</param>
public MeetingParticipantInfo(string role = default(string), bool inMeeting = default(bool))
{
Role = role;
InMeeting = inMeeting;
CustomInit();
}

/// <summary>
/// Gets or sets a value indicating whether the participant is in the meeting or not.
/// </summary>
/// <value>
/// The value indicating if the participant is in the meeting.
/// </value>
[JsonProperty(PropertyName = "inMeeting")]
public bool InMeeting { get; set; }

/// <summary>
/// Gets or sets the participant's role in the meeting.
/// </summary>
/// <value>
/// The participant's role in the meeting.
/// </value>
[JsonProperty(PropertyName = "role")]
public string Role { get; set; }

/// <summary>
/// An initialization method that performs custom operations like setting defaults.
/// </summary>
partial void CustomInit();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for
// license information.

namespace Microsoft.Bot.Schema.Teams
{
using Newtonsoft.Json;

/// <summary>
/// Teams meeting participant information, detailing user Azure Active Directory and meeting participant details.
/// </summary>
public partial class TeamsMeetingParticipant
{
/// <summary>
/// Initializes a new instance of the <see cref="TeamsMeetingParticipant"/> class.
/// </summary>
public TeamsMeetingParticipant()
{
CustomInit();
}

/// <summary>
/// Initializes a new instance of the <see cref="TeamsMeetingParticipant"/> class.
/// </summary>
/// <param name="user">Teams Channel Account information for this meeting participant.</param>
/// <param name="conversation">Conversation Account for the meeting.</param>
/// <param name="meeting">Information specific to this participant in the specific meeting.</param>
public TeamsMeetingParticipant(TeamsChannelAccount user, ConversationAccount conversation = null, MeetingParticipantInfo meeting = null)
{
User = user;
Meeting = meeting;
Conversation = conversation;
CustomInit();
}

/// <summary>
/// Gets or sets the participant's user information.
/// </summary>
/// <value>
/// The participant's user information.
/// </value>
[JsonProperty(PropertyName = "user")]
public TeamsChannelAccount User { get; set; }

/// <summary>
/// Gets or sets the participant's meeting information.
/// </summary>
/// <value>
/// The participant's role in the meeting.
/// </value>
[JsonProperty(PropertyName = "meeting")]
public MeetingParticipantInfo Meeting { get; set; }

/// <summary>
/// Gets or sets the Conversation Account for the meeting.
/// </summary>
/// <value>
/// The Conversation Account for the meeting.
/// </value>
[JsonProperty(PropertyName = "conversation")]
public ConversationAccount Conversation { get; set; }

/// <summary>
/// An initialization method that performs custom operations like setting defaults.
/// </summary>
partial void CustomInit();
}
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ public async Task Action_GetMeetingParticipantMockedResults()
{
var participantResult = new JObject
{
new JProperty("meetingRole", "Organizer"),
new JProperty("userPrincipalName", "userPrincipalName-1"),
new JProperty("meeting", new JObject(new JProperty("role", "Organizer"))),
new JProperty("user", new JObject(new JProperty("userPrincipalName", "userPrincipalName-1"))),
new JProperty("conversation", new JObject(new JProperty("Id", "meetigConversationId-1"))),
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
},
{
"$kind": "Microsoft.SendActivity",
"activity": "${user.participant.meetingRole}"
"activity": "${user.participant.meeting.role}"
}
]
},
Expand Down
8 changes: 4 additions & 4 deletions tests/Microsoft.Bot.Builder.Tests/Teams/TeamsInfoTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -352,9 +352,9 @@ private async Task CallTeamsInfoGetParticipantAsync(ITurnContext turnContext)
{
var participant = await TeamsInfo.GetMeetingParticipantAsync(turnContext);

Assert.Equal("Organizer", participant.MeetingRole);
Assert.Equal("Organizer", participant.Meeting.Role);
Assert.Equal("meetigConversationId-1", participant.Conversation.Id);
Assert.Equal("userPrincipalName-1", participant.UserPrincipalName);
Assert.Equal("userPrincipalName-1", participant.User.UserPrincipalName);
}

private async Task CallGroupChatGetMembersAsync(ITurnContext turnContext)
Expand Down Expand Up @@ -520,8 +520,8 @@ protected override Task<HttpResponseMessage> SendAsync(HttpRequestMessage reques
{
var content = new JObject
{
new JProperty("meetingRole", "Organizer"),
new JProperty("userPrincipalName", "userPrincipalName-1"),
new JProperty("user", new JObject(new JProperty("userPrincipalName", "userPrincipalName-1"))),
new JProperty("meeting", new JObject(new JProperty("role", "Organizer"))),
new JProperty("conversation", new JObject(new JProperty("Id", "meetigConversationId-1"))),
};
response.Content = new StringContent(content.ToString());
Expand Down