Add delete to TwAPI.
This commit is contained in:
parent
3438a120cc
commit
1f9a5272e1
@ -82,6 +82,7 @@ defmodule Pleroma.Web.Router do
|
|||||||
|
|
||||||
post "/statuses/update", TwitterAPI.Controller, :status_update
|
post "/statuses/update", TwitterAPI.Controller, :status_update
|
||||||
post "/statuses/retweet/:id", TwitterAPI.Controller, :retweet
|
post "/statuses/retweet/:id", TwitterAPI.Controller, :retweet
|
||||||
|
post "/statuses/destroy/:id", TwitterAPI.Controller, :delete_post
|
||||||
|
|
||||||
post "/friendships/create", TwitterAPI.Controller, :follow
|
post "/friendships/create", TwitterAPI.Controller, :follow
|
||||||
post "/friendships/destroy", TwitterAPI.Controller, :unfollow
|
post "/friendships/destroy", TwitterAPI.Controller, :unfollow
|
||||||
|
@ -2,7 +2,7 @@ defmodule Pleroma.Web.TwitterAPI.Controller do
|
|||||||
use Pleroma.Web, :controller
|
use Pleroma.Web, :controller
|
||||||
alias Pleroma.Web.TwitterAPI.{TwitterAPI, UserView}
|
alias Pleroma.Web.TwitterAPI.{TwitterAPI, UserView}
|
||||||
alias Pleroma.Web.TwitterAPI.Representers.ActivityRepresenter
|
alias Pleroma.Web.TwitterAPI.Representers.ActivityRepresenter
|
||||||
alias Pleroma.{Repo, Activity, User}
|
alias Pleroma.{Repo, Activity, User, Object}
|
||||||
alias Pleroma.Web.ActivityPub.ActivityPub
|
alias Pleroma.Web.ActivityPub.ActivityPub
|
||||||
alias Ecto.Changeset
|
alias Ecto.Changeset
|
||||||
|
|
||||||
@ -94,6 +94,17 @@ defmodule Pleroma.Web.TwitterAPI.Controller do
|
|||||||
end
|
end
|
||||||
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
|
def unfollow(%{assigns: %{user: user}} = conn, params) do
|
||||||
case TwitterAPI.unfollow(user, params) do
|
case TwitterAPI.unfollow(user, params) do
|
||||||
{:ok, user, unfollowed} ->
|
{:ok, user, unfollowed} ->
|
||||||
|
Loading…
Reference in New Issue
Block a user