Handle unrepeats via the TwitterAPI
This commit is contained in:
parent
687db1bc3a
commit
7b4f55238e
5 changed files with 25 additions and 11 deletions
|
|
@ -12,6 +12,18 @@ defmodule Pleroma.Web.TwitterAPI.TwitterAPI do
|
|||
CommonAPI.post(user, data)
|
||||
end
|
||||
|
||||
def delete(%User{} = user, id) do
|
||||
# TwitterAPI does not have an "unretweet" endpoint; instead this is done
|
||||
# via the "destroy" endpoint. Therefore, there is a need to handle
|
||||
# when the status to "delete" is actually an Announce (repeat) object.
|
||||
with %Activity{data: %{"type" => type}} <- Repo.get(Activity, id) do
|
||||
case type do
|
||||
"Announce" -> unrepeat(user, id)
|
||||
_ -> CommonAPI.delete(id, user)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def follow(%User{} = follower, params) do
|
||||
with {:ok, %User{} = followed} <- get_user(params),
|
||||
{:ok, follower} <- User.follow(follower, followed),
|
||||
|
|
@ -64,6 +76,12 @@ defmodule Pleroma.Web.TwitterAPI.TwitterAPI do
|
|||
end
|
||||
end
|
||||
|
||||
defp unrepeat(%User{} = user, ap_id_or_id) do
|
||||
with {:ok, _unannounce, activity, _object} <- CommonAPI.unrepeat(ap_id_or_id, user) do
|
||||
{:ok, activity}
|
||||
end
|
||||
end
|
||||
|
||||
def fav(%User{} = user, ap_id_or_id) do
|
||||
with {:ok, _announce, %{data: %{"id" => id}}} = CommonAPI.favorite(ap_id_or_id, user),
|
||||
%Activity{} = activity <- Activity.get_create_activity_by_object_ap_id(id) do
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue