Add unfollowing to TwAPI.
[akkoma] / lib / pleroma / web / router.ex
1 defmodule Pleroma.Web.Router do
2 use Pleroma.Web, :router
3
4 alias Pleroma.{Repo, User}
5
6 def user_fetcher(username) do
7 {:ok, Repo.get_by(User, %{nickname: username})}
8 end
9
10 pipeline :api do
11 plug :accepts, ["json"]
12 plug :fetch_session
13 plug Pleroma.Plugs.AuthenticationPlug, %{fetcher: &Pleroma.Web.Router.user_fetcher/1, optional: true}
14 end
15
16 pipeline :authenticated_api do
17 plug :accepts, ["json"]
18 plug :fetch_session
19 plug Pleroma.Plugs.AuthenticationPlug, %{fetcher: &Pleroma.Web.Router.user_fetcher/1}
20 end
21
22 scope "/api", Pleroma.Web do
23 pipe_through :api
24 get "/statuses/public_timeline.json", TwitterAPI.Controller, :public_timeline
25 get "/statuses/public_and_external_timeline.json", TwitterAPI.Controller, :public_timeline
26 end
27
28 scope "/api", Pleroma.Web do
29 pipe_through :authenticated_api
30
31 post "/account/verify_credentials.json", TwitterAPI.Controller, :verify_credentials
32 post "/statuses/update.json", TwitterAPI.Controller, :status_update
33 get "/statuses/friends_timeline.json", TwitterAPI.Controller, :friends_timeline
34 post "/friendships/create.json", TwitterAPI.Controller, :follow
35 post "/friendships/destroy.json", TwitterAPI.Controller, :unfollow
36 end
37 end