about summary refs log tree commit diff
path: root/app/controllers/filters_controller.rb
diff options
context:
space:
mode:
authorClaire <claire.github-309c@sitedethib.com>2022-06-28 11:11:18 +0200
committerClaire <claire.github-309c@sitedethib.com>2022-06-28 11:11:18 +0200
commitfe5f6bc7edf42e8c87dbdfa98f5707020e42d400 (patch)
tree2e632dfa964aad5cf118930389cf95904f3bd82a /app/controllers/filters_controller.rb
parent63f79874b59b3ba28c0f940b9d36ea7aacb44c93 (diff)
parent02851848e964675bb59919fa5fd1bdee2c1c29db (diff)
Merge branch 'main' into glitch-soc/merge-upstream
Conflicts:
- `.github/workflows/build-image.yml`:
  Fix erroneous deletion in a previous merge.
- `Gemfile`:
  Conflict caused by glitch-soc-only hCaptcha dependency
- `app/controllers/auth/sessions_controller.rb`:
  Minor conflict due to glitch-soc's theming system.
- `app/controllers/filters_controller.rb`:
  Minor conflict due to glitch-soc's theming system.
- `app/serializers/rest/status_serializer.rb`:
  Minor conflict due to glitch-soc having an extra `local_only` property
Diffstat (limited to 'app/controllers/filters_controller.rb')
-rw-r--r--app/controllers/filters_controller.rb12
1 files changed, 4 insertions, 8 deletions
diff --git a/app/controllers/filters_controller.rb b/app/controllers/filters_controller.rb
index 0d4c1b97c..6d778312e 100644
--- a/app/controllers/filters_controller.rb
+++ b/app/controllers/filters_controller.rb
@@ -4,17 +4,17 @@ class FiltersController < ApplicationController
   layout 'admin'
 
   before_action :authenticate_user!
-  before_action :set_filters, only: :index
   before_action :set_filter, only: [:edit, :update, :destroy]
   before_action :set_pack
   before_action :set_body_classes
 
   def index
-    @filters = current_account.custom_filters.order(:phrase)
+    @filters = current_account.custom_filters.includes(:keywords).order(:phrase)
   end
 
   def new
-    @filter = current_account.custom_filters.build
+    @filter = current_account.custom_filters.build(action: :warn)
+    @filter.keywords.build
   end
 
   def create
@@ -48,16 +48,12 @@ class FiltersController < ApplicationController
     use_pack 'settings'
   end
 
-  def set_filters
-    @filters = current_account.custom_filters
-  end
-
   def set_filter
     @filter = current_account.custom_filters.find(params[:id])
   end
 
   def resource_params
-    params.require(:custom_filter).permit(:phrase, :expires_in, :irreversible, :whole_word, context: [])
+    params.require(:custom_filter).permit(:title, :expires_in, :filter_action, context: [], keywords_attributes: [:id, :keyword, :whole_word, :_destroy])
   end
 
   def set_body_classes