diff options
author | lambda <pleromagit@rogerbraun.net> | 2018-05-13 09:32:29 +0000 |
---|---|---|
committer | lambda <pleromagit@rogerbraun.net> | 2018-05-13 09:32:29 +0000 |
commit | aeff2d647483d5348cc1da5c901ce55f1c02b733 (patch) | |
tree | 7b7db3e9a7e90771fc6f0283605ac390f2bddb45 /lib/pleroma/web/twitter_api/twitter_api.ex | |
parent | 7e9f14bf3ca95fda9042e10b44b80d8441fa3c42 (diff) | |
parent | 54ccbd8479a77f613e8efd9568b3611c28d21742 (diff) | |
download | pleroma-aeff2d647483d5348cc1da5c901ce55f1c02b733.tar.gz |
Merge branch 'feature/unrepeats' into 'develop'
Add unrepeats
Closes #69
See merge request pleroma/pleroma!113
Diffstat (limited to 'lib/pleroma/web/twitter_api/twitter_api.ex')
-rw-r--r-- | lib/pleroma/web/twitter_api/twitter_api.ex | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/lib/pleroma/web/twitter_api/twitter_api.ex b/lib/pleroma/web/twitter_api/twitter_api.ex index 44ea40a4e..8177a4988 100644 --- a/lib/pleroma/web/twitter_api/twitter_api.ex +++ b/lib/pleroma/web/twitter_api/twitter_api.ex @@ -11,6 +11,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, 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 + end + end + def follow(%User{} = follower, params) do with {:ok, %User{} = followed} <- get_user(params), {:ok, follower} <- User.follow(follower, followed), @@ -63,6 +75,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 |