FIX: update all categories on startup

This commit is contained in:
Leo McArdle 2019-10-11 18:59:38 +01:00
Родитель 36aab4f00a
Коммит ca205f63e8
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 8262833620A64C3F
1 изменённых файлов: 12 добавлений и 4 удалений

Просмотреть файл

@ -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