diff --git a/Samples/Common/Sample.Common.Beta/Meetings/JoinInfo.cs b/Samples/Common/Sample.Common.Beta/Meetings/JoinInfo.cs index ad7ff546b..d113eee77 100644 --- a/Samples/Common/Sample.Common.Beta/Meetings/JoinInfo.cs +++ b/Samples/Common/Sample.Common.Beta/Meetings/JoinInfo.cs @@ -28,6 +28,23 @@ public static (ChatInfo, MeetingInfo) ParseJoinURL(string joinURL) { var decodedURL = WebUtility.UrlDecode(joinURL); + //// Shorter URL format: https://teams.microsoft.com/meet/?p= + var shortUrlRegex = new Regex("https://teams\\.microsoft\\.com/meet/(?[^?]+)(?:\\?p=(?[^&]+))?"); + 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"} diff --git a/Samples/Common/Sample.Common.V1/Meetings/JoinInfo.cs b/Samples/Common/Sample.Common.V1/Meetings/JoinInfo.cs index da5d39316..894ff6990 100644 --- a/Samples/Common/Sample.Common.V1/Meetings/JoinInfo.cs +++ b/Samples/Common/Sample.Common.V1/Meetings/JoinInfo.cs @@ -28,6 +28,23 @@ public static (ChatInfo, MeetingInfo) ParseJoinURL(string joinURL) { var decodedURL = WebUtility.UrlDecode(joinURL); + //// Shorter URL format: https://teams.microsoft.com/meet/?p= + var shortUrlRegex = new Regex("https://teams\\.microsoft\\.com/meet/(?[^?]+)(?:\\?p=(?[^&]+))?"); + 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"} diff --git a/Samples/Common/Sample.Common/Meetings/JoinInfo.cs b/Samples/Common/Sample.Common/Meetings/JoinInfo.cs index c43df2d95..da51408d3 100644 --- a/Samples/Common/Sample.Common/Meetings/JoinInfo.cs +++ b/Samples/Common/Sample.Common/Meetings/JoinInfo.cs @@ -6,6 +6,7 @@ namespace Sample.Common.Meetings { using System; + using System.Collections.Generic; using System.IO; using System.Net; using System.Runtime.Serialization; @@ -28,6 +29,33 @@ public static (ChatInfo, MeetingInfo) ParseJoinURL(string joinURL) { var decodedURL = WebUtility.UrlDecode(joinURL); + //// Shorter URL format: https://teams.microsoft.com/meet/?p= + var shortUrlRegex = new Regex("https://teams\\.microsoft\\.com/meet/(?[^?]+)(?:\\?p=(?[^&]+))?"); + 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 + { + { "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"} diff --git a/Samples/PublicSamples/EchoBot/src/EchoBot/Bot/BotService.cs b/Samples/PublicSamples/EchoBot/src/EchoBot/Bot/BotService.cs index aa6a3a147..9e003bc2e 100644 --- a/Samples/PublicSamples/EchoBot/src/EchoBot/Bot/BotService.cs +++ b/Samples/PublicSamples/EchoBot/src/EchoBot/Bot/BotService.cs @@ -194,7 +194,7 @@ public async Task 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) @@ -215,7 +215,7 @@ public async Task 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}"); diff --git a/Samples/PublicSamples/EchoBot/src/EchoBot/Models/JoinInfo.cs b/Samples/PublicSamples/EchoBot/src/EchoBot/Models/JoinInfo.cs index c4e6da7d2..0dc3e53b4 100644 --- a/Samples/PublicSamples/EchoBot/src/EchoBot/Models/JoinInfo.cs +++ b/Samples/PublicSamples/EchoBot/src/EchoBot/Models/JoinInfo.cs @@ -34,7 +34,7 @@ public class JoinInfo /// Join URL cannot be null or empty: {joinURL} - joinURL /// Join URL cannot be parsed: {joinURL} - joinURL /// Join URL is invalid: missing Tid - joinURL - public static (ChatInfo, MeetingInfo) ParseJoinURL(string joinURL) + public static (ChatInfo?, MeetingInfo) ParseJoinURL(string joinURL) { if (string.IsNullOrEmpty(joinURL)) { @@ -43,6 +43,23 @@ public static (ChatInfo, MeetingInfo) ParseJoinURL(string joinURL) var decodedURL = WebUtility.UrlDecode(joinURL); + //// Shorter URL format: https://teams.microsoft.com/meet/?p= + var shortUrlRegex = new Regex("https://teams\\.microsoft\\.com/meet/(?[^?]+)(?:\\?p=(?[^&]+))?"); + 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.*/(?[^/]+)/(?[^/]+)\\?context=(?{.*})"); var match = regex.Match(decodedURL); if (!match.Success) diff --git a/Samples/PublicSamples/PsiBot/PsiBot/PsiBot.Service/Bot/BotService.cs b/Samples/PublicSamples/PsiBot/PsiBot/PsiBot.Service/Bot/BotService.cs index 7c5bc2ab4..195e031c5 100644 --- a/Samples/PublicSamples/PsiBot/PsiBot/PsiBot.Service/Bot/BotService.cs +++ b/Samples/PublicSamples/PsiBot/PsiBot/PsiBot.Service/Bot/BotService.cs @@ -141,7 +141,7 @@ public async Task 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) @@ -338,6 +338,23 @@ private CallHandler GetHandlerOrThrow(string callLegId) var decodedURL = WebUtility.UrlDecode(joinURL); + //// Shorter URL format: https://teams.microsoft.com/meet/?p= + var shortUrlRegex = new Regex("https://teams\\.microsoft\\.com/meet/(?[^?]+)(?:\\?p=(?[^&]+))?"); + 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"}