Class: PostActionType

Inherits:
ActiveRecord::Base
  • Object
show all
Includes:
AnonCacheInvalidator
Defined in:
app/models/post_action_type.rb

Constant Summary collapse

POST_ACTION_TYPE_ALL_FLAGS_KEY =
"post_action_type_all_flags"
POST_ACTION_TYPE_PUBLIC_TYPE_IDS_KEY =
"post_action_public_type_ids"
LIKE_POST_ACTION_ID =
2

Class Attribute Summary collapse

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Class Attribute Details

.flag_settingsObject (readonly)

Returns the value of attribute flag_settings.



29
30
31
# File 'app/models/post_action_type.rb', line 29

def flag_settings
  @flag_settings
end

Instance Attribute Details

#skip_expire_cache_callbackObject

Returns the value of attribute skip_expire_cache_callback.



11
12
13
# File 'app/models/post_action_type.rb', line 11

def skip_expire_cache_callback
  @skip_expire_cache_callback
end

Class Method Details

.initialize_flag_settingsObject



31
32
33
# File 'app/models/post_action_type.rb', line 31

def initialize_flag_settings
  @flag_settings = FlagSettings.new
end

.reload_typesObject



40
41
42
43
44
# File 'app/models/post_action_type.rb', line 40

def reload_types
  @flag_settings = FlagSettings.new
  PostActionType.new.expire_cache
  ReviewableScore.reload_types
end

.replace_flag_settings(settings) ⇒ Object



35
36
37
38
# File 'app/models/post_action_type.rb', line 35

def replace_flag_settings(settings)
  Discourse.deprecate("Flags should not be replaced. Insert custom flags as database records.")
  @flag_settings = settings || FlagSettings.new
end

Instance Method Details

#expire_cacheObject



15
16
17
18
19
20
21
22
23
24
25
26
# File 'app/models/post_action_type.rb', line 15

def expire_cache
  Discourse.cache.redis.del(
    *I18n.available_locales.map do |locale|
      Discourse.cache.normalize_key("post_action_types_#{locale}")
    end,
    *I18n.available_locales.map do |locale|
      Discourse.cache.normalize_key("post_action_flag_types_#{locale}")
    end,
    Discourse.cache.normalize_key(POST_ACTION_TYPE_ALL_FLAGS_KEY),
    Discourse.cache.normalize_key(POST_ACTION_TYPE_PUBLIC_TYPE_IDS_KEY),
  )
end