Пример #1
0
        private ModerationStatus GetModerationStatus()
        {
            var status = new ModerationStatus
            {
                Followers       = _moderationRepository.GetModerationType(ModerationEntityTypeEnum.Follower),
                TwitterAccounts = _moderationRepository.GetModerationType(ModerationEntityTypeEnum.TwitterAccount)
            };

            return(status);
        }
Пример #2
0
        private async Task CheckFollowerModerationPolicyAsync()
        {
            var followerPolicy = _moderationRepository.GetModerationType(ModerationEntityTypeEnum.Follower);

            if (followerPolicy == ModerationTypeEnum.None)
            {
                return;
            }

            await _followerModerationProcessor.ProcessAsync(followerPolicy);
        }
        public async Task <IViewComponentResult> InvokeAsync()
        {
            var followerPolicy       = _moderationRepository.GetModerationType(ModerationEntityTypeEnum.Follower);
            var twitterAccountPolicy = _moderationRepository.GetModerationType(ModerationEntityTypeEnum.TwitterAccount);

            var statistics = await _cachedStatisticsService.GetStatisticsAsync();

            var viewModel = new NodeInfoViewModel
            {
                BlacklistingEnabled = followerPolicy == ModerationTypeEnum.BlackListing ||
                                      twitterAccountPolicy == ModerationTypeEnum.BlackListing,
                WhitelistingEnabled = followerPolicy == ModerationTypeEnum.WhiteListing ||
                                      twitterAccountPolicy == ModerationTypeEnum.WhiteListing,
                InstanceSaturation = statistics.Saturation
            };

            //viewModel = new NodeInfoViewModel
            //{
            //    BlacklistingEnabled = false,
            //    WhitelistingEnabled = false,
            //    InstanceSaturation = 175
            //};
            return(View(viewModel));
        }
Пример #4
0
        public async Task <IActionResult> NodeInfo(string id)
        {
            var version           = System.Reflection.Assembly.GetEntryAssembly().GetName().Version.ToString(3);
            var twitterUsersCount = await _twitterUserDal.GetTwitterUsersCountAsync();

            var isOpenRegistration = _moderationRepository.GetModerationType(ModerationEntityTypeEnum.Follower) != ModerationTypeEnum.WhiteListing;

            if (id == "2.0")
            {
                var nodeInfo = new NodeInfoV20
                {
                    version = "2.0",
                    usage   = new Usage()
                    {
                        localPosts = 0,
                        users      = new Users()
                        {
                            total = twitterUsersCount
                        }
                    },
                    software = new Software()
                    {
                        name    = "birdsitelive",
                        version = version
                    },
                    protocols = new[]
                    {
                        "activitypub"
                    },
                    openRegistrations = isOpenRegistration,
                    services          = new Models.WellKnownModels.Services()
                    {
                        inbound  = new object[0],
                        outbound = new object[0]
                    },
                    metadata = new Metadata()
                    {
                        email = _settings.AdminEmail
                    }
                };
                return(new JsonResult(nodeInfo));
            }
            if (id == "2.1")
            {
                var nodeInfo = new NodeInfoV21
                {
                    version = "2.1",
                    usage   = new Usage()
                    {
                        localPosts = 0,
                        users      = new Users()
                        {
                            total = twitterUsersCount
                        }
                    },
                    software = new SoftwareV21()
                    {
                        name       = "birdsitelive",
                        version    = version,
                        repository = "https://github.com/NicolasConstant/BirdsiteLive"
                    },
                    protocols = new[]
                    {
                        "activitypub"
                    },
                    openRegistrations = isOpenRegistration,
                    services          = new Models.WellKnownModels.Services()
                    {
                        inbound  = new object[0],
                        outbound = new object[0]
                    },
                    metadata = new Metadata()
                    {
                        email = _settings.AdminEmail
                    }
                };
                return(new JsonResult(nodeInfo));
            }

            return(NotFound());
        }