mirror of
https://github.com/discourse/discourse.git
synced 2026-08-11 13:35:20 -05:00
FEATURE: show group mentions and topics in groups page
This commit is contained in:
@@ -3,6 +3,7 @@ class Group < ActiveRecord::Base
|
||||
|
||||
has_many :category_groups, dependent: :destroy
|
||||
has_many :group_users, dependent: :destroy
|
||||
has_many :group_mentions, dependent: :destroy
|
||||
|
||||
has_many :categories, through: :category_groups
|
||||
has_many :users, through: :group_users
|
||||
@@ -80,6 +81,18 @@ class Group < ActiveRecord::Base
|
||||
result.order('posts.created_at desc')
|
||||
end
|
||||
|
||||
def mentioned_posts_for(guardian, before_post_id=nil)
|
||||
result = Post.joins(:group_mentions)
|
||||
.includes(:user, :topic, :topic => :category)
|
||||
.references(:posts, :topics, :category)
|
||||
.where('topics.archetype <> ?', Archetype.private_message)
|
||||
.where(post_type: Post.types[:regular])
|
||||
|
||||
result = guardian.filter_allowed_categories(result)
|
||||
result = result.where('posts.id < ?', before_post_id) if before_post_id
|
||||
result.order('posts.created_at desc')
|
||||
end
|
||||
|
||||
def self.trust_group_ids
|
||||
(10..19).to_a
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user