Retrospring/app/models/mute_rule.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

12 lines
233 B
Ruby
Raw Normal View History

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
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