-defmodule Pleroma.Web.TwitterAPI.TwitterAPI do
- alias Pleroma.{UserInviteToken, User, Activity, Repo, Object}
- alias Pleroma.Web.ActivityPub.ActivityPub
- alias Pleroma.Web.TwitterAPI.UserView
- alias Pleroma.Web.{OStatus, CommonAPI}
- alias Pleroma.Web.MediaProxy
- import Ecto.Query
-
- @httpoison Application.get_env(:pleroma, :httpoison)
-
- def create_status(%User{} = user, %{"status" => _} = data) do
- CommonAPI.post(user, data)
- end
-
- def delete(%User{} = user, id) do
- with %Activity{data: %{"type" => type}} <- Repo.get(Activity, id),
- {:ok, activity} <- CommonAPI.delete(id, user) do
- {:ok, activity}
- end
- end
-
- 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