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)}")
|> 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
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
{: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
{: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
{: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
{: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
{: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
{: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
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})
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)
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)
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)
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
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)
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)
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)
else
{:error, errors} ->
conn
- |> json_reply(400, Poison.encode!(errors))
+ |> json_reply(400, Jason.encode!(errors))
end
end
{: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
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
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
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
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
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
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