FEATURE: add group posts and mentions RSS
This commit is contained in:
parent
54445f21c1
commit
bd83cf7f4c
|
@ -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)
|
||||
|
|
|
@ -204,6 +204,8 @@ en:
|
|||
hot: "Hot topics"
|
||||
top: "Top topics"
|
||||
posts: "Latest posts"
|
||||
group_posts: "Latest posts from %{group_name}"
|
||||
group_mentions: "Latest mentions from %{group_name}"
|
||||
too_late_to_edit: "That post was created too long ago. It can no longer be edited or deleted."
|
||||
revert_version_same: "The current version is same as the version you are trying to revert to."
|
||||
|
||||
|
|
|
@ -354,6 +354,9 @@ Discourse::Application.routes.draw do
|
|||
get "posts/:username/flagged" => "posts#flagged_posts", constraints: {username: USERNAME_ROUTE_FORMAT}
|
||||
|
||||
resources :groups do
|
||||
get "posts.rss" => "groups#posts_feed", format: :rss
|
||||
get "mentions.rss" => "groups#mentions_feed", format: :rss
|
||||
|
||||
get 'members'
|
||||
get 'posts'
|
||||
get 'topics'
|
||||
|
|
|
@ -228,4 +228,20 @@ describe GroupsController do
|
|||
|
||||
end
|
||||
|
||||
describe '.posts_feed' do
|
||||
it 'renders RSS' do
|
||||
get :posts_feed, group_id: group.name, format: :rss
|
||||
expect(response).to be_success
|
||||
expect(response.content_type).to eq('application/rss+xml')
|
||||
end
|
||||
end
|
||||
|
||||
describe '.mentions_feed' do
|
||||
it 'renders RSS' do
|
||||
get :mentions_feed, group_id: group.name, format: :rss
|
||||
expect(response).to be_success
|
||||
expect(response.content_type).to eq('application/rss+xml')
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue