mirror of
https://github.com/discourse/discourse.git
synced 2025-09-05 08:59:27 +08:00
FIX: Avoid publishing a gigantic payload.
* Certain sites have way too many categories.
This commit is contained in:
parent
996ce8c443
commit
ed851dbfff
4 changed files with 33 additions and 5 deletions
|
@ -414,12 +414,18 @@ class Group < ActiveRecord::Base
|
|||
users.pluck(:username).join(",")
|
||||
end
|
||||
|
||||
PUBLISH_CATEGORIES_LIMIT = 10
|
||||
|
||||
def add(user)
|
||||
self.users.push(user) unless self.users.include?(user)
|
||||
|
||||
MessageBus.publish('/categories', {
|
||||
categories: ActiveModel::ArraySerializer.new(self.categories).as_json
|
||||
}, user_ids: [user.id])
|
||||
if self.categories.count < PUBLISH_CATEGORIES_LIMIT
|
||||
MessageBus.publish('/categories', {
|
||||
categories: ActiveModel::ArraySerializer.new(self.categories).as_json
|
||||
}, user_ids: [user.id])
|
||||
else
|
||||
Discourse.request_refresh!(user_ids: [user.id])
|
||||
end
|
||||
|
||||
self
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue