public async Task <PostStruct> GetPost( string blogId, string postId, string userName, string password, CancellationToken cancellationToken) { var existing = await blogService.GetPost( blogId, postId, userName, password ).ConfigureAwait(false); if (existing == null) { return(new PostStruct()); } var commentsOpen = await blogService.CommentsAreOpen(existing, false); var postUrl = await blogService.ResolvePostUrl(existing); var postStruct = mapper.GetStructFromPost(existing, postUrl, commentsOpen); // 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 return(postStruct); }
public async Task <PostStruct> GetPost( string blogId, string postId, string userName, string password, CancellationToken cancellationToken) { var permission = await _security.ValidatePermissions( blogId, userName, password, CancellationToken.None ).ConfigureAwait(false); if (!permission.CanEditPosts) { _log.LogWarning($"user {userName} cannot edit posts"); return(new PostStruct()); } var existing = await _blogService.GetPost(postId, cancellationToken).ConfigureAwait(false); if (existing == null) { return(new PostStruct()); } var commentsOpen = await _blogService.CommentsAreOpen(existing, false).ConfigureAwait(false); var project = await _projectService.GetCurrentProjectSettings().ConfigureAwait(false); if (project == null) { _log.LogError($"could not resolve project settings"); return(new PostStruct()); } await _blogUrlResolver.ConvertMediaToAbsoluteUrls(existing, project).ConfigureAwait(false); var postUrl = await _blogUrlResolver.ResolvePostUrl(existing, project).ConfigureAwait(false); var postStruct = _mapper.GetStructFromPost(existing, postUrl, commentsOpen); return(postStruct); }