Skip to content

Commit

Permalink
Merge branch 'files-tab-teams-first-load' of https://github.com/rober…
Browse files Browse the repository at this point in the history
  • Loading branch information
jansenbe committed Feb 7, 2022
2 parents 2fdb806 + 5906d84 commit 2fe6cbf
Showing 1 changed file with 27 additions and 6 deletions.
33 changes: 27 additions & 6 deletions src/lib/PnP.Framework/Provisioning/ObjectHandlers/ObjectTeams.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using PnP.Framework.Diagnostics;
using PnP.Framework.Graph;
using PnP.Framework.Provisioning.Connectors;
using PnP.Framework.Provisioning.Model;
using PnP.Framework.Provisioning.Model.Configuration;
Expand All @@ -17,9 +18,8 @@
using System.IO;
using System.Linq;
using System.Net.Http.Headers;
using System.Text.RegularExpressions;
using System.Threading;
using System.Web;
using System.Threading.Tasks;

namespace PnP.Framework.Provisioning.ObjectHandlers
{
Expand Down Expand Up @@ -424,7 +424,7 @@ private static string CreateOrUpdateTeamFromGroup(PnPMonitoredScope scope, Team
catch (Exception ex)
{
scope.LogError("Error checking archive status", ex.Message);
}
}
}

// If the Team is currently archived
Expand Down Expand Up @@ -496,6 +496,15 @@ private static string CreateOrUpdateTeamFromGroupInternal(PnPMonitoredScope scop
wait = false;
}
}

// Ensure that Files tab is available right after Teams creation
Task.Run(async () =>
{
var graphClient = GraphUtility.CreateGraphClient(accessToken);

await InitTeamDrive(groupId, graphClient);
}).GetAwaiter().GetResult();

return (teamId);
}

Expand Down Expand Up @@ -908,7 +917,7 @@ private static string UpdateTeamChannel(Model.Teams.TeamChannel channel, string
var channelId = existingChannel["id"].ToString();
var channelDisplayName = existingChannel["displayName"].ToString();
var newChannelName = parser.ParseString(channel.DisplayName);
var identicalChannelName = newChannelName == channelDisplayName;
var identicalChannelName = newChannelName == channelDisplayName;

// Prepare the request body for the Channel update
var channelToUpdate = new
Expand Down Expand Up @@ -1761,7 +1770,7 @@ private static List<TeamTab> GetTeamChannelTabs(ExtractConfiguration configurati
if (string.IsNullOrEmpty(tab.TeamsAppId))
{
var tabJObject = teamTabsJObject.FirstOrDefault(x => x["id"].ToString() == tab.ID);
if (tabJObject!=default)
if (tabJObject != default)
tab.TeamsAppId = tabJObject["teamsApp"]?["id"]?.ToString();
}
tabs.Add(tab);
Expand All @@ -1777,6 +1786,18 @@ private static string CreateMailNicknameFromDisplayName(string displayName)
mailNickname = UrlUtility.ReplaceAccentedCharactersWithLatin(mailNickname);
return mailNickname;
}


public static async Task InitTeamDrive(string GroupId, Microsoft.Graph.GraphServiceClient graphClient = null)
{
var channels = await graphClient.Teams[GroupId].Channels.Request().GetAsync();

foreach (var channel in channels)
{
if (channel.DisplayName == "General")
{
await graphClient.Teams[GroupId].Channels[channel.Id].FilesFolder.Request().GetAsync();
}
}
}
}
}

0 comments on commit 2fe6cbf

Please sign in to comment.