about summary refs log tree commit diff
path: root/app
diff options
context:
space:
mode:
Diffstat (limited to 'app')
-rw-r--r--app/controllers/api/v1/filters_controller.rb2
-rw-r--r--app/controllers/filters_controller.rb2
-rw-r--r--app/helpers/filter_helper.rb1
-rw-r--r--app/models/custom_filter.rb1
-rw-r--r--app/views/filters/_fields.html.haml7
5 files changed, 10 insertions, 3 deletions
diff --git a/app/controllers/api/v1/filters_controller.rb b/app/controllers/api/v1/filters_controller.rb
index 6b8b82285..8194480fa 100644
--- a/app/controllers/api/v1/filters_controller.rb
+++ b/app/controllers/api/v1/filters_controller.rb
@@ -43,6 +43,6 @@ class Api::V1::FiltersController < Api::BaseController
   end
 
   def resource_params
-    params.permit(:phrase, :expires_in, :whole_word, :exclude_media, :media_only, :status_text, :spoiler, :tags, :custom_cw, :override_cw, :desc, context: [])
+    params.permit(:phrase, :expires_in, :whole_word, :exclude_media, :media_only, :status_text, :spoiler, :tags, :custom_cw, :override_cw, :desc, :no_desc, context: [])
   end
 end
diff --git a/app/controllers/filters_controller.rb b/app/controllers/filters_controller.rb
index c80e6853a..8a4636ba2 100644
--- a/app/controllers/filters_controller.rb
+++ b/app/controllers/filters_controller.rb
@@ -58,7 +58,7 @@ class FiltersController < ApplicationController
   end
 
   def resource_params
-    params.require(:custom_filter).permit(:phrase, :expires_in, :irreversible, :whole_word, :exclude_media, :media_only, :status_text, :spoiler, :tags, :custom_cw, :override_cw, :desc, context: [])
+    params.require(:custom_filter).permit(:phrase, :expires_in, :irreversible, :whole_word, :exclude_media, :media_only, :status_text, :spoiler, :tags, :custom_cw, :override_cw, :desc, :no_desc, context: [])
   end
 
   def set_body_classes
diff --git a/app/helpers/filter_helper.rb b/app/helpers/filter_helper.rb
index 3e3b4b748..a4a86496f 100644
--- a/app/helpers/filter_helper.rb
+++ b/app/helpers/filter_helper.rb
@@ -41,6 +41,7 @@ module FilterHelper
       matched ||= regex.match(spoiler_text).present? if filter.spoiler && spoiler_text.present?
       matched ||= regex.match(tags).present? if filter.tags && tags.present?
       matched ||= regex.match(descs).present? if filter.desc && descs.present?
+      matched ||= status.media_attachments.all { |a| a.description.blank? } if filter.no_desc && status.media_attachments.any?
 
       if matched
         filter_thread(receiver_id, status.conversation_id) if filter.thread && filter.custom_cw.blank?
diff --git a/app/models/custom_filter.rb b/app/models/custom_filter.rb
index fb269d8f4..5feb5fd7d 100644
--- a/app/models/custom_filter.rb
+++ b/app/models/custom_filter.rb
@@ -21,6 +21,7 @@
 #  custom_cw     :text
 #  override_cw   :boolean          default(FALSE), not null
 #  desc          :boolean          default(FALSE), not null
+#  no_desc       :boolean          default(FALSE), not null
 #
 
 class CustomFilter < ApplicationRecord
diff --git a/app/views/filters/_fields.html.haml b/app/views/filters/_fields.html.haml
index 6389e11b1..da0add2ea 100644
--- a/app/views/filters/_fields.html.haml
+++ b/app/views/filters/_fields.html.haml
@@ -16,8 +16,13 @@
   = f.input :status_text, wrapper: :with_label
   = f.input :spoiler, wrapper: :with_label
   = f.input :tags, wrapper: :with_label
-  = f.input :desc, wrapper: :with_label
   = f.input :thread, wrapper: :with_label
+
+.fields-group
+  = f.input :desc, wrapper: :with_label
+  = f.input :no_desc, wrapper: :with_label
+
+.fields-group
   = f.input :media_only, wrapper: :with_label
   = f.input :exclude_media, wrapper: :with_label