config :phoenix, :format_encoders, json: Jason
+config :phoenix, :json_library, Jason
+
config :pleroma, :gopher,
enabled: false,
ip: {0, 0, 0, 0},
- Method: `POST`
- Params:
- - `nickname`
- - `email`
- - `password`
+ `users`: [
+ {
+ `nickname`,
+ `email`,
+ `password`
+ }
+ ]
- Response: User’s nickname
## `/api/pleroma/admin/users/follow`
})
end
- def run(["render_timeline", nickname]) do
+ def run(["render_timeline", nickname | _] = args) do
start_pleroma()
user = Pleroma.User.get_by_nickname(nickname)
|> Map.put("blocking_user", user)
|> Map.put("muting_user", user)
|> Map.put("user", user)
- |> Map.put("limit", 80)
+ |> Map.put("limit", 4096)
|> Pleroma.Web.ActivityPub.ActivityPub.fetch_public_activities()
|> Enum.reverse()
inputs = %{
- "One activity" => Enum.take_random(activities, 1),
- "Ten activities" => Enum.take_random(activities, 10),
- "Twenty activities" => Enum.take_random(activities, 20),
- "Forty activities" => Enum.take_random(activities, 40),
- "Eighty activities" => Enum.take_random(activities, 80)
+ "1 activity" => Enum.take_random(activities, 1),
+ "10 activities" => Enum.take_random(activities, 10),
+ "20 activities" => Enum.take_random(activities, 20),
+ "40 activities" => Enum.take_random(activities, 40),
+ "80 activities" => Enum.take_random(activities, 80)
}
+ inputs =
+ if Enum.at(args, 2) == "extended" do
+ Map.merge(inputs, %{
+ "200 activities" => Enum.take_random(activities, 200),
+ "500 activities" => Enum.take_random(activities, 500),
+ "2000 activities" => Enum.take_random(activities, 2000),
+ "4096 activities" => Enum.take_random(activities, 4096)
+ })
+ else
+ inputs
+ end
+
Benchee.run(
%{
- "Parallel rendering" => fn activities ->
- Pleroma.Web.MastodonAPI.StatusView.render("index.json", %{
- activities: activities,
- for: user,
- as: :activity
- })
- end,
"Standart rendering" => fn activities ->
Pleroma.Web.MastodonAPI.StatusView.render("index.json", %{
activities: activities,
for: user,
- as: :activity,
- parallel: false
+ as: :activity
})
end
},
alias Pleroma.Healthcheck
alias Pleroma.Repo
+ @derive Jason.Encoder
defstruct pool_size: 0,
active: 0,
idle: 0,
|> Map.put("context", replied_object.data["context"] || object["conversation"])
else
e ->
- Logger.error("Couldn't fetch \"#{inspect(in_reply_to_id)}\", error: #{inspect(e)}")
+ Logger.error("Couldn't fetch #{inspect(in_reply_to_id)}, error: #{inspect(e)}")
object
end
e ->
- Logger.error("Couldn't fetch \"#{inspect(in_reply_to_id)}\", error: #{inspect(e)}")
+ Logger.error("Couldn't fetch #{inspect(in_reply_to_id)}, error: #{inspect(e)}")
object
end
else
def render("index.json", opts) do
replied_to_activities = get_replied_to_activities(opts.activities)
- parallel = unless is_nil(opts[:parallel]), do: opts[:parallel], else: true
opts.activities
|> safe_render_many(
StatusView,
"status.json",
- Map.put(opts, :replied_to_activities, replied_to_activities),
- parallel
+ Map.put(opts, :replied_to_activities, replied_to_activities)
)
end
object_tags = for tag when is_binary(tag) <- object_tags, do: tag
Enum.reduce(object_tags, [], fn tag, tags ->
- tags ++ [%{name: tag, url: "/tag/#{tag}"}]
+ tags ++ [%{name: tag, url: "/tag/#{URI.encode(tag)}"}]
end)
end
end
@doc """
- Same as `render_many/4` but wrapped in rescue block and parallelized (unless disabled by passing false as a fifth argument).
+ Same as `render_many/4` but wrapped in rescue block.
"""
- def safe_render_many(collection, view, template, assigns \\ %{}, parallel \\ true)
-
- def safe_render_many(collection, view, template, assigns, true) do
- Enum.map(collection, fn resource ->
- Task.async(fn ->
- as = Map.get(assigns, :as) || view.__resource__
- assigns = Map.put(assigns, as, resource)
- safe_render(view, template, assigns)
- end)
- end)
- |> Enum.map(&Task.await(&1, :infinity))
- |> Enum.filter(& &1)
- end
-
- def safe_render_many(collection, view, template, assigns, false) do
+ def safe_render_many(collection, view, template, assigns \\ %{}) do
Enum.map(collection, fn resource ->
as = Map.get(assigns, :as) || view.__resource__
assigns = Map.put(assigns, as, resource)
assert capture_log(fn ->
{:ok, _returned_activity} = Transmogrifier.handle_incoming(data)
- end) =~ "[error] Couldn't fetch \"\"https://404.site/whatever\"\", error: nil"
+ end) =~ "[error] Couldn't fetch \"https://404.site/whatever\", error: nil"
end
test "it works for incoming notices" do