aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorlain <lain@soykaf.club>2018-03-27 16:45:38 +0200
committerlain <lain@soykaf.club>2018-03-27 16:45:38 +0200
commitd2099c849d355a9b8d3b1f2e0342dfe3c7e3497c (patch)
treed2973f3e43913e6e620f4cd31d699144d9348b13 /lib
parent527e8037589ab06e772125cdf937388db6d2c468 (diff)
downloadpleroma-d2099c849d355a9b8d3b1f2e0342dfe3c7e3497c.tar.gz
More Jason changes.
Diffstat (limited to 'lib')
-rw-r--r--lib/pleroma/plugs/authentication_plug.ex2
-rw-r--r--lib/pleroma/web/activity_pub/activity_pub.ex6
-rw-r--r--lib/pleroma/web/mastodon_api/mastodon_api_controller.ex14
-rw-r--r--lib/pleroma/web/streamer.ex8
-rw-r--r--lib/pleroma/web/twitter_api/representers/base_representer.ex4
-rw-r--r--lib/pleroma/web/twitter_api/twitter_api.ex4
-rw-r--r--lib/pleroma/web/twitter_api/twitter_api_controller.ex30
-rw-r--r--lib/pleroma/web/web_finger/web_finger.ex4
8 files changed, 36 insertions, 36 deletions
diff --git a/lib/pleroma/plugs/authentication_plug.ex b/lib/pleroma/plugs/authentication_plug.ex
index 60f6faf49..4794e625a 100644
--- a/lib/pleroma/plugs/authentication_plug.ex
+++ b/lib/pleroma/plugs/authentication_plug.ex
@@ -58,7 +58,7 @@ defmodule Pleroma.Plugs.AuthenticationPlug do
defp halt_or_continue(conn, _) do
conn
|> put_resp_content_type("application/json")
- |> send_resp(403, Poison.encode!(%{error: "Invalid credentials."}))
+ |> send_resp(403, Jason.encode!(%{error: "Invalid credentials."}))
|> halt
end
end
diff --git a/lib/pleroma/web/activity_pub/activity_pub.ex b/lib/pleroma/web/activity_pub/activity_pub.ex
index bdc1b5df7..3a914088f 100644
--- a/lib/pleroma/web/activity_pub/activity_pub.ex
+++ b/lib/pleroma/web/activity_pub/activity_pub.ex
@@ -305,7 +305,7 @@ defmodule Pleroma.Web.ActivityPub.ActivityPub do
def fetch_and_prepare_user_from_ap_id(ap_id) do
with {:ok, %{status_code: 200, body: body}} <- @httpoison.get(ap_id, ["Accept": "application/activity+json"]),
- {:ok, data} <- Poison.decode(body) do
+ {:ok, data} <- Jason.decode(body) do
user_data_from_user_object(data)
else
e -> Logger.error("Could not decode user at fetch #{ap_id}, #{inspect(e)}")
@@ -348,7 +348,7 @@ defmodule Pleroma.Web.ActivityPub.ActivityPub do
|> Enum.uniq
{:ok, data} = Transmogrifier.prepare_outgoing(activity.data)
- json = Poison.encode!(data)
+ json = Jason.encode!(data)
Enum.each remote_inboxes, fn(inbox) ->
Federator.enqueue(:publish_single_ap, %{inbox: inbox, json: json, actor: actor, id: activity.data["id"]})
end
@@ -370,7 +370,7 @@ defmodule Pleroma.Web.ActivityPub.ActivityPub do
Logger.info("Fetching #{id} via AP")
with true <- String.starts_with?(id, "http"),
{:ok, %{body: body, status_code: code}} when code in 200..299 <- @httpoison.get(id, [Accept: "application/activity+json"], follow_redirect: true, timeout: 10000, recv_timeout: 20000),
- {:ok, data} <- Poison.decode(body),
+ {:ok, data} <- Jason.decode(body),
nil <- Object.get_by_ap_id(data["id"]),
params <- %{"type" => "Create", "to" => data["to"], "cc" => data["cc"], "actor" => data["attributedTo"], "object" => data},
{:ok, activity} <- Transmogrifier.handle_incoming(params) do
diff --git a/lib/pleroma/web/mastodon_api/mastodon_api_controller.ex b/lib/pleroma/web/mastodon_api/mastodon_api_controller.ex
index c03941254..70a7fa863 100644
--- a/lib/pleroma/web/mastodon_api/mastodon_api_controller.ex
+++ b/lib/pleroma/web/mastodon_api/mastodon_api_controller.ex
@@ -284,7 +284,7 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIController do
{:error, reason} ->
conn
|> put_resp_content_type("application/json")
- |> send_resp(403, Poison.encode!(%{"error" => reason}))
+ |> send_resp(403, Jason.encode!(%{"error" => reason}))
end
end
@@ -300,7 +300,7 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIController do
{:error, reason} ->
conn
|> put_resp_content_type("application/json")
- |> send_resp(403, Poison.encode!(%{"error" => reason}))
+ |> send_resp(403, Jason.encode!(%{"error" => reason}))
end
end
@@ -381,7 +381,7 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIController do
{:error, message} ->
conn
|> put_resp_content_type("application/json")
- |> send_resp(403, Poison.encode!(%{"error" => message}))
+ |> send_resp(403, Jason.encode!(%{"error" => message}))
end
end
@@ -394,7 +394,7 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIController do
{:error, message} ->
conn
|> put_resp_content_type("application/json")
- |> send_resp(403, Poison.encode!(%{"error" => message}))
+ |> send_resp(403, Jason.encode!(%{"error" => message}))
end
end
@@ -419,7 +419,7 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIController do
{:error, message} ->
conn
|> put_resp_content_type("application/json")
- |> send_resp(403, Poison.encode!(%{"error" => message}))
+ |> send_resp(403, Jason.encode!(%{"error" => message}))
end
end
@@ -431,7 +431,7 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIController do
{:error, message} ->
conn
|> put_resp_content_type("application/json")
- |> send_resp(403, Poison.encode!(%{"error" => message}))
+ |> send_resp(403, Jason.encode!(%{"error" => message}))
end
end
@@ -565,7 +565,7 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIController do
push_subscription: nil,
accounts: accounts,
custom_emojis: mastodon_emoji
- } |> Poison.encode!
+ } |> Jason.encode!
conn
|> put_layout(false)
|> render(MastodonView, "index.html", %{initial_state: initial_state})
diff --git a/lib/pleroma/web/streamer.ex b/lib/pleroma/web/streamer.ex
index a417178ba..d81732a1a 100644
--- a/lib/pleroma/web/streamer.ex
+++ b/lib/pleroma/web/streamer.ex
@@ -42,8 +42,8 @@ defmodule Pleroma.Web.Streamer do
Enum.each(topics[topic] || [], fn (socket) ->
json = %{
event: "notification",
- payload: Pleroma.Web.MastodonAPI.MastodonAPIController.render_notification(socket.assigns["user"], item) |> Poison.encode!
- } |> Poison.encode!
+ payload: Pleroma.Web.MastodonAPI.MastodonAPIController.render_notification(socket.assigns["user"], item) |> Jason.encode!
+ } |> Jason.encode!
send socket.transport_pid, {:text, json}
end)
@@ -95,8 +95,8 @@ defmodule Pleroma.Web.Streamer do
Enum.each(topics[topic] || [], fn (socket) ->
json = %{
event: "update",
- payload: Pleroma.Web.MastodonAPI.StatusView.render("status.json", activity: item, for: socket.assigns[:user]) |> Poison.encode!
- } |> Poison.encode!
+ payload: Pleroma.Web.MastodonAPI.StatusView.render("status.json", activity: item, for: socket.assigns[:user]) |> Jason.encode!
+ } |> Jason.encode!
send socket.transport_pid, {:text, json}
end)
diff --git a/lib/pleroma/web/twitter_api/representers/base_representer.ex b/lib/pleroma/web/twitter_api/representers/base_representer.ex
index a4ef245fc..75e00520c 100644
--- a/lib/pleroma/web/twitter_api/representers/base_representer.ex
+++ b/lib/pleroma/web/twitter_api/representers/base_representer.ex
@@ -5,7 +5,7 @@ defmodule Pleroma.Web.TwitterAPI.Representers.BaseRepresenter do
def to_json(object, options) do
object
|> to_map(options)
- |> Poison.encode!
+ |> Jason.encode!
end
def enum_to_list(enum, options) do
@@ -21,7 +21,7 @@ defmodule Pleroma.Web.TwitterAPI.Representers.BaseRepresenter do
def enum_to_json(enum, options) do
enum
|> enum_to_list(options)
- |> Poison.encode!
+ |> Jason.encode!
end
end
end
diff --git a/lib/pleroma/web/twitter_api/twitter_api.ex b/lib/pleroma/web/twitter_api/twitter_api.ex
index 6e1f141f3..58801bc33 100644
--- a/lib/pleroma/web/twitter_api/twitter_api.ex
+++ b/lib/pleroma/web/twitter_api/twitter_api.ex
@@ -169,7 +169,7 @@ defmodule Pleroma.Web.TwitterAPI.TwitterAPI do
media_id_string: "#{object.id}}",
media_url: href,
size: 0
- } |> Poison.encode!
+ } |> Jason.encode!
end
end
@@ -190,7 +190,7 @@ defmodule Pleroma.Web.TwitterAPI.TwitterAPI do
else
{:error, changeset} ->
errors = Ecto.Changeset.traverse_errors(changeset, fn {msg, _opts} -> msg end)
- |> Poison.encode!
+ |> Jason.encode!
{:error, %{error: errors}}
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 848ec218f..085113f26 100644
--- a/lib/pleroma/web/twitter_api/twitter_api_controller.ex
+++ b/lib/pleroma/web/twitter_api/twitter_api_controller.ex
@@ -44,7 +44,7 @@ defmodule Pleroma.Web.TwitterAPI.Controller do
def public_and_external_timeline(%{assigns: %{user: user}} = conn, params) do
statuses = TwitterAPI.fetch_public_and_external_statuses(user, params)
- {:ok, json} = Poison.encode(statuses)
+ {:ok, json} = Jason.encode(statuses)
conn
|> json_reply(200, json)
@@ -52,7 +52,7 @@ defmodule Pleroma.Web.TwitterAPI.Controller do
def public_timeline(%{assigns: %{user: user}} = conn, params) do
statuses = TwitterAPI.fetch_public_statuses(user, params)
- {:ok, json} = Poison.encode(statuses)
+ {:ok, json} = Jason.encode(statuses)
conn
|> json_reply(200, json)
@@ -60,7 +60,7 @@ defmodule Pleroma.Web.TwitterAPI.Controller do
def friends_timeline(%{assigns: %{user: user}} = conn, params) do
statuses = TwitterAPI.fetch_friend_statuses(user, params)
- {:ok, json} = Poison.encode(statuses)
+ {:ok, json} = Jason.encode(statuses)
conn
|> json_reply(200, json)
@@ -85,7 +85,7 @@ defmodule Pleroma.Web.TwitterAPI.Controller do
params = Map.merge(params, %{"actor_id" => target_user.ap_id, "whole_db" => true})
statuses = TwitterAPI.fetch_user_statuses(user, params)
conn
- |> json_reply(200, statuses |> Poison.encode!)
+ |> json_reply(200, statuses |> Jason.encode!)
{:error, msg} ->
bad_request_reply(conn, msg)
end
@@ -93,7 +93,7 @@ defmodule Pleroma.Web.TwitterAPI.Controller do
def mentions_timeline(%{assigns: %{user: user}} = conn, params) do
statuses = TwitterAPI.fetch_mentions(user, params)
- {:ok, json} = Poison.encode(statuses)
+ {:ok, json} = Jason.encode(statuses)
conn
|> json_reply(200, json)
@@ -140,7 +140,7 @@ defmodule Pleroma.Web.TwitterAPI.Controller do
end
def fetch_status(%{assigns: %{user: user}} = conn, %{"id" => id}) do
- response = Poison.encode!(TwitterAPI.fetch_status(user, id))
+ response = Jason.encode!(TwitterAPI.fetch_status(user, id))
conn
|> json_reply(200, response)
@@ -148,7 +148,7 @@ defmodule Pleroma.Web.TwitterAPI.Controller do
def fetch_conversation(%{assigns: %{user: user}} = conn, %{"id" => id}) do
id = String.to_integer(id)
- response = Poison.encode!(TwitterAPI.fetch_conversation(user, id))
+ response = Jason.encode!(TwitterAPI.fetch_conversation(user, id))
conn
|> json_reply(200, response)
@@ -200,7 +200,7 @@ defmodule Pleroma.Web.TwitterAPI.Controller do
else
{:error, errors} ->
conn
- |> json_reply(400, Poison.encode!(errors))
+ |> json_reply(400, Jason.encode!(errors))
end
end
@@ -220,7 +220,7 @@ defmodule Pleroma.Web.TwitterAPI.Controller do
{:ok, user} <- User.update_and_set_cache(change) do
CommonAPI.update(user)
%{"url" => [ %{ "href" => href } | _ ]} = object.data
- response = %{ url: href } |> Poison.encode!
+ response = %{ url: href } |> Jason.encode!
conn
|> json_reply(200, response)
end
@@ -232,7 +232,7 @@ defmodule Pleroma.Web.TwitterAPI.Controller do
change <- User.info_changeset(user, %{info: new_info}),
{:ok, _user} <- User.update_and_set_cache(change) do
%{"url" => [ %{ "href" => href } | _ ]} = object.data
- response = %{ url: href } |> Poison.encode!
+ response = %{ url: href } |> Jason.encode!
conn
|> json_reply(200, response)
end
@@ -240,7 +240,7 @@ defmodule Pleroma.Web.TwitterAPI.Controller do
def external_profile(%{assigns: %{user: current_user}} = conn, %{"profileurl" => uri}) do
with {:ok, user_map} <- TwitterAPI.get_external_profile(current_user, uri),
- response <- Poison.encode!(user_map) do
+ response <- Jason.encode!(user_map) do
conn
|> json_reply(200, response)
else
@@ -259,7 +259,7 @@ defmodule Pleroma.Web.TwitterAPI.Controller do
changeset <- User.info_changeset(user, %{info: updated_info}),
{:ok, _user} <- User.update_and_set_cache(changeset) do
conn
- |> json_reply(200, Poison.encode!(mrn))
+ |> json_reply(200, Jason.encode!(mrn))
else
_e -> bad_request_reply(conn, "Can't update.")
end
@@ -287,7 +287,7 @@ defmodule Pleroma.Web.TwitterAPI.Controller do
with {:ok, friends} <- User.get_friends(user) do
ids = friends
|> Enum.map(fn x -> x.id end)
- |> Poison.encode!
+ |> Jason.encode!
json(conn, ids)
else
@@ -296,7 +296,7 @@ defmodule Pleroma.Web.TwitterAPI.Controller do
end
def empty_array(conn, _params) do
- json(conn, Poison.encode!([]))
+ json(conn, Jason.encode!([]))
end
def update_profile(%{assigns: %{user: user}} = conn, params) do
@@ -339,6 +339,6 @@ defmodule Pleroma.Web.TwitterAPI.Controller do
end
defp error_json(conn, error_message) do
- %{"error" => error_message, "request" => conn.request_path} |> Poison.encode!
+ %{"error" => error_message, "request" => conn.request_path} |> Jason.encode!
end
end
diff --git a/lib/pleroma/web/web_finger/web_finger.ex b/lib/pleroma/web/web_finger/web_finger.ex
index 7391edcd7..8edb89963 100644
--- a/lib/pleroma/web/web_finger/web_finger.ex
+++ b/lib/pleroma/web/web_finger/web_finger.ex
@@ -4,7 +4,7 @@ defmodule Pleroma.Web.WebFinger do
alias Pleroma.{Repo, User, XmlBuilder}
alias Pleroma.Web
alias Pleroma.Web.{XML, Salmon, OStatus}
- require Poison
+ require Jason
require Logger
def host_meta do
@@ -182,7 +182,7 @@ defmodule Pleroma.Web.WebFinger do
if doc != :error do
webfinger_from_xml(doc)
else
- {:ok, doc} = Poison.decode(body)
+ {:ok, doc} = Jason.decode(body)
webfinger_from_json(doc)
end
else