1 defmodule Pleroma.LoadTesting.Fetcher do
2 use Pleroma.LoadTesting.Helper
4 def fetch_user(user) do
6 "By id" => fn -> Repo.get_by(User, id: user.id) end,
7 "By ap_id" => fn -> Repo.get_by(User, ap_id: user.ap_id) end,
8 "By email" => fn -> Repo.get_by(User, email: user.email) end,
9 "By nickname" => fn -> Repo.get_by(User, nickname: user.nickname) end
13 def query_timelines(user) do
14 home_timeline_params = %{
17 "type" => ["Create", "Announce"],
18 "blocking_user" => user,
19 "muting_user" => user,
23 mastodon_public_timeline_params = %{
26 "only_media" => "false",
27 "type" => ["Create", "Announce"],
28 "with_muted" => "true",
29 "blocking_user" => user,
33 mastodon_federated_timeline_params = %{
35 "only_media" => "false",
36 "type" => ["Create", "Announce"],
37 "with_muted" => "true",
38 "blocking_user" => user,
42 following = User.following(user)
45 "User home timeline" => fn ->
46 Pleroma.Web.ActivityPub.ActivityPub.fetch_activities(
51 "User mastodon public timeline" => fn ->
52 Pleroma.Web.ActivityPub.ActivityPub.fetch_public_activities(
53 mastodon_public_timeline_params
56 "User mastodon federated public timeline" => fn ->
57 Pleroma.Web.ActivityPub.ActivityPub.fetch_public_activities(
58 mastodon_federated_timeline_params
64 Pleroma.Web.ActivityPub.ActivityPub.fetch_activities(
70 Pleroma.Web.ActivityPub.ActivityPub.fetch_public_activities(mastodon_public_timeline_params)
72 public_federated_activities =
73 Pleroma.Web.ActivityPub.ActivityPub.fetch_public_activities(
74 mastodon_federated_timeline_params
78 "Rendering home timeline" => fn ->
79 Pleroma.Web.MastodonAPI.StatusView.render("index.json", %{
80 activities: home_activities,
85 "Rendering public timeline" => fn ->
86 Pleroma.Web.MastodonAPI.StatusView.render("index.json", %{
87 activities: public_activities,
92 "Rendering public federated timeline" => fn ->
93 Pleroma.Web.MastodonAPI.StatusView.render("index.json", %{
94 activities: public_federated_activities,
102 def query_notifications(user) do
103 without_muted_params = %{"count" => "20", "with_muted" => "false"}
104 with_muted_params = %{"count" => "20", "with_muted" => "true"}
107 "Notifications without muted" => fn ->
108 Pleroma.Web.MastodonAPI.MastodonAPI.get_notifications(user, without_muted_params)
110 "Notifications with muted" => fn ->
111 Pleroma.Web.MastodonAPI.MastodonAPI.get_notifications(user, with_muted_params)
115 without_muted_notifications =
116 Pleroma.Web.MastodonAPI.MastodonAPI.get_notifications(user, without_muted_params)
118 with_muted_notifications =
119 Pleroma.Web.MastodonAPI.MastodonAPI.get_notifications(user, with_muted_params)
122 "Render notifications without muted" => fn ->
123 Pleroma.Web.MastodonAPI.NotificationView.render("index.json", %{
124 notifications: without_muted_notifications,
128 "Render notifications with muted" => fn ->
129 Pleroma.Web.MastodonAPI.NotificationView.render("index.json", %{
130 notifications: with_muted_notifications,
137 def query_dms(user) do
140 "with_muted" => "true",
142 "blocking_user" => user,
148 "Direct messages with muted" => fn ->
149 Pleroma.Web.ActivityPub.ActivityPub.fetch_activities_query([user.ap_id], params)
150 |> Pleroma.Pagination.fetch_paginated(params)
152 "Direct messages without muted" => fn ->
153 Pleroma.Web.ActivityPub.ActivityPub.fetch_activities_query([user.ap_id], params)
154 |> Pleroma.Pagination.fetch_paginated(Map.put(params, "with_muted", false))
159 Pleroma.Web.ActivityPub.ActivityPub.fetch_activities_query([user.ap_id], params)
160 |> Pleroma.Pagination.fetch_paginated(params)
163 Pleroma.Web.ActivityPub.ActivityPub.fetch_activities_query([user.ap_id], params)
164 |> Pleroma.Pagination.fetch_paginated(Map.put(params, "with_muted", false))
167 "Rendering dms with muted" => fn ->
168 Pleroma.Web.MastodonAPI.StatusView.render("index.json", %{
169 activities: dms_with_muted,
174 "Rendering dms without muted" => fn ->
175 Pleroma.Web.MastodonAPI.StatusView.render("index.json", %{
176 activities: dms_without_muted,
184 def query_long_thread(user, activity) do
186 "Fetch main post" => fn ->
187 Pleroma.Activity.get_by_id_with_object(activity.id)
189 "Fetch context of main post" => fn ->
190 Pleroma.Web.ActivityPub.ActivityPub.fetch_activities_for_context(
191 activity.data["context"],
193 "blocking_user" => user,
195 "exclude_id" => activity.id
201 activity = Pleroma.Activity.get_by_id_with_object(activity.id)
204 Pleroma.Web.ActivityPub.ActivityPub.fetch_activities_for_context(
205 activity.data["context"],
207 "blocking_user" => user,
209 "exclude_id" => activity.id
214 "Render status" => fn ->
215 Pleroma.Web.MastodonAPI.StatusView.render("show.json", %{
220 "Render context" => fn ->
221 Pleroma.Web.MastodonAPI.StatusView.render(