blob: 1d835dc465b3e95f9f14cddb248ec808eb0646cc (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
# frozen_string_literal: true
class Block < ApplicationRecord
belongs_to :person
belongs_to :user
delegate :name, :diaspora_handle, to: :person, prefix: true
validates :person_id, uniqueness: {scope: :user_id}
validate :not_blocking_yourself
def not_blocking_yourself
return unless user.person.id == person_id
errors.add(:person_id, "stop blocking yourself!")
end
# @return [Array<Person>] The recipient of the block
def subscribers
[person]
end
end
|