discourse/spec/requests/api
Krzysztof Kotlarek 094052c1ff
FIX: serialize Flags instead of PostActionType (#28259)
### 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 11:22:37 +10:00
..
schemas FIX: serialize Flags instead of PostActionType (#28259) 2024-08-13 11:22:37 +10:00
shared DEV: Apply syntax_tree formatting to spec/* 2023-01-09 11:49:28 +00:00
backups_spec.rb DEV: Apply syntax_tree formatting to spec/* 2023-01-09 11:49:28 +00:00
badges_spec.rb DEV: Allow fab! without block (#24314) 2023-11-09 16:47:59 -06:00
categories_spec.rb DEV: Apply syntax_tree formatting to spec/* 2023-01-09 11:49:28 +00:00
groups_spec.rb DEV: Apply syntax_tree formatting to spec/* 2023-01-09 11:49:28 +00:00
invites_spec.rb FIX: Create invite api docs (#21460) 2023-05-09 13:20:46 -06:00
multiple_invites_spec.rb FEATURE: change /invites.json api endpoint to optionally accept array of emails (#24853) 2023-12-28 10:16:04 -05:00
notifications_spec.rb DEV: Block accidental serialization of entire AR models (#27668) 2024-07-01 17:08:48 -03:00
posts_spec.rb DEV: Block accidental serialization of entire AR models (#27668) 2024-07-01 17:08:48 -03:00
private_messages_spec.rb FIX: update id types in API docs to integers (#27412) 2024-06-26 20:44:39 -06:00
rate_limits_spec.rb DEV: Don't enforce per ip rate limits for admin api requests (#27500) 2024-06-17 13:21:11 -05:00
search_spec.rb DEV: Document group param for search endpoint (#19806) 2023-01-09 14:46:07 -07:00
site_spec.rb DEV: Document basic-info endpoint (#26471) 2024-04-02 14:53:19 -06:00
tags_spec.rb FIX: update id types in API docs to integers (#27412) 2024-06-26 20:44:39 -06:00
topics_spec.rb FIX: update id types in API docs to integers (#27412) 2024-06-26 20:44:39 -06:00
uploads_spec.rb DEV: Apply syntax_tree formatting to spec/* 2023-01-09 11:49:28 +00:00
user_badges_spec.rb DEV: Apply syntax_tree formatting to spec/* 2023-01-09 11:49:28 +00:00
users_spec.rb FIX: update id types in API docs to integers (#27412) 2024-06-26 20:44:39 -06:00