Display status link in remote interaction form
This commit is contained in:
parent
b7c75db0f7
commit
1218adacc5
|
@ -1,10 +1,7 @@
|
||||||
<%= if @error do %>
|
<%= if @error do %>
|
||||||
<h2>Error: <%= @error %></h2>
|
<h2>Error: <%= @error %></h2>
|
||||||
<% else %>
|
<% else %>
|
||||||
<h2>Interacting with <%= @nickname %></h2>
|
<h2>Interacting with <%= @nickname %>'s <%= link("status", to: @status_link) %></h2>
|
||||||
<div>
|
|
||||||
<%= @status_id %>
|
|
||||||
</div>
|
|
||||||
<%= form_for @conn, Routes.util_path(@conn, :remote_subscribe), [as: "status"], fn f -> %>
|
<%= form_for @conn, Routes.util_path(@conn, :remote_subscribe), [as: "status"], fn f -> %>
|
||||||
<%= hidden_input f, :status_id, value: @status_id %>
|
<%= hidden_input f, :status_id, value: @status_id %>
|
||||||
<%= text_input f, :profile, placeholder: "Your account ID, e.g. lain@quitter.se" %>
|
<%= text_input f, :profile, placeholder: "Your account ID, e.g. lain@quitter.se" %>
|
||||||
|
|
|
@ -70,10 +70,12 @@ def show_subscribe_form(conn, %{"nickname" => nick}) do
|
||||||
|
|
||||||
def show_subscribe_form(conn, %{"status_id" => id}) do
|
def show_subscribe_form(conn, %{"status_id" => id}) do
|
||||||
with %Activity{} = activity <- Activity.get_by_id(id),
|
with %Activity{} = activity <- Activity.get_by_id(id),
|
||||||
|
{:ok, ap_id} <- get_ap_id(activity),
|
||||||
%User{} = user <- User.get_cached_by_ap_id(activity.actor),
|
%User{} = user <- User.get_cached_by_ap_id(activity.actor),
|
||||||
avatar = User.avatar_url(user) do
|
avatar = User.avatar_url(user) do
|
||||||
conn
|
conn
|
||||||
|> render("status_interact.html", %{
|
|> render("status_interact.html", %{
|
||||||
|
status_link: ap_id,
|
||||||
status_id: id,
|
status_id: id,
|
||||||
nickname: user.nickname,
|
nickname: user.nickname,
|
||||||
avatar: avatar,
|
avatar: avatar,
|
||||||
|
@ -113,18 +115,9 @@ def remote_subscribe(conn, %{"user" => %{"nickname" => nick, "profile" => profil
|
||||||
end
|
end
|
||||||
|
|
||||||
def remote_subscribe(conn, %{"status" => %{"status_id" => id, "profile" => profile}}) do
|
def remote_subscribe(conn, %{"status" => %{"status_id" => id, "profile" => profile}}) do
|
||||||
get_ap_id = fn activity ->
|
|
||||||
object = Pleroma.Object.normalize(activity, fetch: false)
|
|
||||||
|
|
||||||
case object do
|
|
||||||
%{data: %{"id" => ap_id}} -> {:ok, ap_id}
|
|
||||||
_ -> {:no_ap_id, nil}
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
with {:ok, %{"subscribe_address" => template}} <- WebFinger.finger(profile),
|
with {:ok, %{"subscribe_address" => template}} <- WebFinger.finger(profile),
|
||||||
%Activity{} = activity <- Activity.get_by_id(id),
|
%Activity{} = activity <- Activity.get_by_id(id),
|
||||||
{:ok, ap_id} <- get_ap_id.(activity) do
|
{:ok, ap_id} <- get_ap_id(activity) do
|
||||||
conn
|
conn
|
||||||
|> Phoenix.Controller.redirect(external: String.replace(template, "{uri}", ap_id))
|
|> Phoenix.Controller.redirect(external: String.replace(template, "{uri}", ap_id))
|
||||||
else
|
else
|
||||||
|
@ -146,6 +139,15 @@ def remote_interaction(%{body_params: %{ap_id: ap_id, profile: profile}} = conn,
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
defp get_ap_id(activity) do
|
||||||
|
object = Pleroma.Object.normalize(activity, fetch: false)
|
||||||
|
|
||||||
|
case object do
|
||||||
|
%{data: %{"id" => ap_id}} -> {:ok, ap_id}
|
||||||
|
_ -> {:no_ap_id, nil}
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def frontend_configurations(conn, _params) do
|
def frontend_configurations(conn, _params) do
|
||||||
render(conn, "frontend_configurations.json")
|
render(conn, "frontend_configurations.json")
|
||||||
end
|
end
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
defmodule Pleroma.Web.TwitterAPI.UtilView do
|
defmodule Pleroma.Web.TwitterAPI.UtilView do
|
||||||
use Pleroma.Web, :view
|
use Pleroma.Web, :view
|
||||||
import Phoenix.HTML.Form
|
import Phoenix.HTML.Form
|
||||||
|
import Phoenix.HTML.Link
|
||||||
alias Pleroma.Config
|
alias Pleroma.Config
|
||||||
alias Pleroma.Web.Endpoint
|
alias Pleroma.Web.Endpoint
|
||||||
alias Pleroma.Web.Gettext
|
alias Pleroma.Web.Gettext
|
||||||
|
|
Loading…
Reference in New Issue