Sha256: eafe479cd5a57628b80844e373e260ba3636d96eb1d30f2a7aeff8e3607ef312

Contents?: true

Size: 682 Bytes

Versions: 1

Compression:

Stored size: 682 Bytes

Contents

module Federails
  module Client
    class FollowingPolicy < Federails::FederailsPolicy
      def show?
        in_following?
      end

      def destroy?
        in_following?
      end

      def accept?
        in_following? && @record.target_actor_id == @user.federails_actor.id
      end

      def follow?
        create?
      end

      class Scope < Scope
        def resolve
          scope.with_actor(@user.federails_actor)
        end
      end

      private

      def in_following?
        return false unless user_with_actor?

        @record.actor_id == @user.federails_actor&.id || @record.target_actor_id == @user.federails_actor&.id
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
federails-0.4.0 app/policies/federails/client/following_policy.rb