Fix showing profiles when logged out

This commit is contained in:
Shadowfacts 2021-08-25 16:29:06 -04:00
parent 836ead6625
commit 10a06fd634
Signed by: shadowfacts
GPG Key ID: 94A5AB95422746E5
2 changed files with 13 additions and 3 deletions

View File

@ -135,7 +135,7 @@ defmodule ClacksWeb.FrontendController do
current_user: current_user, current_user: current_user,
actor: user.actor, actor: user.actor,
statuses_with_actor: statuses_with_actor, statuses_with_actor: statuses_with_actor,
following_state: following_state(current_user.actor, user.actor) following_state: following_state(current_user, user.actor)
}) })
end end
end end
@ -305,9 +305,15 @@ defmodule ClacksWeb.FrontendController do
Repo.one(query) Repo.one(query)
end end
@spec following_state(follower :: User.t(), followee :: Actor.t()) ::
:following | :not_following | :pending
defp following_state(%User{actor: %Actor{} = actor}, followee) do
following_state(actor, followee)
end
@spec following_state(follower :: Actor.t(), followee :: Actor.t()) :: @spec following_state(follower :: Actor.t(), followee :: Actor.t()) ::
:following | :not_following | :pending :following | :not_following | :pending
defp following_state(follower, followee) do defp following_state(%Actor{} = follower, followee) do
case follow_activity(follower, followee) do case follow_activity(follower, followee) do
%Activity{data: %{"state" => "pending"}} -> %Activity{data: %{"state" => "pending"}} ->
:pending :pending
@ -319,4 +325,8 @@ defmodule ClacksWeb.FrontendController do
:not_following :not_following
end end
end end
defp following_state(_, _) do
:not_following
end
end end

View File

@ -9,7 +9,7 @@
</div> </div>
<div class="actor-actions"> <div class="actor-actions">
<%= unless @current_user.actor.ap_id == @actor.ap_id do %> <%= unless @current_user == nil || @current_user.actor.ap_id == @actor.ap_id do %>
<%= case @following_state do %> <%= case @following_state do %>
<% :not_following -> %> <% :not_following -> %>