FEATURE: add group posts and mentions RSS

This commit is contained in:
Arpit Jalan
2016-03-18 21:49:45 +05:30
parent 54445f21c1
commit bd83cf7f4c
4 changed files with 40 additions and 0 deletions

View File

@ -1,6 +1,7 @@
class GroupsController < ApplicationController
before_filter :ensure_logged_in, only: [:set_notifications]
skip_before_filter :preload_json, :check_xhr, only: [:posts_feed, :mentions_feed]
def show
render_serialized(find_group(:id), BasicGroupSerializer)
@ -29,6 +30,15 @@ class GroupsController < ApplicationController
render_serialized posts.to_a, GroupPostSerializer
end
def posts_feed
group = find_group(:group_id)
@posts = group.posts_for(guardian).limit(50)
@title = "#{SiteSetting.title} - #{I18n.t("rss_description.group_posts", group_name: group.name)}"
@link = Discourse.base_url
@description = I18n.t("rss_description.group_posts", group_name: group.name)
render 'posts/latest', formats: [:rss]
end
def topics
group = find_group(:group_id)
posts = group.posts_for(guardian, params[:before_post_id]).where(post_number: 1).limit(20)
@ -41,6 +51,15 @@ class GroupsController < ApplicationController
render_serialized posts.to_a, GroupPostSerializer
end
def mentions_feed
group = find_group(:group_id)
@posts = group.mentioned_posts_for(guardian).limit(50)
@title = "#{SiteSetting.title} - #{I18n.t("rss_description.group_mentions", group_name: group.name)}"
@link = Discourse.base_url
@description = I18n.t("rss_description.group_mentions", group_name: group.name)
render 'posts/latest', formats: [:rss]
end
def messages
group = find_group(:group_id)
posts = if guardian.can_see_group_messages?(group)