<%# Displays buttons to follow/revoke following on a given actor. Requires variables: - user (usually user) - actor (target actor) %>

<% if Federails::Client::FollowingPolicy.new(user, Federails::Following).create? %> <% follow = user.federails_actor.follows? actor %> <% if actor.entity == user %> <% elsif follow %> Already following (<%= follow.status %>) <%= button_to 'Cancel', federails.client_following_path(follow), method: :delete %> <% else %> <%= button_to "Follow #{actor.username}", federails.follow_client_followings_path, params: { account: actor.at_address }, method: :post %> <% end %> <% followed = actor.follows? user.federails_actor %> <% if followed %> <% if followed.pending? %> <%= actor.username %> wants to follow you. <%= button_to 'Accept request', federails.accept_client_following_path(followed), method: :put %> <% else %> <%= actor.username %> follows you. <%= button_to 'Revoke', federails.client_following_path(followed), method: :delete %> <% end %> <% end %> <% else %> <%= user.class.name %> is not configured to follow/be followed, or has no associated actor. <% end %>