Sha256: b283bf86fecf113d6615cb25dfff366bde55986adfe13ad8ae8b0fa2424c79cf

Contents?: true

Size: 642 Bytes

Versions: 1

Compression:

Stored size: 642 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.actor.id
      end

      def follow?
        create?
      end

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

      private

      def in_following?
        return false unless user_with_actor?

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

Version data entries

1 entries across 1 versions & 1 rubygems

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