Ensure mute rules cannot be empty

This commit is contained in:
Karina Kwiatek 2022-11-20 15:06:20 +01:00 committed by Andreas Nedbal
parent 0c9bb05f29
commit 40d5dc41dd
1 changed files with 2 additions and 0 deletions

View File

@ -1,6 +1,8 @@
class MuteRule < ApplicationRecord
belongs_to :user
validates_presence_of :muted_phrase
def applies_to?(post)
!!(post.content =~ /\b#{Regexp.escape(muted_phrase)}\b/i)
end