mirror of
https://github.com/discourse/discourse.git
synced 2025-02-21 03:19:10 +00:00
DEV: Compatibility with TruffleRuby (#16864)
Removes thread unsafe lazy initialization. See https://meta.discourse.org/t/225447 It also removes an unused variable in `FlagSettings`.
This commit is contained in:
parent
166fe3bb34
commit
0af05c2682
@ -12,51 +12,14 @@ class PostActionType < ActiveRecord::Base
|
||||
end
|
||||
|
||||
class << self
|
||||
|
||||
def flag_settings
|
||||
unless @flag_settings
|
||||
@flag_settings = FlagSettings.new
|
||||
@flag_settings.add(
|
||||
3,
|
||||
:off_topic,
|
||||
notify_type: true,
|
||||
auto_action_type: true,
|
||||
)
|
||||
@flag_settings.add(
|
||||
4,
|
||||
:inappropriate,
|
||||
topic_type: true,
|
||||
notify_type: true,
|
||||
auto_action_type: true,
|
||||
)
|
||||
@flag_settings.add(
|
||||
8,
|
||||
:spam,
|
||||
topic_type: true,
|
||||
notify_type: true,
|
||||
auto_action_type: true,
|
||||
)
|
||||
@flag_settings.add(
|
||||
6,
|
||||
:notify_user,
|
||||
topic_type: false,
|
||||
notify_type: false,
|
||||
custom_type: true
|
||||
)
|
||||
@flag_settings.add(
|
||||
7,
|
||||
:notify_moderators,
|
||||
topic_type: true,
|
||||
notify_type: true,
|
||||
custom_type: true
|
||||
)
|
||||
end
|
||||
|
||||
@flag_settings
|
||||
end
|
||||
attr_reader :flag_settings
|
||||
|
||||
def replace_flag_settings(settings)
|
||||
@flag_settings = settings
|
||||
if settings
|
||||
@flag_settings = settings
|
||||
else
|
||||
initialize_flag_settings
|
||||
end
|
||||
@types = nil
|
||||
end
|
||||
|
||||
@ -117,7 +80,49 @@ class PostActionType < ActiveRecord::Base
|
||||
def is_flag?(sym)
|
||||
flag_types.valid?(sym)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def initialize_flag_settings
|
||||
@flag_settings = FlagSettings.new
|
||||
@flag_settings.add(
|
||||
3,
|
||||
:off_topic,
|
||||
notify_type: true,
|
||||
auto_action_type: true,
|
||||
)
|
||||
@flag_settings.add(
|
||||
4,
|
||||
:inappropriate,
|
||||
topic_type: true,
|
||||
notify_type: true,
|
||||
auto_action_type: true,
|
||||
)
|
||||
@flag_settings.add(
|
||||
8,
|
||||
:spam,
|
||||
topic_type: true,
|
||||
notify_type: true,
|
||||
auto_action_type: true,
|
||||
)
|
||||
@flag_settings.add(
|
||||
6,
|
||||
:notify_user,
|
||||
topic_type: false,
|
||||
notify_type: false,
|
||||
custom_type: true
|
||||
)
|
||||
@flag_settings.add(
|
||||
7,
|
||||
:notify_moderators,
|
||||
topic_type: true,
|
||||
notify_type: true,
|
||||
custom_type: true
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
initialize_flag_settings
|
||||
end
|
||||
|
||||
# == Schema Information
|
||||
|
@ -20,8 +20,6 @@ class FlagSettings
|
||||
end
|
||||
|
||||
def add(id, name, topic_type: nil, notify_type: nil, auto_action_type: nil, custom_type: nil)
|
||||
details ||= {}
|
||||
|
||||
@all_flag_types[name] = id
|
||||
@topic_flag_types[name] = id if !!topic_type
|
||||
@notify_types[name] = id if !!notify_type
|
||||
|
Loading…
x
Reference in New Issue
Block a user