Merge branch 'develop' of git.pleroma.social:pleroma/pleroma into remake-remodel-dms
This commit is contained in:
commit
205313e541
80 changed files with 2138 additions and 337 deletions
|
|
@ -820,21 +820,29 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubControllerTest do
|
|||
activity: activity
|
||||
} do
|
||||
user = insert(:user)
|
||||
conn = assign(conn, :user, user)
|
||||
object = Map.put(activity["object"], "sensitive", true)
|
||||
activity = Map.put(activity, "object", object)
|
||||
|
||||
result =
|
||||
response =
|
||||
conn
|
||||
|> assign(:user, user)
|
||||
|> put_req_header("content-type", "application/activity+json")
|
||||
|> post("/users/#{user.nickname}/outbox", activity)
|
||||
|> json_response(201)
|
||||
|
||||
assert Activity.get_by_ap_id(result["id"])
|
||||
assert result["object"]
|
||||
assert %Object{data: object} = Object.normalize(result["object"])
|
||||
assert object["sensitive"] == activity["object"]["sensitive"]
|
||||
assert object["content"] == activity["object"]["content"]
|
||||
assert Activity.get_by_ap_id(response["id"])
|
||||
assert response["object"]
|
||||
assert %Object{data: response_object} = Object.normalize(response["object"])
|
||||
assert response_object["sensitive"] == true
|
||||
assert response_object["content"] == activity["object"]["content"]
|
||||
|
||||
representation =
|
||||
conn
|
||||
|> put_req_header("accept", "application/activity+json")
|
||||
|> get(response["id"])
|
||||
|> json_response(200)
|
||||
|
||||
assert representation["object"]["sensitive"] == true
|
||||
end
|
||||
|
||||
test "it rejects an incoming activity with bogus type", %{conn: conn, activity: activity} do
|
||||
|
|
|
|||
|
|
@ -18,9 +18,10 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubTest do
|
|||
alias Pleroma.Web.CommonAPI
|
||||
alias Pleroma.Web.Federator
|
||||
|
||||
import ExUnit.CaptureLog
|
||||
import Mock
|
||||
import Pleroma.Factory
|
||||
import Tesla.Mock
|
||||
import Mock
|
||||
|
||||
setup do
|
||||
mock(fn env -> apply(HttpRequestMock, :request, [env]) end)
|
||||
|
|
@ -2403,4 +2404,51 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubTest do
|
|||
u3: %{r1: r3_1.id, r2: r3_2.id},
|
||||
u4: %{r1: r4_1.id}}
|
||||
end
|
||||
|
||||
describe "maybe_update_follow_information/1" do
|
||||
setup do
|
||||
clear_config([:instance, :external_user_synchronization], true)
|
||||
|
||||
user = %{
|
||||
local: false,
|
||||
ap_id: "https://gensokyo.2hu/users/raymoo",
|
||||
following_address: "https://gensokyo.2hu/users/following",
|
||||
follower_address: "https://gensokyo.2hu/users/followers",
|
||||
type: "Person"
|
||||
}
|
||||
|
||||
%{user: user}
|
||||
end
|
||||
|
||||
test "logs an error when it can't fetch the info", %{user: user} do
|
||||
assert capture_log(fn ->
|
||||
ActivityPub.maybe_update_follow_information(user)
|
||||
end) =~ "Follower/Following counter update for #{user.ap_id} failed"
|
||||
end
|
||||
|
||||
test "just returns the input if the user type is Application", %{
|
||||
user: user
|
||||
} do
|
||||
user =
|
||||
user
|
||||
|> Map.put(:type, "Application")
|
||||
|
||||
refute capture_log(fn ->
|
||||
assert ^user = ActivityPub.maybe_update_follow_information(user)
|
||||
end) =~ "Follower/Following counter update for #{user.ap_id} failed"
|
||||
end
|
||||
|
||||
test "it just returns the input if the user has no following/follower addresses", %{
|
||||
user: user
|
||||
} do
|
||||
user =
|
||||
user
|
||||
|> Map.put(:following_address, nil)
|
||||
|> Map.put(:follower_address, nil)
|
||||
|
||||
refute capture_log(fn ->
|
||||
assert ^user = ActivityPub.maybe_update_follow_information(user)
|
||||
end) =~ "Follower/Following counter update for #{user.ap_id} failed"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue