post "/statuses/update", TwitterAPI.Controller, :status_update
post "/statuses/retweet/:id", TwitterAPI.Controller, :retweet
+ post "/statuses/destroy/:id", TwitterAPI.Controller, :delete_post
post "/friendships/create", TwitterAPI.Controller, :follow
post "/friendships/destroy", TwitterAPI.Controller, :unfollow
use Pleroma.Web, :controller
alias Pleroma.Web.TwitterAPI.{TwitterAPI, UserView}
alias Pleroma.Web.TwitterAPI.Representers.ActivityRepresenter
- alias Pleroma.{Repo, Activity, User}
+ alias Pleroma.{Repo, Activity, User, Object}
alias Pleroma.Web.ActivityPub.ActivityPub
alias Ecto.Changeset
end
end
+ def delete_post(%{assigns: %{user: user}} = conn, %{"id" => id}) do
+ with %Activity{data: %{"object" => %{"id" => object_id}}} <- Repo.get(Activity, id),
+ %Object{} = object <- Object.get_by_ap_id(object_id),
+ true <- user.ap_id == object.data["actor"],
+ {:ok, delete} <- ActivityPub.delete(object) |> IO.inspect do
+ json = ActivityRepresenter.to_json(delete, %{user: user, for: user})
+ conn
+ |> json_reply(200, json)
+ end
+ end
+
def unfollow(%{assigns: %{user: user}} = conn, params) do
case TwitterAPI.unfollow(user, params) do
{:ok, user, unfollowed} ->