aboutsummaryrefslogtreecommitdiff
path: root/lib/pleroma/web/twitter_api/twitter_api.ex
diff options
context:
space:
mode:
Diffstat (limited to 'lib/pleroma/web/twitter_api/twitter_api.ex')
-rw-r--r--lib/pleroma/web/twitter_api/twitter_api.ex49
1 files changed, 8 insertions, 41 deletions
diff --git a/lib/pleroma/web/twitter_api/twitter_api.ex b/lib/pleroma/web/twitter_api/twitter_api.ex
index dcb15b9a9..9978c7f64 100644
--- a/lib/pleroma/web/twitter_api/twitter_api.ex
+++ b/lib/pleroma/web/twitter_api/twitter_api.ex
@@ -3,16 +3,15 @@
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.Web.TwitterAPI.TwitterAPI do
- alias Pleroma.UserInviteToken
- alias Pleroma.User
alias Pleroma.Activity
+ alias Pleroma.Mailer
alias Pleroma.Repo
- alias Pleroma.Object
+ alias Pleroma.User
alias Pleroma.UserEmail
- alias Pleroma.Mailer
+ alias Pleroma.UserInviteToken
alias Pleroma.Web.ActivityPub.ActivityPub
- alias Pleroma.Web.TwitterAPI.UserView
alias Pleroma.Web.CommonAPI
+ alias Pleroma.Web.TwitterAPI.UserView
import Ecto.Query
@@ -35,11 +34,8 @@ defmodule Pleroma.Web.TwitterAPI.TwitterAPI do
def unfollow(%User{} = follower, params) do
with {:ok, %User{} = unfollowed} <- get_user(params),
- {:ok, follower, _follow_activity} <- User.unfollow(follower, unfollowed),
- {:ok, _activity} <- ActivityPub.unfollow(follower, unfollowed) do
+ {:ok, follower} <- CommonAPI.unfollow(follower, unfollowed) do
{:ok, follower, unfollowed}
- else
- err -> err
end
end
@@ -133,7 +129,7 @@ defmodule Pleroma.Web.TwitterAPI.TwitterAPI do
end
def register_user(params) do
- tokenString = params["token"]
+ token_string = params["token"]
params = %{
nickname: params["nickname"],
@@ -170,8 +166,8 @@ defmodule Pleroma.Web.TwitterAPI.TwitterAPI do
# no need to query DB if registration is open
token =
- unless registrations_open || is_nil(tokenString) do
- Repo.get_by(UserInviteToken, %{token: tokenString})
+ unless registrations_open || is_nil(token_string) do
+ Repo.get_by(UserInviteToken, %{token: token_string})
end
cond do
@@ -285,35 +281,6 @@ defmodule Pleroma.Web.TwitterAPI.TwitterAPI do
_activities = Repo.all(q)
end
- # DEPRECATED mostly, context objects are now created at insertion time.
- def context_to_conversation_id(context) do
- with %Object{id: id} <- Object.get_cached_by_ap_id(context) do
- id
- else
- _e ->
- changeset = Object.context_mapping(context)
-
- case Repo.insert(changeset) do
- {:ok, %{id: id}} ->
- id
-
- # This should be solved by an upsert, but it seems ecto
- # has problems accessing the constraint inside the jsonb.
- {:error, _} ->
- Object.get_cached_by_ap_id(context).id
- end
- end
- end
-
- def conversation_id_to_context(id) do
- with %Object{data: %{"id" => context}} <- Repo.get(Object, id) do
- context
- else
- _e ->
- {:error, "No such conversation"}
- end
- end
-
def get_external_profile(for_user, uri) do
with %User{} = user <- User.get_or_fetch(uri) do
{:ok, UserView.render("show.json", %{user: user, for: for_user})}