Add favoriting to TwAPI controller.
This commit is contained in:
parent
d0da40dc81
commit
5cb446a148
4 changed files with 39 additions and 0 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue