aboutsummaryrefslogtreecommitdiff
path: root/lib/pleroma/web/twitter_api
diff options
context:
space:
mode:
authordcc <dcc@logografos.com>2024-05-15 00:57:23 -0700
committerdcc <dcc@logografos.com>2024-05-15 00:57:23 -0700
commitb31a934a804aed3f35442ceafe2080b0955e7317 (patch)
tree947b13a0388ecea81e05dd980baa10f7546860b9 /lib/pleroma/web/twitter_api
parentea33a0d3427f8b30b82a6ddbc0ff7429cfaf8d91 (diff)
downloadanni-b31a934a804aed3f35442ceafe2080b0955e7317.tar.gz
anni-b31a934a804aed3f35442ceafe2080b0955e7317.tar.bz2
anni-b31a934a804aed3f35442ceafe2080b0955e7317.zip
total rebaseHEADmaster
Diffstat (limited to 'lib/pleroma/web/twitter_api')
-rw-r--r--[-rwxr-xr-x]lib/pleroma/web/twitter_api/controller.ex0
-rw-r--r--[-rwxr-xr-x]lib/pleroma/web/twitter_api/controllers/password_controller.ex2
-rw-r--r--[-rwxr-xr-x]lib/pleroma/web/twitter_api/controllers/remote_follow_controller.ex11
-rw-r--r--[-rwxr-xr-x]lib/pleroma/web/twitter_api/controllers/util_controller.ex59
-rw-r--r--[-rwxr-xr-x]lib/pleroma/web/twitter_api/twitter_api.ex0
-rw-r--r--[-rwxr-xr-x]lib/pleroma/web/twitter_api/views/password_view.ex0
-rw-r--r--[-rwxr-xr-x]lib/pleroma/web/twitter_api/views/remote_follow_view.ex0
-rw-r--r--[-rwxr-xr-x]lib/pleroma/web/twitter_api/views/token_view.ex0
-rw-r--r--[-rwxr-xr-x]lib/pleroma/web/twitter_api/views/util_view.ex0
9 files changed, 55 insertions, 17 deletions
diff --git a/lib/pleroma/web/twitter_api/controller.ex b/lib/pleroma/web/twitter_api/controller.ex
index 6db3d60..6db3d60 100755..100644
--- a/lib/pleroma/web/twitter_api/controller.ex
+++ b/lib/pleroma/web/twitter_api/controller.ex
diff --git a/lib/pleroma/web/twitter_api/controllers/password_controller.ex b/lib/pleroma/web/twitter_api/controllers/password_controller.ex
index 31b7dd7..e5482de 100755..100644
--- a/lib/pleroma/web/twitter_api/controllers/password_controller.ex
+++ b/lib/pleroma/web/twitter_api/controllers/password_controller.ex
@@ -4,7 +4,7 @@
defmodule Pleroma.Web.TwitterAPI.PasswordController do
@moduledoc """
- The module containts functions for reset password.
+ The module contains functions for password reset.
"""
use Pleroma.Web, :controller
diff --git a/lib/pleroma/web/twitter_api/controllers/remote_follow_controller.ex b/lib/pleroma/web/twitter_api/controllers/remote_follow_controller.ex
index 6229d5d..1557d95 100755..100644
--- a/lib/pleroma/web/twitter_api/controllers/remote_follow_controller.ex
+++ b/lib/pleroma/web/twitter_api/controllers/remote_follow_controller.ex
@@ -29,7 +29,7 @@ defmodule Pleroma.Web.TwitterAPI.RemoteFollowController do
# GET /ostatus_subscribe
#
def follow(%{assigns: %{user: user}} = conn, %{"acct" => acct}) do
- case is_status?(acct) do
+ case status?(acct) do
true -> follow_status(conn, user, acct)
_ -> follow_account(conn, user, acct)
end
@@ -57,7 +57,7 @@ defmodule Pleroma.Web.TwitterAPI.RemoteFollowController do
defp follow_template(%User{} = _user), do: "follow.html"
defp follow_template(_), do: "follow_login.html"
- defp is_status?(acct) do
+ defp status?(acct) do
case Fetcher.fetch_and_contain_remote_object_from_id(acct) do
{:ok, %{"type" => type}} when type in @status_types ->
true
@@ -121,6 +121,13 @@ defmodule Pleroma.Web.TwitterAPI.RemoteFollowController do
render(conn, "followed.html", %{error: "Insufficient permissions: follow | write:follows."})
end
+ # GET /authorize_interaction
+ #
+ def authorize_interaction(conn, %{"uri" => uri}) do
+ conn
+ |> redirect(to: Routes.remote_follow_path(conn, :follow, %{acct: uri}))
+ end
+
defp handle_follow_error(conn, {:mfa_token, followee, _} = _) do
render(conn, "follow_login.html", %{error: "Wrong username or password", followee: followee})
end
diff --git a/lib/pleroma/web/twitter_api/controllers/util_controller.ex b/lib/pleroma/web/twitter_api/controllers/util_controller.ex
index d5a24ae..040fa32 100755..100644
--- a/lib/pleroma/web/twitter_api/controllers/util_controller.ex
+++ b/lib/pleroma/web/twitter_api/controllers/util_controller.ex
@@ -18,7 +18,8 @@ defmodule Pleroma.Web.TwitterAPI.UtilController do
alias Pleroma.Web.WebFinger
plug(
- Pleroma.Web.ApiSpec.CastAndValidate
+ Pleroma.Web.ApiSpec.CastAndValidate,
+ [replace_params: false]
when action != :remote_subscribe and action != :show_subscribe_form
)
@@ -35,7 +36,7 @@ defmodule Pleroma.Web.TwitterAPI.UtilController do
:change_email,
:change_password,
:delete_account,
- :update_notificaton_settings,
+ :update_notification_settings,
:disable_account,
:move_account,
:add_alias,
@@ -150,7 +151,10 @@ defmodule Pleroma.Web.TwitterAPI.UtilController do
end
end
- def remote_interaction(%{body_params: %{ap_id: ap_id, profile: profile}} = conn, _params) do
+ def remote_interaction(
+ %{private: %{open_api_spex: %{body_params: %{ap_id: ap_id, profile: profile}}}} = conn,
+ _params
+ ) do
with {:ok, %{"subscribe_address" => template}} <- WebFinger.finger(profile) do
conn
|> json(%{url: String.replace(template, "{uri}", ap_id)})
@@ -181,13 +185,16 @@ defmodule Pleroma.Web.TwitterAPI.UtilController do
json(conn, emoji)
end
- def update_notificaton_settings(%{assigns: %{user: user}} = conn, params) do
+ def update_notification_settings(%{assigns: %{user: user}} = conn, params) do
with {:ok, _} <- User.update_notification_settings(user, params) do
json(conn, %{status: "success"})
end
end
- def change_password(%{assigns: %{user: user}, body_params: body_params} = conn, %{}) do
+ def change_password(
+ %{assigns: %{user: user}, private: %{open_api_spex: %{body_params: body_params}}} = conn,
+ _
+ ) do
case CommonAPI.Utils.confirm_current_password(user, body_params.password) do
{:ok, user} ->
with {:ok, _user} <-
@@ -210,7 +217,10 @@ defmodule Pleroma.Web.TwitterAPI.UtilController do
end
end
- def change_email(%{assigns: %{user: user}, body_params: body_params} = conn, %{}) do
+ def change_email(
+ %{assigns: %{user: user}, private: %{open_api_spex: %{body_params: body_params}}} = conn,
+ _
+ ) do
case CommonAPI.Utils.confirm_current_password(user, body_params.password) do
{:ok, user} ->
with {:ok, _user} <- User.change_email(user, body_params.email) do
@@ -229,7 +239,13 @@ defmodule Pleroma.Web.TwitterAPI.UtilController do
end
end
- def delete_account(%{assigns: %{user: user}, body_params: body_params} = conn, params) do
+ def delete_account(
+ %{
+ assigns: %{user: user},
+ private: %{open_api_spex: %{body_params: body_params, params: params}}
+ } = conn,
+ _
+ ) do
# This endpoint can accept a query param or JSON body for backwards-compatibility.
# Submitting a JSON body is recommended, so passwords don't end up in server logs.
password = body_params[:password] || params[:password] || ""
@@ -244,7 +260,10 @@ defmodule Pleroma.Web.TwitterAPI.UtilController do
end
end
- def disable_account(%{assigns: %{user: user}} = conn, params) do
+ def disable_account(
+ %{assigns: %{user: user}, private: %{open_api_spex: %{params: params}}} = conn,
+ _
+ ) do
case CommonAPI.Utils.confirm_current_password(user, params[:password]) do
{:ok, user} ->
User.set_activation_async(user, false)
@@ -255,7 +274,10 @@ defmodule Pleroma.Web.TwitterAPI.UtilController do
end
end
- def move_account(%{assigns: %{user: user}, body_params: body_params} = conn, %{}) do
+ def move_account(
+ %{assigns: %{user: user}, private: %{open_api_spex: %{body_params: body_params}}} = conn,
+ _
+ ) do
case CommonAPI.Utils.confirm_current_password(user, body_params.password) do
{:ok, user} ->
with {:ok, target_user} <- find_or_fetch_user_by_nickname(body_params.target_account),
@@ -276,7 +298,10 @@ defmodule Pleroma.Web.TwitterAPI.UtilController do
end
end
- def add_alias(%{assigns: %{user: user}, body_params: body_params} = conn, _) do
+ def add_alias(
+ %{assigns: %{user: user}, private: %{open_api_spex: %{body_params: body_params}}} = conn,
+ _
+ ) do
with {:ok, alias_user} <- find_user_by_nickname(body_params.alias),
{:ok, _user} <- user |> User.add_alias(alias_user) do
json(conn, %{status: "success"})
@@ -291,7 +316,10 @@ defmodule Pleroma.Web.TwitterAPI.UtilController do
end
end
- def delete_alias(%{assigns: %{user: user}, body_params: body_params} = conn, _) do
+ def delete_alias(
+ %{assigns: %{user: user}, private: %{open_api_spex: %{body_params: body_params}}} = conn,
+ _
+ ) do
with {:ok, alias_user} <- find_user_by_nickname(body_params.alias),
{:ok, _user} <- user |> User.delete_alias(alias_user) do
json(conn, %{status: "success"})
@@ -306,7 +334,7 @@ defmodule Pleroma.Web.TwitterAPI.UtilController do
end
end
- def list_aliases(%{assigns: %{user: user}} = conn, %{}) do
+ def list_aliases(%{assigns: %{user: user}} = conn, _) do
alias_nicks =
user
|> User.alias_users()
@@ -319,7 +347,7 @@ defmodule Pleroma.Web.TwitterAPI.UtilController do
user = User.get_cached_by_nickname(nickname)
if user == nil do
- {:not_found, nil}
+ {:error, :not_found}
else
{:ok, user}
end
@@ -345,13 +373,16 @@ defmodule Pleroma.Web.TwitterAPI.UtilController do
end
def healthcheck(conn, _params) do
- with true <- Config.get([:instance, :healthcheck]),
+ with {:cfg, true} <- {:cfg, Config.get([:instance, :healthcheck])},
%{healthy: true} = info <- Healthcheck.system_info() do
json(conn, info)
else
%{healthy: false} = info ->
service_unavailable(conn, info)
+ {:cfg, false} ->
+ service_unavailable(conn, %{"error" => "Healthcheck disabled"})
+
_ ->
service_unavailable(conn, %{})
end
diff --git a/lib/pleroma/web/twitter_api/twitter_api.ex b/lib/pleroma/web/twitter_api/twitter_api.ex
index ef2eb75..ef2eb75 100755..100644
--- a/lib/pleroma/web/twitter_api/twitter_api.ex
+++ b/lib/pleroma/web/twitter_api/twitter_api.ex
diff --git a/lib/pleroma/web/twitter_api/views/password_view.ex b/lib/pleroma/web/twitter_api/views/password_view.ex
index 5579094..5579094 100755..100644
--- a/lib/pleroma/web/twitter_api/views/password_view.ex
+++ b/lib/pleroma/web/twitter_api/views/password_view.ex
diff --git a/lib/pleroma/web/twitter_api/views/remote_follow_view.ex b/lib/pleroma/web/twitter_api/views/remote_follow_view.ex
index 8902261..8902261 100755..100644
--- a/lib/pleroma/web/twitter_api/views/remote_follow_view.ex
+++ b/lib/pleroma/web/twitter_api/views/remote_follow_view.ex
diff --git a/lib/pleroma/web/twitter_api/views/token_view.ex b/lib/pleroma/web/twitter_api/views/token_view.ex
index 2e492c1..2e492c1 100755..100644
--- a/lib/pleroma/web/twitter_api/views/token_view.ex
+++ b/lib/pleroma/web/twitter_api/views/token_view.ex
diff --git a/lib/pleroma/web/twitter_api/views/util_view.ex b/lib/pleroma/web/twitter_api/views/util_view.ex
index 31b7c0c..31b7c0c 100755..100644
--- a/lib/pleroma/web/twitter_api/views/util_view.ex
+++ b/lib/pleroma/web/twitter_api/views/util_view.ex