aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlain <lain@soykaf.club>2020-06-02 10:43:13 +0200
committerlain <lain@soykaf.club>2020-06-02 10:43:13 +0200
commit8e1db6a8352754fd70c51ab8527b71180aa15a5b (patch)
treeea12ca93e5d22e407440d75bb70fce2ac6e140ab
parentaf9090238e1f71e6b081fbd09c09a5975d2ed99e (diff)
parent6fb900a496e1797c1a3b438db9f96b09d9546f1d (diff)
downloadpleroma-8e1db6a8352754fd70c51ab8527b71180aa15a5b.tar.gz
Merge branch 'develop' of git.pleroma.social:pleroma/pleroma into remake-remodel-dms
-rw-r--r--config/config.exs3
-rw-r--r--lib/pleroma/web/mastodon_api/controllers/account_controller.ex23
-rw-r--r--lib/pleroma/web/mastodon_api/controllers/timeline_controller.ex2
-rw-r--r--test/web/mastodon_api/controllers/account_controller/update_credentials_test.exs38
-rw-r--r--test/web/mastodon_api/controllers/timeline_controller_test.exs11
5 files changed, 55 insertions, 22 deletions
diff --git a/config/config.exs b/config/config.exs
index d15998715..9a9fbb436 100644
--- a/config/config.exs
+++ b/config/config.exs
@@ -171,7 +171,8 @@ config :mime, :types, %{
"application/ld+json" => ["activity+json"]
}
-config :tesla, adapter: Tesla.Adapter.Gun
+config :tesla, adapter: Tesla.Adapter.Hackney
+
# Configures http settings, upstream proxy etc.
config :pleroma, :http,
proxy_url: nil,
diff --git a/lib/pleroma/web/mastodon_api/controllers/account_controller.ex b/lib/pleroma/web/mastodon_api/controllers/account_controller.ex
index 47649d41d..97295a52f 100644
--- a/lib/pleroma/web/mastodon_api/controllers/account_controller.ex
+++ b/lib/pleroma/web/mastodon_api/controllers/account_controller.ex
@@ -139,9 +139,7 @@ defmodule Pleroma.Web.MastodonAPI.AccountController do
end
@doc "PATCH /api/v1/accounts/update_credentials"
- def update_credentials(%{assigns: %{user: original_user}, body_params: params} = conn, _params) do
- user = original_user
-
+ def update_credentials(%{assigns: %{user: user}, body_params: params} = conn, _params) do
params =
params
|> Enum.filter(fn {_, value} -> not is_nil(value) end)
@@ -183,12 +181,31 @@ defmodule Pleroma.Web.MastodonAPI.AccountController do
changeset = User.update_changeset(user, user_params)
with {:ok, user} <- User.update_and_set_cache(changeset) do
+ user
+ |> build_update_activity_params()
+ |> ActivityPub.update()
+
render(conn, "show.json", user: user, for: user, with_pleroma_settings: true)
else
_e -> render_error(conn, :forbidden, "Invalid request")
end
end
+ # Hotfix, handling will be redone with the pipeline
+ defp build_update_activity_params(user) do
+ object =
+ Pleroma.Web.ActivityPub.UserView.render("user.json", user: user)
+ |> Map.delete("@context")
+
+ %{
+ local: true,
+ to: [user.follower_address],
+ cc: [],
+ object: object,
+ actor: user.ap_id
+ }
+ end
+
defp add_if_present(map, params, params_field, map_field, value_function \\ &{:ok, &1}) do
with true <- is_map(params),
true <- Map.has_key?(params, params_field),
diff --git a/lib/pleroma/web/mastodon_api/controllers/timeline_controller.ex b/lib/pleroma/web/mastodon_api/controllers/timeline_controller.ex
index 958567510..f67f75430 100644
--- a/lib/pleroma/web/mastodon_api/controllers/timeline_controller.ex
+++ b/lib/pleroma/web/mastodon_api/controllers/timeline_controller.ex
@@ -111,7 +111,7 @@ defmodule Pleroma.Web.MastodonAPI.TimelineController do
else
activities =
params
- |> Map.put("type", ["Create", "Announce"])
+ |> Map.put("type", ["Create"])
|> Map.put("local_only", local_only)
|> Map.put("blocking_user", user)
|> Map.put("muting_user", user)
diff --git a/test/web/mastodon_api/controllers/account_controller/update_credentials_test.exs b/test/web/mastodon_api/controllers/account_controller/update_credentials_test.exs
index 696228203..7c420985d 100644
--- a/test/web/mastodon_api/controllers/account_controller/update_credentials_test.exs
+++ b/test/web/mastodon_api/controllers/account_controller/update_credentials_test.exs
@@ -8,6 +8,7 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIController.UpdateCredentialsTest do
use Pleroma.Web.ConnCase
+ import Mock
import Pleroma.Factory
setup do: clear_config([:instance, :max_account_fields])
@@ -52,24 +53,31 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIController.UpdateCredentialsTest do
user = Repo.get(User, user_data["id"])
- res_conn =
- conn
- |> assign(:user, user)
- |> patch("/api/v1/accounts/update_credentials", %{
- "pleroma_settings_store" => %{
- masto_fe: %{
- theme: "blub"
+ clear_config([:instance, :federating], true)
+
+ with_mock Pleroma.Web.Federator,
+ publish: fn _activity -> :ok end do
+ res_conn =
+ conn
+ |> assign(:user, user)
+ |> patch("/api/v1/accounts/update_credentials", %{
+ "pleroma_settings_store" => %{
+ masto_fe: %{
+ theme: "blub"
+ }
}
- }
- })
+ })
- assert user_data = json_response_and_validate_schema(res_conn, 200)
+ assert user_data = json_response_and_validate_schema(res_conn, 200)
- assert user_data["pleroma"]["settings_store"] ==
- %{
- "pleroma_fe" => %{"theme" => "bla"},
- "masto_fe" => %{"theme" => "blub"}
- }
+ assert user_data["pleroma"]["settings_store"] ==
+ %{
+ "pleroma_fe" => %{"theme" => "bla"},
+ "masto_fe" => %{"theme" => "blub"}
+ }
+
+ assert_called(Pleroma.Web.Federator.publish(:_))
+ end
end
test "updates the user's bio", %{conn: conn} do
diff --git a/test/web/mastodon_api/controllers/timeline_controller_test.exs b/test/web/mastodon_api/controllers/timeline_controller_test.exs
index 2375ac8e8..65b4079fe 100644
--- a/test/web/mastodon_api/controllers/timeline_controller_test.exs
+++ b/test/web/mastodon_api/controllers/timeline_controller_test.exs
@@ -60,9 +60,9 @@ defmodule Pleroma.Web.MastodonAPI.TimelineControllerTest do
describe "public" do
@tag capture_log: true
test "the public timeline", %{conn: conn} do
- following = insert(:user)
+ user = insert(:user)
- {:ok, _activity} = CommonAPI.post(following, %{status: "test"})
+ {:ok, activity} = CommonAPI.post(user, %{status: "test"})
_activity = insert(:note_activity, local: false)
@@ -77,6 +77,13 @@ defmodule Pleroma.Web.MastodonAPI.TimelineControllerTest do
conn = get(build_conn(), "/api/v1/timelines/public?local=1")
assert [%{"content" => "test"}] = json_response_and_validate_schema(conn, :ok)
+
+ # does not contain repeats
+ {:ok, _} = CommonAPI.repeat(activity.id, user)
+
+ conn = get(build_conn(), "/api/v1/timelines/public?local=true")
+
+ assert [_] = json_response_and_validate_schema(conn, :ok)
end
test "the public timeline includes only public statuses for an authenticated user" do