forked from AkkomaGang/akkoma
Upgrade to Phoenix 1.4
This commit is contained in:
parent
8fadc1b6a2
commit
f672555ad3
7 changed files with 102 additions and 58 deletions
|
@ -6,10 +6,6 @@ defmodule Pleroma.Web.UserSocket do
|
||||||
# channel "room:*", Pleroma.Web.RoomChannel
|
# channel "room:*", Pleroma.Web.RoomChannel
|
||||||
channel("chat:*", Pleroma.Web.ChatChannel)
|
channel("chat:*", Pleroma.Web.ChatChannel)
|
||||||
|
|
||||||
## Transports
|
|
||||||
transport(:websocket, Phoenix.Transports.WebSocket)
|
|
||||||
# transport :longpoll, Phoenix.Transports.LongPoll
|
|
||||||
|
|
||||||
# Socket params are passed from the client and can
|
# Socket params are passed from the client and can
|
||||||
# be used to verify and authenticate a user. After
|
# be used to verify and authenticate a user. After
|
||||||
# verification, you can put default assigns into
|
# verification, you can put default assigns into
|
||||||
|
|
|
@ -3,7 +3,7 @@ defmodule Pleroma.Web.Endpoint do
|
||||||
|
|
||||||
socket("/socket", Pleroma.Web.UserSocket)
|
socket("/socket", Pleroma.Web.UserSocket)
|
||||||
|
|
||||||
socket("/api/v1", Pleroma.Web.MastodonAPI.MastodonSocket)
|
socket("/api/v1", Pleroma.Web.MastodonAPI.MastodonSocket, websocket: [path: "/streaming"])
|
||||||
|
|
||||||
# Serve at "/" the static files from "priv/static" directory.
|
# Serve at "/" the static files from "priv/static" directory.
|
||||||
#
|
#
|
||||||
|
|
|
@ -4,13 +4,6 @@ defmodule Pleroma.Web.MastodonAPI.MastodonSocket do
|
||||||
alias Pleroma.Web.OAuth.Token
|
alias Pleroma.Web.OAuth.Token
|
||||||
alias Pleroma.{User, Repo}
|
alias Pleroma.{User, Repo}
|
||||||
|
|
||||||
transport(
|
|
||||||
:websocket,
|
|
||||||
Phoenix.Transports.WebSocket.Raw,
|
|
||||||
# We never receive data.
|
|
||||||
timeout: :infinity
|
|
||||||
)
|
|
||||||
|
|
||||||
@spec connect(params :: map(), Phoenix.Socket.t()) :: {:ok, Phoenix.Socket.t()} | :error
|
@spec connect(params :: map(), Phoenix.Socket.t()) :: {:ok, Phoenix.Socket.t()} | :error
|
||||||
def connect(%{"access_token" => token} = params, socket) do
|
def connect(%{"access_token" => token} = params, socket) do
|
||||||
with %Token{user_id: user_id} <- Repo.get_by(Token, token: token),
|
with %Token{user_id: user_id} <- Repo.get_by(Token, token: token),
|
||||||
|
|
|
@ -17,7 +17,10 @@ defmodule Pleroma.Web.TwitterAPI.Controller do
|
||||||
|
|
||||||
def verify_credentials(%{assigns: %{user: user}} = conn, _params) do
|
def verify_credentials(%{assigns: %{user: user}} = conn, _params) do
|
||||||
token = Phoenix.Token.sign(conn, "user socket", user.id)
|
token = Phoenix.Token.sign(conn, "user socket", user.id)
|
||||||
render(conn, UserView, "show.json", %{user: user, token: token})
|
|
||||||
|
conn
|
||||||
|
|> put_view(UserView)
|
||||||
|
|> render("show.json", %{user: user, token: token})
|
||||||
end
|
end
|
||||||
|
|
||||||
def status_update(%{assigns: %{user: user}} = conn, %{"status" => _} = status_data) do
|
def status_update(%{assigns: %{user: user}} = conn, %{"status" => _} = status_data) do
|
||||||
|
@ -58,7 +61,8 @@ def public_and_external_timeline(%{assigns: %{user: user}} = conn, params) do
|
||||||
activities = ActivityPub.fetch_public_activities(params)
|
activities = ActivityPub.fetch_public_activities(params)
|
||||||
|
|
||||||
conn
|
conn
|
||||||
|> render(ActivityView, "index.json", %{activities: activities, for: user})
|
|> put_view(ActivityView)
|
||||||
|
|> render("index.json", %{activities: activities, for: user})
|
||||||
end
|
end
|
||||||
|
|
||||||
def public_timeline(%{assigns: %{user: user}} = conn, params) do
|
def public_timeline(%{assigns: %{user: user}} = conn, params) do
|
||||||
|
@ -71,7 +75,8 @@ def public_timeline(%{assigns: %{user: user}} = conn, params) do
|
||||||
activities = ActivityPub.fetch_public_activities(params)
|
activities = ActivityPub.fetch_public_activities(params)
|
||||||
|
|
||||||
conn
|
conn
|
||||||
|> render(ActivityView, "index.json", %{activities: activities, for: user})
|
|> put_view(ActivityView)
|
||||||
|
|> render("index.json", %{activities: activities, for: user})
|
||||||
end
|
end
|
||||||
|
|
||||||
def friends_timeline(%{assigns: %{user: user}} = conn, params) do
|
def friends_timeline(%{assigns: %{user: user}} = conn, params) do
|
||||||
|
@ -86,16 +91,22 @@ def friends_timeline(%{assigns: %{user: user}} = conn, params) do
|
||||||
|> ActivityPub.contain_timeline(user)
|
|> ActivityPub.contain_timeline(user)
|
||||||
|
|
||||||
conn
|
conn
|
||||||
|> render(ActivityView, "index.json", %{activities: activities, for: user})
|
|> put_view(ActivityView)
|
||||||
|
|> render("index.json", %{activities: activities, for: user})
|
||||||
end
|
end
|
||||||
|
|
||||||
def show_user(conn, params) do
|
def show_user(conn, params) do
|
||||||
with {:ok, shown} <- TwitterAPI.get_user(params) do
|
with {:ok, shown} <- TwitterAPI.get_user(params) do
|
||||||
if user = conn.assigns.user do
|
params =
|
||||||
render(conn, UserView, "show.json", %{user: shown, for: user})
|
if user = conn.assigns.user do
|
||||||
else
|
%{user: shown, for: user}
|
||||||
render(conn, UserView, "show.json", %{user: shown})
|
else
|
||||||
end
|
%{user: shown}
|
||||||
|
end
|
||||||
|
|
||||||
|
conn
|
||||||
|
|> put_view(UserView)
|
||||||
|
|> render("show.json", params)
|
||||||
else
|
else
|
||||||
{:error, msg} ->
|
{:error, msg} ->
|
||||||
bad_request_reply(conn, msg)
|
bad_request_reply(conn, msg)
|
||||||
|
@ -108,7 +119,8 @@ def user_timeline(%{assigns: %{user: user}} = conn, params) do
|
||||||
activities = ActivityPub.fetch_user_activities(target_user, user, params)
|
activities = ActivityPub.fetch_user_activities(target_user, user, params)
|
||||||
|
|
||||||
conn
|
conn
|
||||||
|> render(ActivityView, "index.json", %{activities: activities, for: user})
|
|> put_view(ActivityView)
|
||||||
|
|> render("index.json", %{activities: activities, for: user})
|
||||||
|
|
||||||
{:error, msg} ->
|
{:error, msg} ->
|
||||||
bad_request_reply(conn, msg)
|
bad_request_reply(conn, msg)
|
||||||
|
@ -124,7 +136,8 @@ def mentions_timeline(%{assigns: %{user: user}} = conn, params) do
|
||||||
activities = ActivityPub.fetch_activities([user.ap_id], params)
|
activities = ActivityPub.fetch_activities([user.ap_id], params)
|
||||||
|
|
||||||
conn
|
conn
|
||||||
|> render(ActivityView, "index.json", %{activities: activities, for: user})
|
|> put_view(ActivityView)
|
||||||
|
|> render("index.json", %{activities: activities, for: user})
|
||||||
end
|
end
|
||||||
|
|
||||||
def dm_timeline(%{assigns: %{user: user}} = conn, params) do
|
def dm_timeline(%{assigns: %{user: user}} = conn, params) do
|
||||||
|
@ -137,14 +150,16 @@ def dm_timeline(%{assigns: %{user: user}} = conn, params) do
|
||||||
activities = Repo.all(query)
|
activities = Repo.all(query)
|
||||||
|
|
||||||
conn
|
conn
|
||||||
|> render(ActivityView, "index.json", %{activities: activities, for: user})
|
|> put_view(ActivityView)
|
||||||
|
|> render("index.json", %{activities: activities, for: user})
|
||||||
end
|
end
|
||||||
|
|
||||||
def notifications(%{assigns: %{user: user}} = conn, params) do
|
def notifications(%{assigns: %{user: user}} = conn, params) do
|
||||||
notifications = Notification.for_user(user, params)
|
notifications = Notification.for_user(user, params)
|
||||||
|
|
||||||
conn
|
conn
|
||||||
|> render(NotificationView, "notification.json", %{notifications: notifications, for: user})
|
|> put_view(NotificationView)
|
||||||
|
|> render("notification.json", %{notifications: notifications, for: user})
|
||||||
end
|
end
|
||||||
|
|
||||||
def notifications_read(%{assigns: %{user: user}} = conn, %{"latest_id" => latest_id} = params) do
|
def notifications_read(%{assigns: %{user: user}} = conn, %{"latest_id" => latest_id} = params) do
|
||||||
|
@ -153,7 +168,8 @@ def notifications_read(%{assigns: %{user: user}} = conn, %{"latest_id" => latest
|
||||||
notifications = Notification.for_user(user, params)
|
notifications = Notification.for_user(user, params)
|
||||||
|
|
||||||
conn
|
conn
|
||||||
|> render(NotificationView, "notification.json", %{notifications: notifications, for: user})
|
|> put_view(NotificationView)
|
||||||
|
|> render("notification.json", %{notifications: notifications, for: user})
|
||||||
end
|
end
|
||||||
|
|
||||||
def notifications_read(%{assigns: %{user: _user}} = conn, _) do
|
def notifications_read(%{assigns: %{user: _user}} = conn, _) do
|
||||||
|
@ -163,7 +179,9 @@ def notifications_read(%{assigns: %{user: _user}} = conn, _) do
|
||||||
def follow(%{assigns: %{user: user}} = conn, params) do
|
def follow(%{assigns: %{user: user}} = conn, params) do
|
||||||
case TwitterAPI.follow(user, params) do
|
case TwitterAPI.follow(user, params) do
|
||||||
{:ok, user, followed, _activity} ->
|
{:ok, user, followed, _activity} ->
|
||||||
render(conn, UserView, "show.json", %{user: followed, for: user})
|
conn
|
||||||
|
|> put_view(UserView)
|
||||||
|
|> render("show.json", %{user: followed, for: user})
|
||||||
|
|
||||||
{:error, msg} ->
|
{:error, msg} ->
|
||||||
forbidden_json_reply(conn, msg)
|
forbidden_json_reply(conn, msg)
|
||||||
|
@ -173,7 +191,9 @@ def follow(%{assigns: %{user: user}} = conn, params) do
|
||||||
def block(%{assigns: %{user: user}} = conn, params) do
|
def block(%{assigns: %{user: user}} = conn, params) do
|
||||||
case TwitterAPI.block(user, params) do
|
case TwitterAPI.block(user, params) do
|
||||||
{:ok, user, blocked} ->
|
{:ok, user, blocked} ->
|
||||||
render(conn, UserView, "show.json", %{user: blocked, for: user})
|
conn
|
||||||
|
|> put_view(UserView)
|
||||||
|
|> render("show.json", %{user: blocked, for: user})
|
||||||
|
|
||||||
{:error, msg} ->
|
{:error, msg} ->
|
||||||
forbidden_json_reply(conn, msg)
|
forbidden_json_reply(conn, msg)
|
||||||
|
@ -183,7 +203,9 @@ def block(%{assigns: %{user: user}} = conn, params) do
|
||||||
def unblock(%{assigns: %{user: user}} = conn, params) do
|
def unblock(%{assigns: %{user: user}} = conn, params) do
|
||||||
case TwitterAPI.unblock(user, params) do
|
case TwitterAPI.unblock(user, params) do
|
||||||
{:ok, user, blocked} ->
|
{:ok, user, blocked} ->
|
||||||
render(conn, UserView, "show.json", %{user: blocked, for: user})
|
conn
|
||||||
|
|> put_view(UserView)
|
||||||
|
|> render("show.json", %{user: blocked, for: user})
|
||||||
|
|
||||||
{:error, msg} ->
|
{:error, msg} ->
|
||||||
forbidden_json_reply(conn, msg)
|
forbidden_json_reply(conn, msg)
|
||||||
|
@ -192,14 +214,18 @@ def unblock(%{assigns: %{user: user}} = conn, params) do
|
||||||
|
|
||||||
def delete_post(%{assigns: %{user: user}} = conn, %{"id" => id}) do
|
def delete_post(%{assigns: %{user: user}} = conn, %{"id" => id}) do
|
||||||
with {:ok, activity} <- TwitterAPI.delete(user, id) do
|
with {:ok, activity} <- TwitterAPI.delete(user, id) do
|
||||||
render(conn, ActivityView, "activity.json", %{activity: activity, for: user})
|
conn
|
||||||
|
|> put_view(ActivityView)
|
||||||
|
|> render("activity.json", %{activity: activity, for: user})
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def unfollow(%{assigns: %{user: user}} = conn, params) do
|
def unfollow(%{assigns: %{user: user}} = conn, params) do
|
||||||
case TwitterAPI.unfollow(user, params) do
|
case TwitterAPI.unfollow(user, params) do
|
||||||
{:ok, user, unfollowed} ->
|
{:ok, user, unfollowed} ->
|
||||||
render(conn, UserView, "show.json", %{user: unfollowed, for: user})
|
conn
|
||||||
|
|> put_view(UserView)
|
||||||
|
|> render("show.json", %{user: unfollowed, for: user})
|
||||||
|
|
||||||
{:error, msg} ->
|
{:error, msg} ->
|
||||||
forbidden_json_reply(conn, msg)
|
forbidden_json_reply(conn, msg)
|
||||||
|
@ -209,7 +235,9 @@ def unfollow(%{assigns: %{user: user}} = conn, params) do
|
||||||
def fetch_status(%{assigns: %{user: user}} = conn, %{"id" => id}) do
|
def fetch_status(%{assigns: %{user: user}} = conn, %{"id" => id}) do
|
||||||
with %Activity{} = activity <- Repo.get(Activity, id),
|
with %Activity{} = activity <- Repo.get(Activity, id),
|
||||||
true <- ActivityPub.visible_for_user?(activity, user) do
|
true <- ActivityPub.visible_for_user?(activity, user) do
|
||||||
render(conn, ActivityView, "activity.json", %{activity: activity, for: user})
|
conn
|
||||||
|
|> put_view(ActivityView)
|
||||||
|
|> render("activity.json", %{activity: activity, for: user})
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -223,7 +251,8 @@ def fetch_conversation(%{assigns: %{user: user}} = conn, %{"id" => id}) do
|
||||||
"user" => user
|
"user" => user
|
||||||
}) do
|
}) do
|
||||||
conn
|
conn
|
||||||
|> render(ActivityView, "index.json", %{activities: activities, for: user})
|
|> put_view(ActivityView)
|
||||||
|
|> render("index.json", %{activities: activities, for: user})
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -290,34 +319,44 @@ def get_by_id_or_ap_id(id) do
|
||||||
def favorite(%{assigns: %{user: user}} = conn, %{"id" => id}) do
|
def favorite(%{assigns: %{user: user}} = conn, %{"id" => id}) do
|
||||||
with {_, {:ok, id}} <- {:param_cast, Ecto.Type.cast(:integer, id)},
|
with {_, {:ok, id}} <- {:param_cast, Ecto.Type.cast(:integer, id)},
|
||||||
{:ok, activity} <- TwitterAPI.fav(user, id) do
|
{:ok, activity} <- TwitterAPI.fav(user, id) do
|
||||||
render(conn, ActivityView, "activity.json", %{activity: activity, for: user})
|
conn
|
||||||
|
|> put_view(ActivityView)
|
||||||
|
|> render("activity.json", %{activity: activity, for: user})
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def unfavorite(%{assigns: %{user: user}} = conn, %{"id" => id}) do
|
def unfavorite(%{assigns: %{user: user}} = conn, %{"id" => id}) do
|
||||||
with {_, {:ok, id}} <- {:param_cast, Ecto.Type.cast(:integer, id)},
|
with {_, {:ok, id}} <- {:param_cast, Ecto.Type.cast(:integer, id)},
|
||||||
{:ok, activity} <- TwitterAPI.unfav(user, id) do
|
{:ok, activity} <- TwitterAPI.unfav(user, id) do
|
||||||
render(conn, ActivityView, "activity.json", %{activity: activity, for: user})
|
conn
|
||||||
|
|> put_view(ActivityView)
|
||||||
|
|> render("activity.json", %{activity: activity, for: user})
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def retweet(%{assigns: %{user: user}} = conn, %{"id" => id}) do
|
def retweet(%{assigns: %{user: user}} = conn, %{"id" => id}) do
|
||||||
with {_, {:ok, id}} <- {:param_cast, Ecto.Type.cast(:integer, id)},
|
with {_, {:ok, id}} <- {:param_cast, Ecto.Type.cast(:integer, id)},
|
||||||
{:ok, activity} <- TwitterAPI.repeat(user, id) do
|
{:ok, activity} <- TwitterAPI.repeat(user, id) do
|
||||||
render(conn, ActivityView, "activity.json", %{activity: activity, for: user})
|
conn
|
||||||
|
|> put_view(ActivityView)
|
||||||
|
|> render("activity.json", %{activity: activity, for: user})
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def unretweet(%{assigns: %{user: user}} = conn, %{"id" => id}) do
|
def unretweet(%{assigns: %{user: user}} = conn, %{"id" => id}) do
|
||||||
with {_, {:ok, id}} <- {:param_cast, Ecto.Type.cast(:integer, id)},
|
with {_, {:ok, id}} <- {:param_cast, Ecto.Type.cast(:integer, id)},
|
||||||
{:ok, activity} <- TwitterAPI.unrepeat(user, id) do
|
{:ok, activity} <- TwitterAPI.unrepeat(user, id) do
|
||||||
render(conn, ActivityView, "activity.json", %{activity: activity, for: user})
|
conn
|
||||||
|
|> put_view(ActivityView)
|
||||||
|
|> render("activity.json", %{activity: activity, for: user})
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def register(conn, params) do
|
def register(conn, params) do
|
||||||
with {:ok, user} <- TwitterAPI.register_user(params) do
|
with {:ok, user} <- TwitterAPI.register_user(params) do
|
||||||
render(conn, UserView, "show.json", %{user: user})
|
conn
|
||||||
|
|> put_view(UserView)
|
||||||
|
|> render("show.json", %{user: user})
|
||||||
else
|
else
|
||||||
{:error, errors} ->
|
{:error, errors} ->
|
||||||
conn
|
conn
|
||||||
|
@ -339,7 +378,9 @@ def update_avatar(%{assigns: %{user: user}} = conn, params) do
|
||||||
{:ok, user} = User.update_and_set_cache(change)
|
{:ok, user} = User.update_and_set_cache(change)
|
||||||
CommonAPI.update(user)
|
CommonAPI.update(user)
|
||||||
|
|
||||||
render(conn, UserView, "show.json", %{user: user, for: user})
|
conn
|
||||||
|
|> put_view(UserView)
|
||||||
|
|> render("show.json", %{user: user, for: user})
|
||||||
end
|
end
|
||||||
|
|
||||||
def update_banner(%{assigns: %{user: user}} = conn, params) do
|
def update_banner(%{assigns: %{user: user}} = conn, params) do
|
||||||
|
@ -394,7 +435,9 @@ def followers(%{assigns: %{user: for_user}} = conn, params) do
|
||||||
true -> followers
|
true -> followers
|
||||||
end
|
end
|
||||||
|
|
||||||
render(conn, UserView, "index.json", %{users: followers, for: conn.assigns[:user]})
|
conn
|
||||||
|
|> put_view(UserView)
|
||||||
|
|> render("index.json", %{users: followers, for: conn.assigns[:user]})
|
||||||
else
|
else
|
||||||
_e -> bad_request_reply(conn, "Can't get followers")
|
_e -> bad_request_reply(conn, "Can't get followers")
|
||||||
end
|
end
|
||||||
|
@ -410,7 +453,9 @@ def friends(%{assigns: %{user: for_user}} = conn, params) do
|
||||||
true -> friends
|
true -> friends
|
||||||
end
|
end
|
||||||
|
|
||||||
render(conn, UserView, "index.json", %{users: friends, for: conn.assigns[:user]})
|
conn
|
||||||
|
|> put_view(UserView)
|
||||||
|
|> render("index.json", %{users: friends, for: conn.assigns[:user]})
|
||||||
else
|
else
|
||||||
_e -> bad_request_reply(conn, "Can't get friends")
|
_e -> bad_request_reply(conn, "Can't get friends")
|
||||||
end
|
end
|
||||||
|
@ -419,7 +464,9 @@ def friends(%{assigns: %{user: for_user}} = conn, params) do
|
||||||
def friend_requests(conn, params) do
|
def friend_requests(conn, params) do
|
||||||
with {:ok, user} <- TwitterAPI.get_user(conn.assigns[:user], params),
|
with {:ok, user} <- TwitterAPI.get_user(conn.assigns[:user], params),
|
||||||
{:ok, friend_requests} <- User.get_follow_requests(user) do
|
{:ok, friend_requests} <- User.get_follow_requests(user) do
|
||||||
render(conn, UserView, "index.json", %{users: friend_requests, for: conn.assigns[:user]})
|
conn
|
||||||
|
|> put_view(UserView)
|
||||||
|
|> render("index.json", %{users: friend_requests, for: conn.assigns[:user]})
|
||||||
else
|
else
|
||||||
_e -> bad_request_reply(conn, "Can't get friend requests")
|
_e -> bad_request_reply(conn, "Can't get friend requests")
|
||||||
end
|
end
|
||||||
|
@ -439,7 +486,9 @@ def approve_friend_request(conn, %{"user_id" => uid} = _params) do
|
||||||
object: follow_activity.data["id"],
|
object: follow_activity.data["id"],
|
||||||
type: "Accept"
|
type: "Accept"
|
||||||
}) do
|
}) do
|
||||||
render(conn, UserView, "show.json", %{user: follower, for: followed})
|
conn
|
||||||
|
|> put_view(UserView)
|
||||||
|
|> render("show.json", %{user: follower, for: followed})
|
||||||
else
|
else
|
||||||
e -> bad_request_reply(conn, "Can't approve user: #{inspect(e)}")
|
e -> bad_request_reply(conn, "Can't approve user: #{inspect(e)}")
|
||||||
end
|
end
|
||||||
|
@ -458,7 +507,9 @@ def deny_friend_request(conn, %{"user_id" => uid} = _params) do
|
||||||
object: follow_activity.data["id"],
|
object: follow_activity.data["id"],
|
||||||
type: "Reject"
|
type: "Reject"
|
||||||
}) do
|
}) do
|
||||||
render(conn, UserView, "show.json", %{user: follower, for: followed})
|
conn
|
||||||
|
|> put_view(UserView)
|
||||||
|
|> render("show.json", %{user: follower, for: followed})
|
||||||
else
|
else
|
||||||
e -> bad_request_reply(conn, "Can't deny user: #{inspect(e)}")
|
e -> bad_request_reply(conn, "Can't deny user: #{inspect(e)}")
|
||||||
end
|
end
|
||||||
|
@ -522,7 +573,10 @@ def update_profile(%{assigns: %{user: user}} = conn, params) do
|
||||||
changeset <- Ecto.Changeset.put_embed(changeset, :info, info_cng),
|
changeset <- Ecto.Changeset.put_embed(changeset, :info, info_cng),
|
||||||
{:ok, user} <- User.update_and_set_cache(changeset) do
|
{:ok, user} <- User.update_and_set_cache(changeset) do
|
||||||
CommonAPI.update(user)
|
CommonAPI.update(user)
|
||||||
render(conn, UserView, "user.json", %{user: user, for: user})
|
|
||||||
|
conn
|
||||||
|
|> put_view(UserView)
|
||||||
|
|> render("user.json", %{user: user, for: user})
|
||||||
else
|
else
|
||||||
error ->
|
error ->
|
||||||
Logger.debug("Can't update user: #{inspect(error)}")
|
Logger.debug("Can't update user: #{inspect(error)}")
|
||||||
|
@ -534,14 +588,16 @@ def search(%{assigns: %{user: user}} = conn, %{"q" => _query} = params) do
|
||||||
activities = TwitterAPI.search(user, params)
|
activities = TwitterAPI.search(user, params)
|
||||||
|
|
||||||
conn
|
conn
|
||||||
|> render(ActivityView, "index.json", %{activities: activities, for: user})
|
|> put_view(ActivityView)
|
||||||
|
|> render("index.json", %{activities: activities, for: user})
|
||||||
end
|
end
|
||||||
|
|
||||||
def search_user(%{assigns: %{user: user}} = conn, %{"query" => query}) do
|
def search_user(%{assigns: %{user: user}} = conn, %{"query" => query}) do
|
||||||
users = User.search(query, true)
|
users = User.search(query, true)
|
||||||
|
|
||||||
conn
|
conn
|
||||||
|> render(UserView, "index.json", %{users: users, for: user})
|
|> put_view(UserView)
|
||||||
|
|> render("index.json", %{users: users, for: user})
|
||||||
end
|
end
|
||||||
|
|
||||||
defp bad_request_reply(conn, error_message) do
|
defp bad_request_reply(conn, error_message) do
|
||||||
|
|
7
mix.exs
7
mix.exs
|
@ -43,12 +43,13 @@ defp elixirc_paths(_), do: ["lib"]
|
||||||
# Type `mix help deps` for examples and options.
|
# Type `mix help deps` for examples and options.
|
||||||
defp deps do
|
defp deps do
|
||||||
[
|
[
|
||||||
{:phoenix, "~> 1.3.3"},
|
# Until Phoenix 1.4.1 is released
|
||||||
{:phoenix_pubsub, "~> 1.0.2"},
|
{:phoenix, github: "feld/phoenix", branch: "v1.4"},
|
||||||
|
{:plug_cowboy, "~> 1.0"},
|
||||||
|
{:phoenix_pubsub, "~> 1.1"},
|
||||||
{:phoenix_ecto, "~> 3.3"},
|
{:phoenix_ecto, "~> 3.3"},
|
||||||
{:postgrex, ">= 0.13.5"},
|
{:postgrex, ">= 0.13.5"},
|
||||||
{:gettext, "~> 0.15"},
|
{:gettext, "~> 0.15"},
|
||||||
{:cowboy, "~> 1.1.2", override: true},
|
|
||||||
{:comeonin, "~> 4.1.1"},
|
{:comeonin, "~> 4.1.1"},
|
||||||
{:pbkdf2_elixir, "~> 0.12.3"},
|
{:pbkdf2_elixir, "~> 0.12.3"},
|
||||||
{:trailing_format_plug, "~> 0.0.7"},
|
{:trailing_format_plug, "~> 0.0.7"},
|
||||||
|
|
10
mix.lock
10
mix.lock
|
@ -32,7 +32,7 @@
|
||||||
"makeup_elixir": {:hex, :makeup_elixir, "0.10.0", "0f09c2ddf352887a956d84f8f7e702111122ca32fbbc84c2f0569b8b65cbf7fa", [:mix], [{:makeup, "~> 0.5.5", [hex: :makeup, repo: "hexpm", optional: false]}], "hexpm"},
|
"makeup_elixir": {:hex, :makeup_elixir, "0.10.0", "0f09c2ddf352887a956d84f8f7e702111122ca32fbbc84c2f0569b8b65cbf7fa", [:mix], [{:makeup, "~> 0.5.5", [hex: :makeup, repo: "hexpm", optional: false]}], "hexpm"},
|
||||||
"meck": {:hex, :meck, "0.8.9", "64c5c0bd8bcca3a180b44196265c8ed7594e16bcc845d0698ec6b4e577f48188", [:rebar3], [], "hexpm"},
|
"meck": {:hex, :meck, "0.8.9", "64c5c0bd8bcca3a180b44196265c8ed7594e16bcc845d0698ec6b4e577f48188", [:rebar3], [], "hexpm"},
|
||||||
"metrics": {:hex, :metrics, "1.0.1", "25f094dea2cda98213cecc3aeff09e940299d950904393b2a29d191c346a8486", [:rebar3], [], "hexpm"},
|
"metrics": {:hex, :metrics, "1.0.1", "25f094dea2cda98213cecc3aeff09e940299d950904393b2a29d191c346a8486", [:rebar3], [], "hexpm"},
|
||||||
"mime": {:hex, :mime, "1.3.0", "5e8d45a39e95c650900d03f897fbf99ae04f60ab1daa4a34c7a20a5151b7a5fe", [:mix], [], "hexpm"},
|
"mime": {:hex, :mime, "1.3.1", "30ce04ab3175b6ad0bdce0035cba77bba68b813d523d1aac73d9781b4d193cf8", [:mix], [], "hexpm"},
|
||||||
"mimerl": {:hex, :mimerl, "1.0.2", "993f9b0e084083405ed8252b99460c4f0563e41729ab42d9074fd5e52439be88", [:rebar3], [], "hexpm"},
|
"mimerl": {:hex, :mimerl, "1.0.2", "993f9b0e084083405ed8252b99460c4f0563e41729ab42d9074fd5e52439be88", [:rebar3], [], "hexpm"},
|
||||||
"mochiweb": {:hex, :mochiweb, "2.15.0", "e1daac474df07651e5d17cc1e642c4069c7850dc4508d3db7263a0651330aacc", [:rebar3], [], "hexpm"},
|
"mochiweb": {:hex, :mochiweb, "2.15.0", "e1daac474df07651e5d17cc1e642c4069c7850dc4508d3db7263a0651330aacc", [:rebar3], [], "hexpm"},
|
||||||
"mock": {:hex, :mock, "0.3.1", "994f00150f79a0ea50dc9d86134cd9ebd0d177ad60bd04d1e46336cdfdb98ff9", [:mix], [{:meck, "~> 0.8.8", [hex: :meck, repo: "hexpm", optional: false]}], "hexpm"},
|
"mock": {:hex, :mock, "0.3.1", "994f00150f79a0ea50dc9d86134cd9ebd0d177ad60bd04d1e46336cdfdb98ff9", [:mix], [{:meck, "~> 0.8.8", [hex: :meck, repo: "hexpm", optional: false]}], "hexpm"},
|
||||||
|
@ -40,11 +40,13 @@
|
||||||
"nimble_parsec": {:hex, :nimble_parsec, "0.4.0", "ee261bb53214943679422be70f1658fff573c5d0b0a1ecd0f18738944f818efe", [:mix], [], "hexpm"},
|
"nimble_parsec": {:hex, :nimble_parsec, "0.4.0", "ee261bb53214943679422be70f1658fff573c5d0b0a1ecd0f18738944f818efe", [:mix], [], "hexpm"},
|
||||||
"parse_trans": {:hex, :parse_trans, "3.2.0", "2adfa4daf80c14dc36f522cf190eb5c4ee3e28008fc6394397c16f62a26258c2", [:rebar3], [], "hexpm"},
|
"parse_trans": {:hex, :parse_trans, "3.2.0", "2adfa4daf80c14dc36f522cf190eb5c4ee3e28008fc6394397c16f62a26258c2", [:rebar3], [], "hexpm"},
|
||||||
"pbkdf2_elixir": {:hex, :pbkdf2_elixir, "0.12.3", "6706a148809a29c306062862c803406e88f048277f6e85b68faf73291e820b84", [:mix], [], "hexpm"},
|
"pbkdf2_elixir": {:hex, :pbkdf2_elixir, "0.12.3", "6706a148809a29c306062862c803406e88f048277f6e85b68faf73291e820b84", [:mix], [], "hexpm"},
|
||||||
"phoenix": {:hex, :phoenix, "1.3.4", "aaa1b55e5523083a877bcbe9886d9ee180bf2c8754905323493c2ac325903dc5", [:mix], [{:cowboy, "~> 1.0", [hex: :cowboy, repo: "hexpm", optional: true]}, {:phoenix_pubsub, "~> 1.0", [hex: :phoenix_pubsub, repo: "hexpm", optional: false]}, {:plug, "~> 1.3.3 or ~> 1.4", [hex: :plug, repo: "hexpm", optional: false]}, {:poison, "~> 2.2 or ~> 3.0", [hex: :poison, repo: "hexpm", optional: false]}], "hexpm"},
|
"phoenix": {:git, "https://github.com/feld/phoenix.git", "38e03a6c18eabe24284d9bf1e1dbc09fd24547ad", [branch: "v1.4"]},
|
||||||
"phoenix_ecto": {:hex, :phoenix_ecto, "3.3.0", "702f6e164512853d29f9d20763493f2b3bcfcb44f118af2bc37bb95d0801b480", [:mix], [{:ecto, "~> 2.1", [hex: :ecto, repo: "hexpm", optional: false]}, {:phoenix_html, "~> 2.9", [hex: :phoenix_html, repo: "hexpm", optional: true]}, {:plug, "~> 1.0", [hex: :plug, repo: "hexpm", optional: false]}], "hexpm"},
|
"phoenix_ecto": {:hex, :phoenix_ecto, "3.3.0", "702f6e164512853d29f9d20763493f2b3bcfcb44f118af2bc37bb95d0801b480", [:mix], [{:ecto, "~> 2.1", [hex: :ecto, repo: "hexpm", optional: false]}, {:phoenix_html, "~> 2.9", [hex: :phoenix_html, repo: "hexpm", optional: true]}, {:plug, "~> 1.0", [hex: :plug, repo: "hexpm", optional: false]}], "hexpm"},
|
||||||
"phoenix_html": {:hex, :phoenix_html, "2.11.2", "86ebd768258ba60a27f5578bec83095bdb93485d646fc4111db8844c316602d6", [:mix], [{:plug, "~> 1.5", [hex: :plug, repo: "hexpm", optional: false]}], "hexpm"},
|
"phoenix_html": {:hex, :phoenix_html, "2.11.2", "86ebd768258ba60a27f5578bec83095bdb93485d646fc4111db8844c316602d6", [:mix], [{:plug, "~> 1.5", [hex: :plug, repo: "hexpm", optional: false]}], "hexpm"},
|
||||||
"phoenix_pubsub": {:hex, :phoenix_pubsub, "1.0.2", "bfa7fd52788b5eaa09cb51ff9fcad1d9edfeb68251add458523f839392f034c1", [:mix], [], "hexpm"},
|
"phoenix_pubsub": {:hex, :phoenix_pubsub, "1.1.1", "6668d787e602981f24f17a5fbb69cc98f8ab085114ebfac6cc36e10a90c8e93c", [:mix], [], "hexpm"},
|
||||||
"plug": {:hex, :plug, "1.6.2", "e06a7bd2bb6de5145da0dd950070110dce88045351224bd98e84edfdaaf5ffee", [:mix], [{:cowboy, "~> 1.0.1 or ~> 1.1 or ~> 2.4", [hex: :cowboy, repo: "hexpm", optional: true]}, {:mime, "~> 1.0", [hex: :mime, repo: "hexpm", optional: false]}], "hexpm"},
|
"plug": {:hex, :plug, "1.7.1", "8516d565fb84a6a8b2ca722e74e2cd25ca0fc9d64f364ec9dbec09d33eb78ccd", [:mix], [{:mime, "~> 1.0", [hex: :mime, repo: "hexpm", optional: false]}, {:plug_crypto, "~> 1.0", [hex: :plug_crypto, repo: "hexpm", optional: false]}], "hexpm"},
|
||||||
|
"plug_cowboy": {:hex, :plug_cowboy, "1.0.0", "2e2a7d3409746d335f451218b8bb0858301c3de6d668c3052716c909936eb57a", [:mix], [{:cowboy, "~> 1.0", [hex: :cowboy, repo: "hexpm", optional: false]}, {:plug, "~> 1.7", [hex: :plug, repo: "hexpm", optional: false]}], "hexpm"},
|
||||||
|
"plug_crypto": {:hex, :plug_crypto, "1.0.0", "18e49317d3fa343f24620ed22795ec29d4a5e602d52d1513ccea0b07d8ea7d4d", [:mix], [], "hexpm"},
|
||||||
"poison": {:hex, :poison, "3.1.0", "d9eb636610e096f86f25d9a46f35a9facac35609a7591b3be3326e99a0484665", [:mix], [], "hexpm"},
|
"poison": {:hex, :poison, "3.1.0", "d9eb636610e096f86f25d9a46f35a9facac35609a7591b3be3326e99a0484665", [:mix], [], "hexpm"},
|
||||||
"poolboy": {:hex, :poolboy, "1.5.1", "6b46163901cfd0a1b43d692657ed9d7e599853b3b21b95ae5ae0a777cf9b6ca8", [:rebar], [], "hexpm"},
|
"poolboy": {:hex, :poolboy, "1.5.1", "6b46163901cfd0a1b43d692657ed9d7e599853b3b21b95ae5ae0a777cf9b6ca8", [:rebar], [], "hexpm"},
|
||||||
"postgrex": {:hex, :postgrex, "0.13.5", "3d931aba29363e1443da167a4b12f06dcd171103c424de15e5f3fc2ba3e6d9c5", [:mix], [{:connection, "~> 1.0", [hex: :connection, repo: "hexpm", optional: false]}, {:db_connection, "~> 1.1", [hex: :db_connection, repo: "hexpm", optional: false]}, {:decimal, "~> 1.0", [hex: :decimal, repo: "hexpm", optional: false]}], "hexpm"},
|
"postgrex": {:hex, :postgrex, "0.13.5", "3d931aba29363e1443da167a4b12f06dcd171103c424de15e5f3fc2ba3e6d9c5", [:mix], [{:connection, "~> 1.0", [hex: :connection, repo: "hexpm", optional: false]}, {:db_connection, "~> 1.1", [hex: :db_connection, repo: "hexpm", optional: false]}, {:decimal, "~> 1.0", [hex: :decimal, repo: "hexpm", optional: false]}], "hexpm"},
|
||||||
|
|
|
@ -1,11 +1,7 @@
|
||||||
defmodule Pleroma.Web.WebFinger.WebFingerControllerTest do
|
defmodule Pleroma.Web.WebFinger.WebFingerControllerTest do
|
||||||
use Pleroma.Web.ConnCase
|
use Pleroma.Web.ConnCase
|
||||||
|
|
||||||
alias Pleroma.User
|
|
||||||
alias Pleroma.Web.WebFinger.WebFingerController
|
|
||||||
|
|
||||||
import Pleroma.Factory
|
import Pleroma.Factory
|
||||||
import ExUnit.CaptureLog
|
|
||||||
import Tesla.Mock
|
import Tesla.Mock
|
||||||
|
|
||||||
setup do
|
setup do
|
||||||
|
|
Loading…
Reference in a new issue