예제 #1
0
        private async Task <ContactInfo> GetPublisherContactInfo(string ownerId, string repoId)
        {
            try
            {
                ProgressLog.Info("Attempting to retrieve publisher contact information from repository settings");
                // get repoSettings
                var repoSettings = await RepoSettingsStore.GetRepoSettingsAsync(ownerId, repoId);

                if (repoSettings?.DefaultPublisher != null)
                {
                    ProgressLog.Info("Returning publisher from repository settings");
                    return(repoSettings.DefaultPublisher);
                }
                // no repo settings publisher, try at owner level
                ProgressLog.Info("No publisher info found in repository settings");
                if (ownerId != null)
                {
                    ProgressLog.Info("Attempting to retrieve publisher contact information from repository owner's settings");
                    var ownerSettings = await OwnerSettingsStore.GetOwnerSettingsAsync(ownerId);

                    if (ownerSettings?.DefaultPublisher != null)
                    {
                        ProgressLog.Info("Returning publisher from repository owner's settings");
                        return(ownerSettings.DefaultPublisher);
                    }
                }
                // no settings / publisher found for that repo
                ProgressLog.Info("No publisher info found in repository owner's settings");
                return(null);
            }
            catch (Exception)
            {
                ProgressLog.Error("Error when attempting to retrieve publisher contact information from repository/owner settings");
                return(null);
            }
        }
예제 #2
0
 public RepoSettingsStoreSearchTests(RepoSettingsStoreFixture fixture)
 {
     _store = fixture.Store;
 }
예제 #3
0
 public RepoSettingsStoreFixture()
 {
     Store = new RepoSettingsStore(Client, Configuration);
     InitializeRepository().Wait();
 }
예제 #4
0
 public RepoSettingsStoreTests(ElasticsearchFixture fixture)
 {
     _store = new RepoSettingsStore(fixture.Client, fixture.Configuration);
 }
예제 #5
0
        private async Task <PortalInfoDrop> GetPortalSettingsInfo(string ownerId, string repoId, string authenticationToken)
        {
            try
            {
                ProgressLog.Info("Attempting to retrieve portal settings information from owner settings");
                if (ownerId != null)
                {
                    var portalInfo = new PortalInfoDrop
                    {
                        OwnerId        = ownerId,
                        RepositoryName = repoId
                    };

                    ProgressLog.Info("Attempting to retrieve publisher contact information from repository owner's settings");
                    var ownerSettings = await OwnerSettingsStore.GetOwnerSettingsAsync(ownerId);

                    if (ownerSettings != null)
                    {
                        portalInfo.IsOrg             = ownerSettings.IsOrg;
                        portalInfo.ShowDashboardLink = ownerSettings.DisplayDataDockLink;
                        if (!string.IsNullOrEmpty(ownerSettings.TwitterHandle))
                        {
                            portalInfo.Twitter = ownerSettings.TwitterHandle;
                        }

                        var client = GitHubClientFactory.CreateClient(authenticationToken);
                        if (ownerSettings.IsOrg)
                        {
                            var org = await client.Organization.Get(ownerId);

                            if (org == null)
                            {
                                return(portalInfo);
                            }

                            portalInfo.OwnerDisplayName = org.Name ?? ownerId;
                            if (ownerSettings.DisplayGitHubBlogUrl)
                            {
                                portalInfo.Website = org.Blog;
                            }
                            if (ownerSettings.DisplayGitHubAvatar)
                            {
                                portalInfo.LogoUrl = org.AvatarUrl;
                            }
                            if (ownerSettings.DisplayGitHubDescription)
                            {
                                portalInfo.Description = org.Bio;
                            }
                            if (ownerSettings.DisplayGitHubBlogUrl)
                            {
                                portalInfo.Website = org.Blog;
                            }
                            if (ownerSettings.DisplayGitHubLocation)
                            {
                                portalInfo.Location = org.Location;
                            }
                            if (ownerSettings.DisplayGitHubIssuesLink)
                            {
                                portalInfo.GitHubHtmlUrl = org.HtmlUrl;
                            }
                        }
                        else
                        {
                            var user = await client.User.Get(ownerId);

                            if (user == null)
                            {
                                return(portalInfo);
                            }

                            portalInfo.OwnerDisplayName = user.Name ?? ownerId;
                            if (ownerSettings.DisplayGitHubBlogUrl)
                            {
                                portalInfo.Website = user.Blog;
                            }
                            if (ownerSettings.DisplayGitHubAvatar)
                            {
                                portalInfo.LogoUrl = user.AvatarUrl;
                            }
                            if (ownerSettings.DisplayGitHubDescription)
                            {
                                portalInfo.Description = user.Bio;
                            }
                            if (ownerSettings.DisplayGitHubBlogUrl)
                            {
                                portalInfo.Website = user.Blog;
                            }
                            if (ownerSettings.DisplayGitHubLocation)
                            {
                                portalInfo.Location = user.Location;
                            }
                            if (ownerSettings.DisplayGitHubIssuesLink)
                            {
                                portalInfo.GitHubHtmlUrl = user.HtmlUrl;
                            }
                        }
                    }
                    ProgressLog.Info("Looking up repository portal search buttons from settings for {0} repository.", repoId);

                    var repoSettings = await RepoSettingsStore.GetRepoSettingsAsync(ownerId, repoId);

                    var repoSearchButtons = repoSettings?.SearchButtons;
                    if (!string.IsNullOrEmpty(repoSearchButtons))
                    {
                        portalInfo.RepoSearchButtons = GetSearchButtons(repoSearchButtons);
                    }
                    return(portalInfo);
                }
                // no settings
                ProgressLog.Info("No owner settings found");
                return(null);
            }
            catch (Exception)
            {
                ProgressLog.Error("Error when attempting to retrieve portal information from owner settings");
                return(null);
            }
        }