Esempio n. 1
0
        public async Task <List <PageStruct> > GetPages(
            string blogId,
            string userName,
            string password,
            CancellationToken cancellationToken)
        {
            var list = new List <PageStruct>();

            var permission = await _security.ValidatePermissions(
                blogId,
                userName,
                password,
                CancellationToken.None
                ).ConfigureAwait(false);

            if (!permission.CanEditPages)
            {
                _log.LogWarning($"user {userName} cannot edit pages");
                return(list);
            }

            var pages = await _pageService.GetAllPages(blogId, cancellationToken).ConfigureAwait(false);

            foreach (var p in pages)
            {
                var pageUrl = await _pageUrlResolver.ResolvePageUrl(p);

                var s = _mapper.GetStructFromPage(p, pageUrl, false);
                list.Add(s);
            }

            return(list);
        }
        public async Task Handle(string projectId, string pageId, CancellationToken cancellationToken = default(CancellationToken))
        {
            var page = await _pageQueries.GetPage(projectId, pageId, cancellationToken);

            var url = await _pageUrlResolver.ResolvePageUrl(page);

            var message = new PushMessageModel()
            {
                MessageType = "contentdelete",
                Body        = "Content deleted",
                Data        = url
            };

            if (page.Slug == "home")
            {
                message.Data = "/";
            }

            var queueItem = new PushQueueItem(
                message,
                BuiltInRecipientProviderNames.AllButCurrentUserPushNotificationRecipientProvider);

            queueItem.TenantId = page.ProjectId;
            queueItem.RecipientProviderCustom1 = _userIdResolver.GetCurrentUserId();

            _pushNotificationsQueue.Enqueue(queueItem);
        }
        public async Task Handle(string projectId, IPage page, CancellationToken cancellationToken = default(CancellationToken))
        {
            var url = await _pageUrlResolver.ResolvePageUrl(page);

            var message = new PushMessageModel()
            {
                MessageType = "newcontent",
                Body        = "New content",
                Data        = url
            };

            if (page.Slug == "home")
            {
                message.Data = "/";
            }

            var queueItem = new PushQueueItem(
                message,
                BuiltInRecipientProviderNames.AllButCurrentUserPushNotificationRecipientProvider);

            queueItem.TenantId = page.ProjectId;
            queueItem.RecipientProviderCustom1 = _userIdResolver.GetCurrentUserId();

            _pushNotificationsQueue.Enqueue(queueItem);

            //TODO: need to extract all image urls and sned message to sw to add to cache if not in there already
            // or maybe need an event for file system when files added or deleted
        }