Merge remote-tracking branch 'soapbox/develop' into pleroma-events
This commit is contained in:
commit
61e069df72
6 changed files with 34 additions and 20 deletions
|
@ -214,7 +214,8 @@ defp cachex_children do
|
|||
expiration: chat_message_id_idempotency_key_expiration(),
|
||||
limit: 500_000
|
||||
),
|
||||
build_cachex("translations", default_ttl: :timer.hours(24), limit: 5_000)
|
||||
build_cachex("translations", default_ttl: :timer.hours(24), limit: 5_000),
|
||||
build_cachex("rel_me", default_ttl: :timer.minutes(30), limit: 2_500)
|
||||
]
|
||||
end
|
||||
|
||||
|
|
|
@ -2713,10 +2713,11 @@ def sanitize_html(%User{} = user) do
|
|||
# - display name
|
||||
def sanitize_html(%User{} = user, filter) do
|
||||
fields =
|
||||
Enum.map(user.fields, fn %{"name" => name, "value" => value} ->
|
||||
Enum.map(user.fields, fn %{"name" => name, "value" => value} = field ->
|
||||
%{
|
||||
"name" => name,
|
||||
"value" => HTML.filter_tags(value, Pleroma.HTML.Scrubber.LinksOnly)
|
||||
"value" => HTML.filter_tags(value, Pleroma.HTML.Scrubber.LinksOnly),
|
||||
"verified_at" => Map.get(field, "verified_at")
|
||||
}
|
||||
end)
|
||||
|
||||
|
|
|
@ -259,7 +259,9 @@ def update_credentials(%{assigns: %{user: user}, body_params: params} = conn, _p
|
|||
|
||||
defp normalize_fields_attributes(fields) do
|
||||
if Enum.all?(fields, &is_tuple/1) do
|
||||
Enum.map(fields, fn {_, v} -> v end)
|
||||
Enum.map(fields, fn {_, %{} = field} ->
|
||||
%{"name" => field["name"], "value" => field["value"]}
|
||||
end)
|
||||
else
|
||||
Enum.map(fields, fn
|
||||
%{} = field -> %{"name" => field.name, "value" => field.value}
|
||||
|
|
|
@ -74,7 +74,7 @@ defp is_status?(acct) do
|
|||
def do_follow(%{assigns: %{user: %User{} = user}} = conn, %{"user" => %{"id" => id}}) do
|
||||
with {:fetch_user, %User{} = followee} <- {:fetch_user, User.get_cached_by_id(id)},
|
||||
{:ok, _, _, _} <- CommonAPI.follow(user, followee) do
|
||||
redirect(conn, to: "/users/#{followee.id}")
|
||||
redirect(conn, to: "/users/#{followee.nickname}")
|
||||
else
|
||||
error ->
|
||||
handle_follow_error(conn, error)
|
||||
|
@ -91,7 +91,7 @@ def do_follow(conn, %{"authorization" => %{"name" => _, "password" => _, "id" =>
|
|||
{_, {:ok, user}, _} <- {:auth, WrapperAuthenticator.get_user(conn), followee},
|
||||
{_, _, _, false} <- {:mfa_required, followee, user, MFA.require?(user)},
|
||||
{:ok, _, _, _} <- CommonAPI.follow(user, followee) do
|
||||
redirect(conn, to: "/users/#{followee.id}")
|
||||
redirect(conn, to: "/users/#{followee.nickname}")
|
||||
else
|
||||
error ->
|
||||
handle_follow_error(conn, error)
|
||||
|
@ -109,7 +109,7 @@ def do_follow(conn, %{"mfa" => %{"code" => code, "token" => token, "id" => id}})
|
|||
{_, _, _, {:ok, _}} <-
|
||||
{:verify_mfa_code, followee, token, TOTPAuthenticator.verify(code, user)},
|
||||
{:ok, _, _, _} <- CommonAPI.follow(user, followee) do
|
||||
redirect(conn, to: "/users/#{followee.id}")
|
||||
redirect(conn, to: "/users/#{followee.nickname}")
|
||||
else
|
||||
error ->
|
||||
handle_follow_error(conn, error)
|
||||
|
|
|
@ -351,8 +351,12 @@ test "updates profile emojos", %{user: user, conn: conn} do
|
|||
|
||||
test "update fields", %{conn: conn} do
|
||||
fields = [
|
||||
%{"name" => "<a href=\"http://google.com\">foo</a>", "value" => "<script>bar</script>"},
|
||||
%{"name" => "link.io", "value" => "cofe.io"}
|
||||
%{
|
||||
"name" => "<a href=\"http://google.com\">foo</a>",
|
||||
"value" => "<script>bar</script>",
|
||||
"verified_at" => nil
|
||||
},
|
||||
%{"name" => "link.io", "value" => "cofe.io", "verified_at" => nil}
|
||||
]
|
||||
|
||||
account_data =
|
||||
|
@ -361,10 +365,15 @@ test "update fields", %{conn: conn} do
|
|||
|> json_response_and_validate_schema(200)
|
||||
|
||||
assert account_data["fields"] == [
|
||||
%{"name" => "<a href=\"http://google.com\">foo</a>", "value" => "bar"},
|
||||
%{
|
||||
"name" => "<a href=\"http://google.com\">foo</a>",
|
||||
"value" => "bar",
|
||||
"verified_at" => nil
|
||||
},
|
||||
%{
|
||||
"name" => "link.io",
|
||||
"value" => ~S(<a href="http://cofe.io" rel="ugc">cofe.io</a>)
|
||||
"value" => ~S(<a href="http://cofe.io" rel="ugc">cofe.io</a>),
|
||||
"verified_at" => nil
|
||||
}
|
||||
]
|
||||
|
||||
|
@ -433,8 +442,8 @@ test "emojis in fields labels", %{conn: conn} do
|
|||
|> json_response_and_validate_schema(200)
|
||||
|
||||
assert account_data["fields"] == [
|
||||
%{"name" => ":firefox:", "value" => "is best 2hu"},
|
||||
%{"name" => "they wins", "value" => ":blank:"}
|
||||
%{"name" => ":firefox:", "value" => "is best 2hu", "verified_at" => nil},
|
||||
%{"name" => "they wins", "value" => ":blank:", "verified_at" => nil}
|
||||
]
|
||||
|
||||
assert account_data["source"]["fields"] == [
|
||||
|
@ -462,10 +471,11 @@ test "update fields via x-www-form-urlencoded", %{conn: conn} do
|
|||
|> json_response_and_validate_schema(200)
|
||||
|
||||
assert account["fields"] == [
|
||||
%{"name" => "foo", "value" => "bar"},
|
||||
%{"name" => "foo", "value" => "bar", "verified_at" => nil},
|
||||
%{
|
||||
"name" => "link",
|
||||
"value" => ~S(<a href="http://cofe.io" rel="ugc">http://cofe.io</a>)
|
||||
"value" => ~S(<a href="http://cofe.io" rel="ugc">http://cofe.io</a>),
|
||||
"verified_at" => nil
|
||||
}
|
||||
]
|
||||
|
||||
|
@ -487,7 +497,7 @@ test "update fields with empty name", %{conn: conn} do
|
|||
|> json_response_and_validate_schema(200)
|
||||
|
||||
assert account["fields"] == [
|
||||
%{"name" => "foo", "value" => ""}
|
||||
%{"name" => "foo", "value" => "", "verified_at" => nil}
|
||||
]
|
||||
end
|
||||
|
||||
|
|
|
@ -167,7 +167,7 @@ test "follows user", %{conn: conn} do
|
|||
|> assign(:token, insert(:oauth_token, user: user, scopes: ["write:follows"]))
|
||||
|> post(remote_follow_path(conn, :do_follow), %{"user" => %{"id" => user2.id}})
|
||||
|
||||
assert redirected_to(conn) == "/users/#{user2.id}"
|
||||
assert redirected_to(conn) == "/users/#{user2.nickname}"
|
||||
end
|
||||
|
||||
test "returns error when user is deactivated", %{conn: conn} do
|
||||
|
@ -222,7 +222,7 @@ test "returns success result when user already in followers", %{conn: conn} do
|
|||
|> assign(:token, insert(:oauth_token, user: user, scopes: ["write:follows"]))
|
||||
|> post(remote_follow_path(conn, :do_follow), %{"user" => %{"id" => user2.id}})
|
||||
|
||||
assert redirected_to(conn) == "/users/#{user2.id}"
|
||||
assert redirected_to(conn) == "/users/#{user2.nickname}"
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -304,7 +304,7 @@ test "follows", %{conn: conn} do
|
|||
}
|
||||
)
|
||||
|
||||
assert redirected_to(conn) == "/users/#{user2.id}"
|
||||
assert redirected_to(conn) == "/users/#{user2.nickname}"
|
||||
assert user2.follower_address in User.following(user)
|
||||
end
|
||||
|
||||
|
@ -350,7 +350,7 @@ test "follows", %{conn: conn} do
|
|||
"authorization" => %{"name" => user.nickname, "password" => "test", "id" => user2.id}
|
||||
})
|
||||
|
||||
assert redirected_to(conn) == "/users/#{user2.id}"
|
||||
assert redirected_to(conn) == "/users/#{user2.nickname}"
|
||||
assert user2.follower_address in User.following(user)
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in a new issue