FIX: update all categories on startup
This commit is contained in:
Родитель
36aab4f00a
Коммит
ca205f63e8
16
plugin.rb
16
plugin.rb
|
@ -1,11 +1,17 @@
|
|||
# name: auto-email-in
|
||||
# about: Discourse plugin which automatically sets category email-in addresses based on their slug
|
||||
# version: 1.2.0
|
||||
# version: 1.2.1
|
||||
# authors: Leo McArdle
|
||||
# url: https://github.com/mozilla/discourse-auto-email-in
|
||||
|
||||
enabled_site_setting :auto_email_in_enabled
|
||||
|
||||
def update_all_categories
|
||||
::Category.all.each do |category|
|
||||
category.update_email_in
|
||||
end
|
||||
end
|
||||
|
||||
after_initialize do
|
||||
require_dependency 'category'
|
||||
class ::Category
|
||||
|
@ -46,12 +52,14 @@ after_initialize do
|
|||
end
|
||||
end
|
||||
end
|
||||
|
||||
if SiteSetting.auto_email_in_enabled
|
||||
update_all_categories
|
||||
end
|
||||
end
|
||||
|
||||
DiscourseEvent.on(:site_setting_changed) do |name|
|
||||
if name == :auto_email_in_enabled or name == :auto_email_in_divider or name == :auto_email_in_domain
|
||||
Category.all.each do |category|
|
||||
category.update_email_in
|
||||
end
|
||||
update_all_categories
|
||||
end
|
||||
end
|
||||
|
|
Загрузка…
Ссылка в новой задаче