Merge branch 'develop' of git.pleroma.social:pleroma/pleroma into remake-remodel-dms
This commit is contained in:
commit
8e1db6a835
|
@ -171,7 +171,8 @@
|
||||||
"application/ld+json" => ["activity+json"]
|
"application/ld+json" => ["activity+json"]
|
||||||
}
|
}
|
||||||
|
|
||||||
config :tesla, adapter: Tesla.Adapter.Gun
|
config :tesla, adapter: Tesla.Adapter.Hackney
|
||||||
|
|
||||||
# Configures http settings, upstream proxy etc.
|
# Configures http settings, upstream proxy etc.
|
||||||
config :pleroma, :http,
|
config :pleroma, :http,
|
||||||
proxy_url: nil,
|
proxy_url: nil,
|
||||||
|
|
|
@ -139,9 +139,7 @@ def verify_credentials(%{assigns: %{user: user}} = conn, _) do
|
||||||
end
|
end
|
||||||
|
|
||||||
@doc "PATCH /api/v1/accounts/update_credentials"
|
@doc "PATCH /api/v1/accounts/update_credentials"
|
||||||
def update_credentials(%{assigns: %{user: original_user}, body_params: params} = conn, _params) do
|
def update_credentials(%{assigns: %{user: user}, body_params: params} = conn, _params) do
|
||||||
user = original_user
|
|
||||||
|
|
||||||
params =
|
params =
|
||||||
params
|
params
|
||||||
|> Enum.filter(fn {_, value} -> not is_nil(value) end)
|
|> Enum.filter(fn {_, value} -> not is_nil(value) end)
|
||||||
|
@ -183,12 +181,31 @@ def update_credentials(%{assigns: %{user: original_user}, body_params: params} =
|
||||||
changeset = User.update_changeset(user, user_params)
|
changeset = User.update_changeset(user, user_params)
|
||||||
|
|
||||||
with {:ok, user} <- User.update_and_set_cache(changeset) do
|
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)
|
render(conn, "show.json", user: user, for: user, with_pleroma_settings: true)
|
||||||
else
|
else
|
||||||
_e -> render_error(conn, :forbidden, "Invalid request")
|
_e -> render_error(conn, :forbidden, "Invalid request")
|
||||||
end
|
end
|
||||||
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
|
defp add_if_present(map, params, params_field, map_field, value_function \\ &{:ok, &1}) do
|
||||||
with true <- is_map(params),
|
with true <- is_map(params),
|
||||||
true <- Map.has_key?(params, params_field),
|
true <- Map.has_key?(params, params_field),
|
||||||
|
|
|
@ -111,7 +111,7 @@ def public(%{assigns: %{user: user}} = conn, params) do
|
||||||
else
|
else
|
||||||
activities =
|
activities =
|
||||||
params
|
params
|
||||||
|> Map.put("type", ["Create", "Announce"])
|
|> Map.put("type", ["Create"])
|
||||||
|> Map.put("local_only", local_only)
|
|> Map.put("local_only", local_only)
|
||||||
|> Map.put("blocking_user", user)
|
|> Map.put("blocking_user", user)
|
||||||
|> Map.put("muting_user", user)
|
|> Map.put("muting_user", user)
|
||||||
|
|
|
@ -8,6 +8,7 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIController.UpdateCredentialsTest do
|
||||||
|
|
||||||
use Pleroma.Web.ConnCase
|
use Pleroma.Web.ConnCase
|
||||||
|
|
||||||
|
import Mock
|
||||||
import Pleroma.Factory
|
import Pleroma.Factory
|
||||||
|
|
||||||
setup do: clear_config([:instance, :max_account_fields])
|
setup do: clear_config([:instance, :max_account_fields])
|
||||||
|
@ -52,6 +53,10 @@ test "sets user settings in a generic way", %{conn: conn} do
|
||||||
|
|
||||||
user = Repo.get(User, user_data["id"])
|
user = Repo.get(User, user_data["id"])
|
||||||
|
|
||||||
|
clear_config([:instance, :federating], true)
|
||||||
|
|
||||||
|
with_mock Pleroma.Web.Federator,
|
||||||
|
publish: fn _activity -> :ok end do
|
||||||
res_conn =
|
res_conn =
|
||||||
conn
|
conn
|
||||||
|> assign(:user, user)
|
|> assign(:user, user)
|
||||||
|
@ -70,6 +75,9 @@ test "sets user settings in a generic way", %{conn: conn} do
|
||||||
"pleroma_fe" => %{"theme" => "bla"},
|
"pleroma_fe" => %{"theme" => "bla"},
|
||||||
"masto_fe" => %{"theme" => "blub"}
|
"masto_fe" => %{"theme" => "blub"}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
assert_called(Pleroma.Web.Federator.publish(:_))
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
test "updates the user's bio", %{conn: conn} do
|
test "updates the user's bio", %{conn: conn} do
|
||||||
|
|
|
@ -60,9 +60,9 @@ test "the home timeline when the direct messages are excluded", %{user: user, co
|
||||||
describe "public" do
|
describe "public" do
|
||||||
@tag capture_log: true
|
@tag capture_log: true
|
||||||
test "the public timeline", %{conn: conn} do
|
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)
|
_activity = insert(:note_activity, local: false)
|
||||||
|
|
||||||
|
@ -77,6 +77,13 @@ test "the public timeline", %{conn: conn} do
|
||||||
conn = get(build_conn(), "/api/v1/timelines/public?local=1")
|
conn = get(build_conn(), "/api/v1/timelines/public?local=1")
|
||||||
|
|
||||||
assert [%{"content" => "test"}] = json_response_and_validate_schema(conn, :ok)
|
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
|
end
|
||||||
|
|
||||||
test "the public timeline includes only public statuses for an authenticated user" do
|
test "the public timeline includes only public statuses for an authenticated user" do
|
||||||
|
|
Loading…
Reference in New Issue