- def follow(%User{} = follower, params) do
- with {:ok, %User{} = followed} <- get_user(params),
- {:ok, follower} <- User.maybe_direct_follow(follower, followed),
- {:ok, activity} <- ActivityPub.follow(follower, followed),
- {:ok, follower, followed} <-
- User.wait_and_refresh(
- Pleroma.Config.get([:activitypub, :follow_handshake_timeout]),
- follower,
- followed
- ) do
- {:ok, follower, followed, activity}
- else
- err -> err
- end
- end
-
- 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, unfollowed}
- else
- err -> err
- end
- end
+defmodule Pleroma.Web.TwitterAPI.TwitterAPI do
+ import Pleroma.Web.Gettext
+
+ alias Pleroma.Emails.Mailer
+ alias Pleroma.Emails.UserEmail
+ alias Pleroma.Repo
+ alias Pleroma.User
+ alias Pleroma.UserInviteToken
+
+ def register_user(params, opts \\ []) do
+ fallback_language = Gettext.get_locale()
+
+ params =
+ params
+ |> Map.take([:email, :token, :password])
+ |> Map.put(:bio, params |> Map.get(:bio, "") |> User.parse_bio())
+ |> Map.put(:nickname, params[:username])
+ |> Map.put(:name, Map.get(params, :fullname, params[:username]))
+ |> Map.put(:password_confirmation, params[:password])
+ |> Map.put(:registration_reason, params[:reason])
+ |> Map.put(
+ :language,
+ Pleroma.Web.Gettext.normalize_locale(params[:language]) || fallback_language
+ )