retrospring/app/models/mute_rule.rb

12 lines
233 B
Ruby
Raw Normal View History

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