+ has_many(:outgoing_relationships, UserRelationship, foreign_key: :source_id)
+ has_many(:incoming_relationships, UserRelationship, foreign_key: :target_id)
+
+ for {relationship_type,
+ [
+ {outgoing_relation, outgoing_relation_target},
+ {incoming_relation, incoming_relation_source}
+ ]} <- @user_relationships_config do
+ # Definitions of `has_many :blocker_blocks`, `has_many :muter_mutes` etc.
+ has_many(outgoing_relation, UserRelationship,
+ foreign_key: :source_id,
+ where: [relationship_type: relationship_type]
+ )
+
+ # Definitions of `has_many :blockee_blocks`, `has_many :mutee_mutes` etc.
+ has_many(incoming_relation, UserRelationship,
+ foreign_key: :target_id,
+ where: [relationship_type: relationship_type]
+ )
+
+ # Definitions of `has_many :blocked_users`, `has_many :muted_users` etc.
+ has_many(outgoing_relation_target, through: [outgoing_relation, :target])
+
+ # Definitions of `has_many :blocker_users`, `has_many :muter_users` etc.
+ has_many(incoming_relation_source, through: [incoming_relation, :source])
+ end
+
+ # `:blocks` is deprecated (replaced with `blocked_users` relation)
+ field(:blocks, {:array, :string}, default: [])
+ # `:mutes` is deprecated (replaced with `muted_users` relation)
+ field(:mutes, {:array, :string}, default: [])
+ # `:muted_reblogs` is deprecated (replaced with `reblog_muted_users` relation)
+ field(:muted_reblogs, {:array, :string}, default: [])
+ # `:muted_notifications` is deprecated (replaced with `notification_muted_users` relation)
+ field(:muted_notifications, {:array, :string}, default: [])
+ # `:subscribers` is deprecated (replaced with `subscriber_users` relation)
+ field(:subscribers, {:array, :string}, default: [])
+