Skip to content
Draft
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
17 changes: 17 additions & 0 deletions Samples/Common/Sample.Common.Beta/Meetings/JoinInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,23 @@ public static (ChatInfo, MeetingInfo) ParseJoinURL(string joinURL)
{
var decodedURL = WebUtility.UrlDecode(joinURL);

//// Shorter URL format: https://teams.microsoft.com/meet/<meetingId>?p=<passcode>
var shortUrlRegex = new Regex("https://teams\\.microsoft\\.com/meet/(?<meetingId>[^?]+)(?:\\?p=(?<passcode>[^&]+))?");
var shortUrlMatch = shortUrlRegex.Match(decodedURL);
if (shortUrlMatch.Success)
{
var meetingId = shortUrlMatch.Groups["meetingId"].Value;
var passcode = shortUrlMatch.Groups["passcode"].Success ? shortUrlMatch.Groups["passcode"].Value : null;

var meetingInfo = new JoinMeetingIdMeetingInfo
{
JoinMeetingId = meetingId,
Passcode = passcode,
};

return (null, meetingInfo);
}

//// URL being needs to be in this format.
//// https://teams.microsoft.com/l/meetup-join/19:cd9ce3da56624fe69c9d7cd026f9126d@thread.skype/1509579179399?context={"Tid":"72f988bf-86f1-41af-91ab-2d7cd011db47","Oid":"550fae72-d251-43ec-868c-373732c2704f","MessageId":"1536978844957"}

Expand Down
17 changes: 17 additions & 0 deletions Samples/Common/Sample.Common.V1/Meetings/JoinInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,23 @@ public static (ChatInfo, MeetingInfo) ParseJoinURL(string joinURL)
{
var decodedURL = WebUtility.UrlDecode(joinURL);

//// Shorter URL format: https://teams.microsoft.com/meet/<meetingId>?p=<passcode>
var shortUrlRegex = new Regex("https://teams\\.microsoft\\.com/meet/(?<meetingId>[^?]+)(?:\\?p=(?<passcode>[^&]+))?");
var shortUrlMatch = shortUrlRegex.Match(decodedURL);
if (shortUrlMatch.Success)
{
var meetingId = shortUrlMatch.Groups["meetingId"].Value;
var passcode = shortUrlMatch.Groups["passcode"].Success ? shortUrlMatch.Groups["passcode"].Value : null;

var meetingInfo = new JoinMeetingIdMeetingInfo
{
JoinMeetingId = meetingId,
Passcode = passcode,
};

return (null, meetingInfo);
}

//// URL being needs to be in this format.
//// https://teams.microsoft.com/l/meetup-join/19:cd9ce3da56624fe69c9d7cd026f9126d@thread.skype/1509579179399?context={"Tid":"72f988bf-86f1-41af-91ab-2d7cd011db47","Oid":"550fae72-d251-43ec-868c-373732c2704f","MessageId":"1536978844957"}

Expand Down
28 changes: 28 additions & 0 deletions Samples/Common/Sample.Common/Meetings/JoinInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
namespace Sample.Common.Meetings
{
using System;
using System.Collections.Generic;
using System.IO;
using System.Net;
using System.Runtime.Serialization;
Expand All @@ -28,6 +29,33 @@ public static (ChatInfo, MeetingInfo) ParseJoinURL(string joinURL)
{
var decodedURL = WebUtility.UrlDecode(joinURL);

//// Shorter URL format: https://teams.microsoft.com/meet/<meetingId>?p=<passcode>
var shortUrlRegex = new Regex("https://teams\\.microsoft\\.com/meet/(?<meetingId>[^?]+)(?:\\?p=(?<passcode>[^&]+))?");
var shortUrlMatch = shortUrlRegex.Match(decodedURL);
if (shortUrlMatch.Success)
{
var meetingId = shortUrlMatch.Groups["meetingId"].Value;
var passcode = shortUrlMatch.Groups["passcode"].Success ? shortUrlMatch.Groups["passcode"].Value : null;

var additionalData = new Dictionary<string, object>
{
{ "joinMeetingId", meetingId },
};

if (passcode != null)
{
additionalData["passcode"] = passcode;
}

var meetingInfo = new TokenMeetingInfo
{
ODataType = "#microsoft.graph.joinMeetingIdMeetingInfo",
AdditionalData = additionalData,
};

return (null, meetingInfo);
}

//// URL being needs to be in this format.
//// https://teams.microsoft.com/l/meetup-join/19:cd9ce3da56624fe69c9d7cd026f9126d@thread.skype/1509579179399?context={"Tid":"72f988bf-86f1-41af-91ab-2d7cd011db47","Oid":"550fae72-d251-43ec-868c-373732c2704f","MessageId":"1536978844957"}

Expand Down
4 changes: 2 additions & 2 deletions Samples/PublicSamples/EchoBot/src/EchoBot/Bot/BotService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ public async Task<ICall> JoinCallAsync(JoinCallBody joinCallBody)

var (chatInfo, meetingInfo) = JoinInfo.ParseJoinURL(joinCallBody.JoinUrl);

var tenantId = (meetingInfo as OrganizerMeetingInfo).Organizer.GetPrimaryIdentity().GetTenantId();
var tenantId = (meetingInfo as OrganizerMeetingInfo)?.Organizer.GetPrimaryIdentity()?.GetTenantId();
var mediaSession = this.CreateLocalMediaSession();

var joinParams = new JoinMeetingParameters(chatInfo, meetingInfo, mediaSession)
Expand All @@ -215,7 +215,7 @@ public async Task<ICall> JoinCallAsync(JoinCallBody joinCallBody)
};
}

if (!this.CallHandlers.TryGetValue(joinParams.ChatInfo.ThreadId, out CallHandler? call))
if (chatInfo == null || !this.CallHandlers.TryGetValue(chatInfo.ThreadId, out CallHandler? call))
{
var statefulCall = await this.Client.Calls().AddAsync(joinParams, scenarioId).ConfigureAwait(false);
statefulCall.GraphLogger.Info($"Call creation complete: {statefulCall.Id}");
Expand Down
19 changes: 18 additions & 1 deletion Samples/PublicSamples/EchoBot/src/EchoBot/Models/JoinInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public class JoinInfo
/// <exception cref="ArgumentException">Join URL cannot be null or empty: {joinURL} - joinURL</exception>
/// <exception cref="ArgumentException">Join URL cannot be parsed: {joinURL} - joinURL</exception>
/// <exception cref="ArgumentException">Join URL is invalid: missing Tid - joinURL</exception>
public static (ChatInfo, MeetingInfo) ParseJoinURL(string joinURL)
public static (ChatInfo?, MeetingInfo) ParseJoinURL(string joinURL)
{
if (string.IsNullOrEmpty(joinURL))
{
Expand All @@ -43,6 +43,23 @@ public static (ChatInfo, MeetingInfo) ParseJoinURL(string joinURL)

var decodedURL = WebUtility.UrlDecode(joinURL);

//// Shorter URL format: https://teams.microsoft.com/meet/<meetingId>?p=<passcode>
var shortUrlRegex = new Regex("https://teams\\.microsoft\\.com/meet/(?<meetingId>[^?]+)(?:\\?p=(?<passcode>[^&]+))?");
var shortUrlMatch = shortUrlRegex.Match(decodedURL);
if (shortUrlMatch.Success)
{
var meetingId = shortUrlMatch.Groups["meetingId"].Value;
var passcode = shortUrlMatch.Groups["passcode"].Success ? shortUrlMatch.Groups["passcode"].Value : null;

var meetingInfo = new JoinMeetingIdMeetingInfo
{
JoinMeetingId = meetingId,
Passcode = passcode,
};

return (null, meetingInfo);
}

var regex = new Regex("https://teams\\.microsoft\\.com.*/(?<thread>[^/]+)/(?<message>[^/]+)\\?context=(?<context>{.*})");
var match = regex.Match(decodedURL);
if (!match.Success)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ public async Task<ICall> JoinCallAsync(JoinCallBody joinCallBody)

var (chatInfo, meetingInfo) = ParseJoinURL(joinCallBody.JoinURL);

var tenantId = (meetingInfo as OrganizerMeetingInfo).Organizer.GetPrimaryIdentity().GetTenantId();
var tenantId = (meetingInfo as OrganizerMeetingInfo)?.Organizer.GetPrimaryIdentity()?.GetTenantId();
var mediaSession = this.CreateLocalMediaSession();

var joinParams = new JoinMeetingParameters(chatInfo, meetingInfo, mediaSession)
Expand Down Expand Up @@ -338,6 +338,23 @@ private CallHandler GetHandlerOrThrow(string callLegId)

var decodedURL = WebUtility.UrlDecode(joinURL);

//// Shorter URL format: https://teams.microsoft.com/meet/<meetingId>?p=<passcode>
var shortUrlRegex = new Regex("https://teams\\.microsoft\\.com/meet/(?<meetingId>[^?]+)(?:\\?p=(?<passcode>[^&]+))?");
var shortUrlMatch = shortUrlRegex.Match(decodedURL);
if (shortUrlMatch.Success)
{
var meetingId = shortUrlMatch.Groups["meetingId"].Value;
var passcode = shortUrlMatch.Groups["passcode"].Success ? shortUrlMatch.Groups["passcode"].Value : null;

var meetingInfo = new JoinMeetingIdMeetingInfo
{
JoinMeetingId = meetingId,
Passcode = passcode,
};

return (null, meetingInfo);
}

//// URL being needs to be in this format.
//// https://teams.microsoft.com/l/meetup-join/19:cd9ce3da56624fe69c9d7cd026f9126d@thread.skype/1509579179399?context={"Tid":"72f988bf-86f1-41af-91ab-2d7cd011db47","Oid":"550fae72-d251-43ec-868c-373732c2704f","MessageId":"1536978844957"}

Expand Down