Browse Source

Fixed RSS not showing up to date system blog posts

tags/2.0.6
Teknikode 3 years ago
parent
commit
e9a40eefe8
1 changed files with 18 additions and 7 deletions
  1. 18
    7
      Teknik/Areas/RSS/Controllers/RSSController.cs

+ 18
- 7
Teknik/Areas/RSS/Controllers/RSSController.cs 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)
{

Loading…
Cancel
Save