diff options
author | Roger Braun <roger@rogerbraun.net> | 2017-04-13 17:22:44 +0200 |
---|---|---|
committer | Roger Braun <roger@rogerbraun.net> | 2017-04-13 17:22:44 +0200 |
commit | 5cb446a148ab7f935b4fc90e4d353d10e18f9f7d (patch) | |
tree | 30322dd6c66c0ff7ed19a450b77505ad7a6a7197 /lib | |
parent | d0da40dc81f5db2b3d335fb47d00d0ac52c2cba3 (diff) | |
download | pleroma-5cb446a148ab7f935b4fc90e4d353d10e18f9f7d.tar.gz |
Add favoriting to TwAPI controller.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/pleroma/web/router.ex | 1 | ||||
-rw-r--r-- | lib/pleroma/web/twitter_api/twitter_api_controller.ex | 10 |
2 files changed, 11 insertions, 0 deletions
diff --git a/lib/pleroma/web/router.ex b/lib/pleroma/web/router.ex index 40350ad0c..a61e32b40 100644 --- a/lib/pleroma/web/router.ex +++ b/lib/pleroma/web/router.ex @@ -39,5 +39,6 @@ defmodule Pleroma.Web.Router do post "/friendships/create", TwitterAPI.Controller, :follow post "/friendships/destroy", TwitterAPI.Controller, :unfollow post "/statusnet/media/upload", TwitterAPI.Controller, :upload + post "/favorites/create/:id", TwitterAPI.Controller, :favorite end end diff --git a/lib/pleroma/web/twitter_api/twitter_api_controller.ex b/lib/pleroma/web/twitter_api/twitter_api_controller.ex index 3f299a941..3969e92a6 100644 --- a/lib/pleroma/web/twitter_api/twitter_api_controller.ex +++ b/lib/pleroma/web/twitter_api/twitter_api_controller.ex @@ -2,6 +2,7 @@ defmodule Pleroma.Web.TwitterAPI.Controller do use Pleroma.Web, :controller alias Pleroma.Web.TwitterAPI.TwitterAPI alias Pleroma.Web.TwitterAPI.Representers.{UserRepresenter, ActivityRepresenter} + alias Pleroma.{Repo, Activity} def verify_credentials(%{assigns: %{user: user}} = conn, _params) do response = user |> UserRepresenter.to_json(%{for: user}) @@ -97,6 +98,15 @@ defmodule Pleroma.Web.TwitterAPI.Controller do |> json_reply(200, response) end + def favorite(%{assigns: %{user: user}} = conn, %{"id" => id}) do + activity = Repo.get(Activity, id) + {:ok, status} = TwitterAPI.favorite(user, activity) + response = Poison.encode!(status) + + conn + |> json_reply(200, response) + end + defp json_reply(conn, status, json) do conn |> put_resp_content_type("application/json") |