mirror of
https://github.com/discourse/discourse.git
synced 2025-05-22 16:11:08 +08:00
FEATURE: allow group members to see all messages on group page
This commit is contained in:
@ -6,10 +6,19 @@ class GroupsController < ApplicationController
|
||||
|
||||
def counts
|
||||
group = find_group(:group_id)
|
||||
render json: {counts: { posts: group.posts_for(guardian).count,
|
||||
topics: group.posts_for(guardian).where(post_number: 1).count,
|
||||
mentions: group.mentioned_posts_for(guardian).count,
|
||||
members: group.users.count } }
|
||||
|
||||
counts = {
|
||||
posts: group.posts_for(guardian).count,
|
||||
topics: group.posts_for(guardian).where(post_number: 1).count,
|
||||
mentions: group.mentioned_posts_for(guardian).count,
|
||||
members: group.users.count,
|
||||
}
|
||||
|
||||
if guardian.can_see_group_messages?(group)
|
||||
counts[:messages] = group.messages_for(guardian).where(post_number: 1).count
|
||||
end
|
||||
|
||||
render json: { counts: counts }
|
||||
end
|
||||
|
||||
def posts
|
||||
@ -30,6 +39,15 @@ class GroupsController < ApplicationController
|
||||
render_serialized posts.to_a, GroupPostSerializer
|
||||
end
|
||||
|
||||
def messages
|
||||
group = find_group(:group_id)
|
||||
posts = if guardian.can_see_group_messages?(group)
|
||||
group.messages_for(guardian, params[:before_post_id]).where(post_number: 1).limit(20).to_a
|
||||
else
|
||||
[]
|
||||
end
|
||||
render_serialized posts, GroupPostSerializer
|
||||
end
|
||||
|
||||
def members
|
||||
group = find_group(:group_id)
|
||||
@ -114,8 +132,4 @@ class GroupsController < ApplicationController
|
||||
group
|
||||
end
|
||||
|
||||
def the_group
|
||||
@the_group ||= find_group(:group_id)
|
||||
end
|
||||
|
||||
end
|
||||
|
Reference in New Issue
Block a user