1
0
mirror of https://git.teknik.io/Teknikode/Teknik.git synced 2023-08-02 14:16:22 +02:00

Fixed RSS not showing up to date system blog posts

This commit is contained in:
Uncled1023 2017-02-14 15:40:45 -08:00
parent 986dd37f71
commit e9a40eefe8

View File

@ -12,6 +12,7 @@ using Teknik.Filters;
using Teknik.Utilities;
using Teknik.Models;
using Teknik.Attributes;
using Teknik.Areas.Users.Utility;
namespace Teknik.Areas.RSS.Controllers
{
@ -33,22 +34,24 @@ namespace Teknik.Areas.RSS.Controllers
public ActionResult Blog(string username)
{
// If empty, grab the main blog
Blog.Models.Blog blog = null;
List<BlogPost> posts = new List<BlogPost>();
string blogUrl = Url.SubRouteUrl("blog", "Blog.Blog");
string title = string.Empty;
string description = string.Empty;
bool isSystem = string.IsNullOrEmpty(username);
if (isSystem)
{
blog = db.Blogs.Where(b => b.BlogId == Config.BlogConfig.ServerBlogId).FirstOrDefault();
posts = db.BlogPosts.Where(p => (p.System && p.Published)).ToList();
blogUrl = Url.SubRouteUrl("blog", "Blog.Blog");
}
else
{
blog = db.Blogs.Where(b => b.User.Username == username).FirstOrDefault();
Blog.Models.Blog blog = db.Blogs.Where(p => p.User.Username == username && p.BlogId != Config.BlogConfig.ServerBlogId).FirstOrDefault();
posts = db.BlogPosts.Where(p => (p.BlogId == blog.BlogId && !p.System) && p.Published).ToList();
blogUrl = Url.SubRouteUrl("blog", "Blog.Blog", new { username = username });
}
if (blog != null)
if (posts.Any())
{
if (isSystem)
{
@ -57,13 +60,21 @@ namespace Teknik.Areas.RSS.Controllers
}
else
{
title = blog.User.BlogSettings.Title;
description = blog.User.BlogSettings.Description;
Users.Models.User user = UserHelper.GetUser(db, username);
if (user != null)
{
title = user.BlogSettings.Title;
description = user.BlogSettings.Description;
}
else
{
}
}
List<SyndicationItem> items = new List<SyndicationItem>();
foreach (BlogPost post in blog.BlogPosts.OrderByDescending(p => p.BlogPostId))
foreach (BlogPost post in posts.OrderByDescending(p => p.BlogPostId))
{
if (post.Published && post.System == isSystem)
{