diff options
author | lambda <pleromagit@rogerbraun.net> | 2018-06-14 07:19:36 +0000 |
---|---|---|
committer | lambda <pleromagit@rogerbraun.net> | 2018-06-14 07:19:36 +0000 |
commit | 8c7fdcb31b1255f91493b8f2e0f86dfbbfa2ac85 (patch) | |
tree | 6bafa899d5e5ac3696ae1d05c1746e134c5898b9 /lib/pleroma/web/twitter_api/twitter_api.ex | |
parent | 2c303b3302e28a85aec448a9d57f9c5b1e658bfb (diff) | |
parent | fc15f30a3c53860af35eb39c6893428df966fb96 (diff) | |
download | pleroma-8c7fdcb31b1255f91493b8f2e0f86dfbbfa2ac85.tar.gz |
Merge branch 'feature/twitterapi-unrepeat' into 'develop'
Add TwitterAPI unretweet endpoint and cleanup AP.unannounce
See merge request pleroma/pleroma!218
Diffstat (limited to 'lib/pleroma/web/twitter_api/twitter_api.ex')
-rw-r--r-- | lib/pleroma/web/twitter_api/twitter_api.ex | 16 |
1 files changed, 6 insertions, 10 deletions
diff --git a/lib/pleroma/web/twitter_api/twitter_api.ex b/lib/pleroma/web/twitter_api/twitter_api.ex index ccc6fe8e7..c23b3c2c4 100644 --- a/lib/pleroma/web/twitter_api/twitter_api.ex +++ b/lib/pleroma/web/twitter_api/twitter_api.ex @@ -12,14 +12,9 @@ defmodule Pleroma.Web.TwitterAPI.TwitterAPI do end def delete(%User{} = user, id) do - # TwitterAPI does not have an "unretweet" endpoint; instead this is done - # via the "destroy" endpoint. Therefore, we 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 + with %Activity{data: %{"type" => type}} <- Repo.get(Activity, id), + {:ok, activity} <- CommonAPI.delete(id, user) do + {:ok, activity} end end @@ -70,8 +65,9 @@ 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 + def unrepeat(%User{} = user, ap_id_or_id) do + with {:ok, _unannounce, %{data: %{"id" => id}}} <- CommonAPI.unrepeat(ap_id_or_id, user), + %Activity{} = activity <- Activity.get_create_activity_by_object_ap_id(id) do {:ok, activity} end end |