DEV: Set disable_mailing_list_mode automatically (#12402)

The user mailing list mode continued to be silently enabled and
UserEmail job checked just that ignoring site setting
disable_mailing_list_mode.

An additional migrate was added to set disable_mailing_list_mode
to false if any users enabled the mailing list mode already.
This commit is contained in:
Bianca Nenciu
2021-03-17 17:39:10 +02:00
committed by GitHub
parent 38dd81d38a
commit 16b5fa030b
3 changed files with 40 additions and 1 deletions

View File

@@ -0,0 +1,21 @@
# frozen_string_literal: true
class SetDisableMailingListMode < ActiveRecord::Migration[6.0]
def up
result = execute "SELECT COUNT(*) FROM user_options WHERE mailing_list_mode"
if result.first['count'] > 0
execute <<~SQL
INSERT INTO site_settings(name, data_type, value, created_at, updated_at)
VALUES('disable_mailing_list_mode', 5, 'f', NOW(), NOW())
ON CONFLICT (name) DO UPDATE SET value = 'f'
SQL
end
end
def down
result = execute "SELECT COUNT(*) FROM user_options WHERE mailing_list_mode"
if result.first['count'] == 0
execute "DELETE FROM site_settings WHERE name = 'disable_mailing_list_mode'"
end
end
end