Пример #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 <List <PageStruct> > GetPages(
            string blogId,
            string userName,
            string password,
            CancellationToken cancellationToken)
        {
            var list = new List <PageStruct>();

            var pages = await pageService.GetAllPages(
                blogId,
                userName,
                password
                ).ConfigureAwait(false);

            foreach (var p in pages)
            {
                //var commentsOpen = await blogService.CommentsAreOpen(p, false);
                var postUrl = await pageService.ResolvePageUrl(p);

                var s = mapper.GetStructFromPage(p, postUrl, false);

                // OLW/WLW need the image urls to be fully qualified - actually not sure this is true
                // I seem to remember that being the case with WLW
                // but when I open a recent post in olw that orignated from the web client
                // it shows the image correctly in olw
                // we persist them as relative so we need to convert them back
                // before passing posts back to metaweblogapi

                list.Add(s);
            }

            //return structs;

            //var list = new List<PageStruct>();

            return(list);
        }