2024-05-22 22:19:07 -04:00
|
|
|
# frozen_string_literal: true
|
2024-08-13 04:32:11 -04:00
|
|
|
|
2024-06-06 01:45:30 -04:00
|
|
|
Flag.seed do |s|
|
|
|
|
s.id = 6
|
|
|
|
s.name = "notify_user"
|
|
|
|
s.notify_type = false
|
|
|
|
s.auto_action_type = false
|
2024-07-17 20:10:22 -04:00
|
|
|
s.require_message = true
|
2024-06-06 01:45:30 -04:00
|
|
|
s.applies_to = %w[Post Chat::Message]
|
2024-08-12 23:22:57 -04:00
|
|
|
s.skip_reset_flag_callback = true
|
2024-06-06 01:45:30 -04:00
|
|
|
end
|
2024-05-22 22:19:07 -04:00
|
|
|
Flag.seed do |s|
|
|
|
|
s.id = 3
|
|
|
|
s.name = "off_topic"
|
|
|
|
s.notify_type = true
|
|
|
|
s.auto_action_type = true
|
2024-07-17 20:10:22 -04:00
|
|
|
s.require_message = false
|
2024-05-22 22:19:07 -04:00
|
|
|
s.applies_to = %w[Post Chat::Message]
|
2024-08-12 23:22:57 -04:00
|
|
|
s.skip_reset_flag_callback = true
|
2024-05-22 22:19:07 -04:00
|
|
|
end
|
|
|
|
Flag.seed do |s|
|
|
|
|
s.id = 4
|
|
|
|
s.name = "inappropriate"
|
|
|
|
s.notify_type = true
|
|
|
|
s.auto_action_type = true
|
2024-07-17 20:10:22 -04:00
|
|
|
s.require_message = false
|
2024-05-22 22:19:07 -04:00
|
|
|
s.applies_to = %w[Post Topic Chat::Message]
|
2024-08-12 23:22:57 -04:00
|
|
|
s.skip_reset_flag_callback = true
|
2024-05-22 22:19:07 -04:00
|
|
|
end
|
|
|
|
Flag.seed do |s|
|
|
|
|
s.id = 8
|
|
|
|
s.name = "spam"
|
|
|
|
s.notify_type = true
|
|
|
|
s.auto_action_type = true
|
2024-07-17 20:10:22 -04:00
|
|
|
s.require_message = false
|
2024-05-22 22:19:07 -04:00
|
|
|
s.applies_to = %w[Post Topic Chat::Message]
|
2024-08-12 23:22:57 -04:00
|
|
|
s.skip_reset_flag_callback = true
|
2024-05-22 22:19:07 -04:00
|
|
|
end
|
|
|
|
Flag.seed do |s|
|
2024-06-06 01:45:30 -04:00
|
|
|
s.id = 10
|
|
|
|
s.name = "illegal"
|
2024-05-22 22:19:07 -04:00
|
|
|
s.notify_type = true
|
|
|
|
s.auto_action_type = false
|
2024-07-17 20:10:22 -04:00
|
|
|
s.require_message = true
|
2024-05-22 22:19:07 -04:00
|
|
|
s.applies_to = %w[Post Topic Chat::Message]
|
2024-08-12 23:22:57 -04:00
|
|
|
s.skip_reset_flag_callback = true
|
2024-05-22 22:19:07 -04:00
|
|
|
end
|
|
|
|
Flag.seed do |s|
|
2024-06-06 01:45:30 -04:00
|
|
|
s.id = 7
|
|
|
|
s.name = "notify_moderators"
|
2024-05-22 22:19:07 -04:00
|
|
|
s.notify_type = true
|
|
|
|
s.auto_action_type = false
|
2024-07-17 20:10:22 -04:00
|
|
|
s.require_message = true
|
2024-05-22 22:19:07 -04:00
|
|
|
s.applies_to = %w[Post Topic Chat::Message]
|
2024-08-12 23:22:57 -04:00
|
|
|
s.skip_reset_flag_callback = true
|
2024-05-22 22:19:07 -04:00
|
|
|
end
|
2024-06-04 23:27:06 -04:00
|
|
|
Flag.unscoped.seed do |s|
|
2024-05-29 00:39:58 -04:00
|
|
|
s.id = 9
|
|
|
|
s.name = "needs_approval"
|
|
|
|
s.notify_type = false
|
|
|
|
s.auto_action_type = false
|
2024-07-17 20:10:22 -04:00
|
|
|
s.require_message = false
|
2024-05-29 00:39:58 -04:00
|
|
|
s.score_type = true
|
|
|
|
s.applies_to = %w[]
|
2024-08-12 23:22:57 -04:00
|
|
|
s.skip_reset_flag_callback = true
|
2024-05-29 00:39:58 -04:00
|
|
|
end
|
FIX: serialize Flags instead of PostActionType (#28362)
### Why?
Before, all flags were static. Therefore, they were stored in class variables and serialized by SiteSerializer. Recently, we added an option for admins to add their own flags or disable existing flags. Therefore, the class variable had to be dropped because it was unsafe for a multisite environment. However, it started causing performance problems.
### Solution
When a new Flag system is used, instead of using PostActionType, we can serialize Flags and use fragment cache for performance reasons.
At the same time, we are still supporting deprecated `replace_flags` API call. When it is used, we fall back to the old solution and the admin cannot add custom flags. In a couple of months, we will be able to drop that API function and clean that code properly. However, because it may still be used, redis cache was introduced to improve performance.
To test backward compatibility you can add this code to any plugin
```ruby
replace_flags do |flag_settings|
flag_settings.add(
4,
:inappropriate,
topic_type: true,
notify_type: true,
auto_action_type: true,
)
flag_settings.add(1001, :trolling, topic_type: true, notify_type: true, auto_action_type: true)
end
```
2024-08-13 22:13:46 -04:00
|
|
|
Flag.unscoped.seed do |s|
|
|
|
|
s.id = 2
|
|
|
|
s.name = "like"
|
|
|
|
s.notify_type = false
|
|
|
|
s.auto_action_type = false
|
|
|
|
s.require_message = false
|
|
|
|
s.score_type = false
|
|
|
|
s.applies_to = %w[Post]
|
|
|
|
s.skip_reset_flag_callback = true
|
|
|
|
end
|
2024-09-08 20:40:43 -04:00
|
|
|
|
|
|
|
Flag.reset_flag_settings!
|