Merge branch 'develop' into feature/digest-email
This commit is contained in:
commit
8292331b35
|
@ -20,6 +20,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
|
||||||
- Mastodon API: Embedded relationships not being properly rendered in the Account entity of Status entity
|
- Mastodon API: Embedded relationships not being properly rendered in the Account entity of Status entity
|
||||||
- Mastodon API: Add `account_id`, `type`, `offset`, and `limit` to search API (`/api/v1/search` and `/api/v2/search`)
|
- Mastodon API: Add `account_id`, `type`, `offset`, and `limit` to search API (`/api/v1/search` and `/api/v2/search`)
|
||||||
- ActivityPub C2S: follower/following collection pages being inaccessible even when authentifucated if `hide_followers`/ `hide_follows` was set
|
- ActivityPub C2S: follower/following collection pages being inaccessible even when authentifucated if `hide_followers`/ `hide_follows` was set
|
||||||
|
- Existing user id not being preserved on insert conflict
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
- MRF: Support for priming the mediaproxy cache (`Pleroma.Web.ActivityPub.MRF.MediaProxyWarmingPolicy`)
|
- MRF: Support for priming the mediaproxy cache (`Pleroma.Web.ActivityPub.MRF.MediaProxyWarmingPolicy`)
|
||||||
|
@ -34,6 +35,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
|
||||||
- Mastodon API: Add support for the `blocked_by` attribute in the relationship API (`GET /api/v1/accounts/relationships`). <https://github.com/tootsuite/mastodon/pull/10373>
|
- Mastodon API: Add support for the `blocked_by` attribute in the relationship API (`GET /api/v1/accounts/relationships`). <https://github.com/tootsuite/mastodon/pull/10373>
|
||||||
- Mastodon API: Add `pleroma.deactivated` to the Account entity
|
- Mastodon API: Add `pleroma.deactivated` to the Account entity
|
||||||
- Mastodon API: added `/auth/password` endpoint for password reset with rate limit.
|
- Mastodon API: added `/auth/password` endpoint for password reset with rate limit.
|
||||||
|
- Mastodon API: /api/v1/accounts/:id/statuses now supports nicknames or user id
|
||||||
- Admin API: Return users' tags when querying reports
|
- Admin API: Return users' tags when querying reports
|
||||||
- Admin API: Return avatar and display name when querying users
|
- Admin API: Return avatar and display name when querying users
|
||||||
- Admin API: Allow querying user by ID
|
- Admin API: Allow querying user by ID
|
||||||
|
|
|
@ -34,7 +34,10 @@ Has these additional fields under the `pleroma` object:
|
||||||
|
|
||||||
## Accounts
|
## Accounts
|
||||||
|
|
||||||
- `/api/v1/accounts/:id`: The `id` parameter can also be the `nickname` of the user. This only works in this endpoint, not the deeper nested ones for following etc.
|
The `id` parameter can also be the `nickname` of the user. This only works in these endpoints, not the deeper nested ones for following etc.
|
||||||
|
|
||||||
|
- `/api/v1/accounts/:id`
|
||||||
|
- `/api/v1/accounts/:id/statuses`
|
||||||
|
|
||||||
Has these additional fields under the `pleroma` object:
|
Has these additional fields under the `pleroma` object:
|
||||||
|
|
||||||
|
|
|
@ -1212,7 +1212,7 @@ def insert_or_update_user(data) do
|
||||||
data
|
data
|
||||||
|> Map.put(:name, blank?(data[:name]) || data[:nickname])
|
|> Map.put(:name, blank?(data[:name]) || data[:nickname])
|
||||||
|> remote_user_creation()
|
|> remote_user_creation()
|
||||||
|> Repo.insert(on_conflict: :replace_all, conflict_target: :nickname)
|
|> Repo.insert(on_conflict: :replace_all_except_primary_key, conflict_target: :nickname)
|
||||||
|> set_cache()
|
|> set_cache()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -440,7 +440,7 @@ def public_timeline(%{assigns: %{user: user}} = conn, params) do
|
||||||
end
|
end
|
||||||
|
|
||||||
def user_statuses(%{assigns: %{user: reading_user}} = conn, params) do
|
def user_statuses(%{assigns: %{user: reading_user}} = conn, params) do
|
||||||
with %User{} = user <- User.get_cached_by_id(params["id"]) do
|
with %User{} = user <- User.get_cached_by_nickname_or_id(params["id"]) do
|
||||||
params =
|
params =
|
||||||
params
|
params
|
||||||
|> Map.put("tag", params["tagged"])
|
|> Map.put("tag", params["tagged"])
|
||||||
|
|
|
@ -8,6 +8,9 @@ defmodule Pleroma.Plugs.AuthenticationPlugTest do
|
||||||
alias Pleroma.Plugs.AuthenticationPlug
|
alias Pleroma.Plugs.AuthenticationPlug
|
||||||
alias Pleroma.User
|
alias Pleroma.User
|
||||||
|
|
||||||
|
import ExUnit.CaptureLog
|
||||||
|
import Mock
|
||||||
|
|
||||||
setup %{conn: conn} do
|
setup %{conn: conn} do
|
||||||
user = %User{
|
user = %User{
|
||||||
id: 1,
|
id: 1,
|
||||||
|
@ -68,15 +71,18 @@ test "check sha512-crypt hash" do
|
||||||
hash =
|
hash =
|
||||||
"$6$9psBWV8gxkGOZWBz$PmfCycChoxeJ3GgGzwvhlgacb9mUoZ.KUXNCssekER4SJ7bOK53uXrHNb2e4i8yPFgSKyzaW9CcmrDXWIEMtD1"
|
"$6$9psBWV8gxkGOZWBz$PmfCycChoxeJ3GgGzwvhlgacb9mUoZ.KUXNCssekER4SJ7bOK53uXrHNb2e4i8yPFgSKyzaW9CcmrDXWIEMtD1"
|
||||||
|
|
||||||
|
with_mock :crypt, crypt: fn _password, password_hash -> password_hash end do
|
||||||
assert AuthenticationPlug.checkpw("password", hash)
|
assert AuthenticationPlug.checkpw("password", hash)
|
||||||
refute AuthenticationPlug.checkpw("password1", hash)
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
test "it returns false when hash invalid" do
|
test "it returns false when hash invalid" do
|
||||||
hash =
|
hash =
|
||||||
"psBWV8gxkGOZWBz$PmfCycChoxeJ3GgGzwvhlgacb9mUoZ.KUXNCssekER4SJ7bOK53uXrHNb2e4i8yPFgSKyzaW9CcmrDXWIEMtD1"
|
"psBWV8gxkGOZWBz$PmfCycChoxeJ3GgGzwvhlgacb9mUoZ.KUXNCssekER4SJ7bOK53uXrHNb2e4i8yPFgSKyzaW9CcmrDXWIEMtD1"
|
||||||
|
|
||||||
|
assert capture_log(fn ->
|
||||||
refute Pleroma.Plugs.AuthenticationPlug.checkpw("password", hash)
|
refute Pleroma.Plugs.AuthenticationPlug.checkpw("password", hash)
|
||||||
|
end) =~ "[error] Password hash not recognized"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
defmodule Pleroma.SignatureTest do
|
defmodule Pleroma.SignatureTest do
|
||||||
use Pleroma.DataCase
|
use Pleroma.DataCase
|
||||||
|
|
||||||
|
import ExUnit.CaptureLog
|
||||||
import Pleroma.Factory
|
import Pleroma.Factory
|
||||||
import Tesla.Mock
|
import Tesla.Mock
|
||||||
|
|
||||||
|
@ -46,8 +47,10 @@ test "it returns key" do
|
||||||
end
|
end
|
||||||
|
|
||||||
test "it returns error when not found user" do
|
test "it returns error when not found user" do
|
||||||
|
assert capture_log(fn ->
|
||||||
assert Signature.fetch_public_key(make_fake_conn("test-ap_id")) ==
|
assert Signature.fetch_public_key(make_fake_conn("test-ap_id")) ==
|
||||||
{:error, :error}
|
{:error, :error}
|
||||||
|
end) =~ "[error] Could not decode user"
|
||||||
end
|
end
|
||||||
|
|
||||||
test "it returns error if public key is empty" do
|
test "it returns error if public key is empty" do
|
||||||
|
@ -67,8 +70,10 @@ test "it returns key" do
|
||||||
end
|
end
|
||||||
|
|
||||||
test "it returns error when not found user" do
|
test "it returns error when not found user" do
|
||||||
|
assert capture_log(fn ->
|
||||||
assert Signature.refetch_public_key(make_fake_conn("test-ap_id")) ==
|
assert Signature.refetch_public_key(make_fake_conn("test-ap_id")) ==
|
||||||
{:error, {:error, :ok}}
|
{:error, {:error, :ok}}
|
||||||
|
end) =~ "[error] Could not decode user"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -5,6 +5,8 @@
|
||||||
defmodule Pleroma.UploadTest do
|
defmodule Pleroma.UploadTest do
|
||||||
use Pleroma.DataCase
|
use Pleroma.DataCase
|
||||||
|
|
||||||
|
import ExUnit.CaptureLog
|
||||||
|
|
||||||
alias Pleroma.Upload
|
alias Pleroma.Upload
|
||||||
alias Pleroma.Uploaders.Uploader
|
alias Pleroma.Uploaders.Uploader
|
||||||
|
|
||||||
|
@ -77,8 +79,12 @@ def put_file(upload), do: TestUploaderBase.put_file(upload, __MODULE__)
|
||||||
|
|
||||||
test "it returns error" do
|
test "it returns error" do
|
||||||
File.cp!("test/fixtures/image.jpg", "test/fixtures/image_tmp.jpg")
|
File.cp!("test/fixtures/image.jpg", "test/fixtures/image_tmp.jpg")
|
||||||
|
|
||||||
|
assert capture_log(fn ->
|
||||||
assert Upload.store(@upload_file) == {:error, "Errors"}
|
assert Upload.store(@upload_file) == {:error, "Errors"}
|
||||||
Task.await(Agent.get(TestUploaderError, fn task_pid -> task_pid end))
|
Task.await(Agent.get(TestUploaderError, fn task_pid -> task_pid end))
|
||||||
|
end) =~
|
||||||
|
"[error] Elixir.Pleroma.Upload store (using Pleroma.UploadTest.TestUploaderError) failed: \"Errors\""
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -89,7 +95,11 @@ test "it returns error" do
|
||||||
|
|
||||||
test "it returns error" do
|
test "it returns error" do
|
||||||
File.cp!("test/fixtures/image.jpg", "test/fixtures/image_tmp.jpg")
|
File.cp!("test/fixtures/image.jpg", "test/fixtures/image_tmp.jpg")
|
||||||
|
|
||||||
|
assert capture_log(fn ->
|
||||||
assert Upload.store(@upload_file) == {:error, "Uploader callback timeout"}
|
assert Upload.store(@upload_file) == {:error, "Uploader callback timeout"}
|
||||||
|
end) =~
|
||||||
|
"[error] Elixir.Pleroma.Upload store (using Pleroma.UploadTest.TestUploader) failed: \"Uploader callback timeout\""
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -24,12 +24,16 @@ test "it returns empty result if user or status search return undefined error",
|
||||||
{Pleroma.User, [], [search: fn _q, _o -> raise "Oops" end]},
|
{Pleroma.User, [], [search: fn _q, _o -> raise "Oops" end]},
|
||||||
{Pleroma.Activity, [], [search: fn _u, _q, _o -> raise "Oops" end]}
|
{Pleroma.Activity, [], [search: fn _u, _q, _o -> raise "Oops" end]}
|
||||||
] do
|
] do
|
||||||
conn = get(conn, "/api/v2/search", %{"q" => "2hu"})
|
capture_log(fn ->
|
||||||
|
results =
|
||||||
assert results = json_response(conn, 200)
|
conn
|
||||||
|
|> get("/api/v2/search", %{"q" => "2hu"})
|
||||||
|
|> json_response(200)
|
||||||
|
|
||||||
assert results["accounts"] == []
|
assert results["accounts"] == []
|
||||||
assert results["statuses"] == []
|
assert results["statuses"] == []
|
||||||
|
end) =~
|
||||||
|
"[error] Elixir.Pleroma.Web.MastodonAPI.SearchController search error: %RuntimeError{message: \"Oops\"}"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -99,14 +103,16 @@ test "it returns empty result if user or status search return undefined error",
|
||||||
{Pleroma.User, [], [search: fn _q, _o -> raise "Oops" end]},
|
{Pleroma.User, [], [search: fn _q, _o -> raise "Oops" end]},
|
||||||
{Pleroma.Activity, [], [search: fn _u, _q, _o -> raise "Oops" end]}
|
{Pleroma.Activity, [], [search: fn _u, _q, _o -> raise "Oops" end]}
|
||||||
] do
|
] do
|
||||||
conn =
|
capture_log(fn ->
|
||||||
|
results =
|
||||||
conn
|
conn
|
||||||
|> get("/api/v1/search", %{"q" => "2hu"})
|
|> get("/api/v1/search", %{"q" => "2hu"})
|
||||||
|
|> json_response(200)
|
||||||
assert results = json_response(conn, 200)
|
|
||||||
|
|
||||||
assert results["accounts"] == []
|
assert results["accounts"] == []
|
||||||
assert results["statuses"] == []
|
assert results["statuses"] == []
|
||||||
|
end) =~
|
||||||
|
"[error] Elixir.Pleroma.Web.MastodonAPI.SearchController search error: %RuntimeError{message: \"Oops\"}"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,10 @@
|
||||||
|
|
||||||
defmodule Pleroma.Web.OStatus.OStatusControllerTest do
|
defmodule Pleroma.Web.OStatus.OStatusControllerTest do
|
||||||
use Pleroma.Web.ConnCase
|
use Pleroma.Web.ConnCase
|
||||||
|
|
||||||
|
import ExUnit.CaptureLog
|
||||||
import Pleroma.Factory
|
import Pleroma.Factory
|
||||||
|
|
||||||
alias Pleroma.Object
|
alias Pleroma.Object
|
||||||
alias Pleroma.User
|
alias Pleroma.User
|
||||||
alias Pleroma.Web.CommonAPI
|
alias Pleroma.Web.CommonAPI
|
||||||
|
@ -27,24 +30,28 @@ test "decodes a salmon", %{conn: conn} do
|
||||||
user = insert(:user)
|
user = insert(:user)
|
||||||
salmon = File.read!("test/fixtures/salmon.xml")
|
salmon = File.read!("test/fixtures/salmon.xml")
|
||||||
|
|
||||||
|
assert capture_log(fn ->
|
||||||
conn =
|
conn =
|
||||||
conn
|
conn
|
||||||
|> put_req_header("content-type", "application/atom+xml")
|
|> put_req_header("content-type", "application/atom+xml")
|
||||||
|> post("/users/#{user.nickname}/salmon", salmon)
|
|> post("/users/#{user.nickname}/salmon", salmon)
|
||||||
|
|
||||||
assert response(conn, 200)
|
assert response(conn, 200)
|
||||||
|
end) =~ "[error]"
|
||||||
end
|
end
|
||||||
|
|
||||||
test "decodes a salmon with a changed magic key", %{conn: conn} do
|
test "decodes a salmon with a changed magic key", %{conn: conn} do
|
||||||
user = insert(:user)
|
user = insert(:user)
|
||||||
salmon = File.read!("test/fixtures/salmon.xml")
|
salmon = File.read!("test/fixtures/salmon.xml")
|
||||||
|
|
||||||
|
assert capture_log(fn ->
|
||||||
conn =
|
conn =
|
||||||
conn
|
conn
|
||||||
|> put_req_header("content-type", "application/atom+xml")
|
|> put_req_header("content-type", "application/atom+xml")
|
||||||
|> post("/users/#{user.nickname}/salmon", salmon)
|
|> post("/users/#{user.nickname}/salmon", salmon)
|
||||||
|
|
||||||
assert response(conn, 200)
|
assert response(conn, 200)
|
||||||
|
end) =~ "[error]"
|
||||||
|
|
||||||
# Set a wrong magic-key for a user so it has to refetch
|
# Set a wrong magic-key for a user so it has to refetch
|
||||||
salmon_user = User.get_cached_by_ap_id("http://gs.example.org:4040/index.php/user/1")
|
salmon_user = User.get_cached_by_ap_id("http://gs.example.org:4040/index.php/user/1")
|
||||||
|
@ -61,12 +68,14 @@ test "decodes a salmon with a changed magic key", %{conn: conn} do
|
||||||
|> Ecto.Changeset.put_embed(:info, info_cng)
|
|> Ecto.Changeset.put_embed(:info, info_cng)
|
||||||
|> User.update_and_set_cache()
|
|> User.update_and_set_cache()
|
||||||
|
|
||||||
|
assert capture_log(fn ->
|
||||||
conn =
|
conn =
|
||||||
build_conn()
|
build_conn()
|
||||||
|> put_req_header("content-type", "application/atom+xml")
|
|> put_req_header("content-type", "application/atom+xml")
|
||||||
|> post("/users/#{user.nickname}/salmon", salmon)
|
|> post("/users/#{user.nickname}/salmon", salmon)
|
||||||
|
|
||||||
assert response(conn, 200)
|
assert response(conn, 200)
|
||||||
|
end) =~ "[error]"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue