2022-11-20 07:38:02 -08:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2021-12-22 10:21:09 -08:00
|
|
|
class MuteRule < ApplicationRecord
|
|
|
|
belongs_to :user
|
|
|
|
|
2023-10-14 21:40:32 -07:00
|
|
|
validates :muted_phrase, length: { minimum: 1 }
|
2022-11-20 06:06:20 -08:00
|
|
|
|
2021-12-22 10:21:09 -08:00
|
|
|
def applies_to?(post)
|
2021-12-22 10:33:19 -08:00
|
|
|
!!(post.content =~ /\b#{Regexp.escape(muted_phrase)}\b/i)
|
2021-12-22 10:21:09 -08:00
|
|
|
end
|
|
|
|
end
|