2024-12-27 03:03:37 +00:00
|
|
|
defmodule PostlandWeb.DevLive do
|
|
|
|
|
use PostlandWeb, :live_view
|
|
|
|
|
use Phoenix.VerifiedRoutes, endpoint: PostlandWeb.Endpoint, router: PostlandWeb.Router
|
|
|
|
|
|
|
|
|
|
alias Postland.Activities
|
|
|
|
|
|
|
|
|
|
def render(assigns) do
|
|
|
|
|
~H"""
|
|
|
|
|
<.button phx-click="make_follower_request">Make follower request</.button>
|
|
|
|
|
"""
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def handle_event("make_follower_request", _, socket) do
|
|
|
|
|
mock_actor = "https://example.com/actors/test"
|
|
|
|
|
encoded_followee = Base.url_encode64(Postland.my_actor_id(), padding: false)
|
|
|
|
|
encoded_follower = Base.url_encode64(mock_actor, padding: false)
|
|
|
|
|
|
|
|
|
|
Activities.process_activity(%{
|
|
|
|
|
"@context" => "https://www.w3.org/ns/activitystreams",
|
|
|
|
|
"id" => url(~p"/follows/#{encoded_followee}/#{encoded_follower}"),
|
|
|
|
|
"type" => "Follow",
|
|
|
|
|
"actor" => mock_actor,
|
|
|
|
|
"object" => Postland.my_actor_id()
|
|
|
|
|
})
|
|
|
|
|
|
2024-12-27 03:26:10 +00:00
|
|
|
{:noreply, socket |> push_navigate(to: ~p"/followers")}
|
2024-12-27 03:03:37 +00:00
|
|
|
end
|
|
|
|
|
end
|