Merge remote-tracking branch 'origin/develop' into translate-posts
This commit is contained in:
commit
f7a7517296
393 changed files with 4027 additions and 2279 deletions
BIN
test/fixtures/DSCN0010.png
vendored
Normal file
BIN
test/fixtures/DSCN0010.png
vendored
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 744 KiB |
117
test/fixtures/bastianallgeier.json
vendored
Normal file
117
test/fixtures/bastianallgeier.json
vendored
Normal file
|
|
@ -0,0 +1,117 @@
|
|||
{
|
||||
"@context": [
|
||||
"https://www.w3.org/ns/activitystreams",
|
||||
"https://w3id.org/security/v1",
|
||||
{
|
||||
"Curve25519Key": "toot:Curve25519Key",
|
||||
"Device": "toot:Device",
|
||||
"Ed25519Key": "toot:Ed25519Key",
|
||||
"Ed25519Signature": "toot:Ed25519Signature",
|
||||
"EncryptedMessage": "toot:EncryptedMessage",
|
||||
"PropertyValue": "schema:PropertyValue",
|
||||
"alsoKnownAs": {
|
||||
"@id": "as:alsoKnownAs",
|
||||
"@type": "@id"
|
||||
},
|
||||
"cipherText": "toot:cipherText",
|
||||
"claim": {
|
||||
"@id": "toot:claim",
|
||||
"@type": "@id"
|
||||
},
|
||||
"deviceId": "toot:deviceId",
|
||||
"devices": {
|
||||
"@id": "toot:devices",
|
||||
"@type": "@id"
|
||||
},
|
||||
"discoverable": "toot:discoverable",
|
||||
"featured": {
|
||||
"@id": "toot:featured",
|
||||
"@type": "@id"
|
||||
},
|
||||
"featuredTags": {
|
||||
"@id": "toot:featuredTags",
|
||||
"@type": "@id"
|
||||
},
|
||||
"fingerprintKey": {
|
||||
"@id": "toot:fingerprintKey",
|
||||
"@type": "@id"
|
||||
},
|
||||
"focalPoint": {
|
||||
"@container": "@list",
|
||||
"@id": "toot:focalPoint"
|
||||
},
|
||||
"identityKey": {
|
||||
"@id": "toot:identityKey",
|
||||
"@type": "@id"
|
||||
},
|
||||
"indexable": "toot:indexable",
|
||||
"manuallyApprovesFollowers": "as:manuallyApprovesFollowers",
|
||||
"memorial": "toot:memorial",
|
||||
"messageFranking": "toot:messageFranking",
|
||||
"messageType": "toot:messageType",
|
||||
"movedTo": {
|
||||
"@id": "as:movedTo",
|
||||
"@type": "@id"
|
||||
},
|
||||
"publicKeyBase64": "toot:publicKeyBase64",
|
||||
"schema": "http://schema.org#",
|
||||
"suspended": "toot:suspended",
|
||||
"toot": "http://joinmastodon.org/ns#",
|
||||
"value": "schema:value"
|
||||
}
|
||||
],
|
||||
"attachment": [
|
||||
{
|
||||
"name": "Website",
|
||||
"type": "PropertyValue",
|
||||
"value": "<a href=\"https://bastianallgeier.com\" target=\"_blank\" rel=\"nofollow noopener noreferrer me\" translate=\"no\"><span class=\"invisible\">https://</span><span class=\"\">bastianallgeier.com</span><span class=\"invisible\"></span></a>"
|
||||
},
|
||||
{
|
||||
"name": "Project",
|
||||
"type": "PropertyValue",
|
||||
"value": "<a href=\"https://getkirby.com\" target=\"_blank\" rel=\"nofollow noopener noreferrer me\" translate=\"no\"><span class=\"invisible\">https://</span><span class=\"\">getkirby.com</span><span class=\"invisible\"></span></a>"
|
||||
},
|
||||
{
|
||||
"name": "Github",
|
||||
"type": "PropertyValue",
|
||||
"value": "<a href=\"https://github.com/bastianallgeier\" target=\"_blank\" rel=\"nofollow noopener noreferrer me\" translate=\"no\"><span class=\"invisible\">https://</span><span class=\"\">github.com/bastianallgeier</span><span class=\"invisible\"></span></a>"
|
||||
}
|
||||
],
|
||||
"devices": "https://mastodon.social/users/bastianallgeier/collections/devices",
|
||||
"discoverable": true,
|
||||
"endpoints": {
|
||||
"sharedInbox": "https://mastodon.social/inbox"
|
||||
},
|
||||
"featured": "https://mastodon.social/users/bastianallgeier/collections/featured",
|
||||
"featuredTags": "https://mastodon.social/users/bastianallgeier/collections/tags",
|
||||
"followers": "https://mastodon.social/users/bastianallgeier/followers",
|
||||
"following": "https://mastodon.social/users/bastianallgeier/following",
|
||||
"icon": {
|
||||
"mediaType": "image/jpeg",
|
||||
"type": "Image",
|
||||
"url": "https://files.mastodon.social/accounts/avatars/000/007/393/original/0180a20079617c71.jpg"
|
||||
},
|
||||
"id": "https://mastodon.social/users/bastianallgeier",
|
||||
"image": {
|
||||
"mediaType": "image/jpeg",
|
||||
"type": "Image",
|
||||
"url": "https://files.mastodon.social/accounts/headers/000/007/393/original/13d644ab46d50478.jpeg"
|
||||
},
|
||||
"inbox": "https://mastodon.social/users/bastianallgeier/inbox",
|
||||
"indexable": false,
|
||||
"manuallyApprovesFollowers": false,
|
||||
"memorial": false,
|
||||
"name": "Bastian Allgeier",
|
||||
"outbox": "https://mastodon.social/users/bastianallgeier/outbox",
|
||||
"preferredUsername": "bastianallgeier",
|
||||
"publicKey": {
|
||||
"id": "https://mastodon.social/users/bastianallgeier#main-key",
|
||||
"owner": "https://mastodon.social/users/bastianallgeier",
|
||||
"publicKeyPem": "-----BEGIN PUBLIC KEY-----\nMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA3fz+hpgVztO9z6HUhyzv\nwP++ERBBoIwSLKf1TyIM8bvzGFm2YXaO5uxu1HvumYFTYc3ACr3q4j8VUb7NMxkQ\nlzu4QwPjOFJ43O+fY+HSPORXEDW5fXDGC5DGpox4+i08LxRmx7L6YPRUSUuPN8nI\nWyq1Qsq1zOQrNY/rohMXkBdSXxqC3yIRqvtLt4otCgay/5tMogJWkkS6ZKyFhb9z\nwVVy1fsbV10c9C+SHy4NH26CKaTtpTYLRBMjhTCS8bX8iDSjGIf2aZgYs1ir7gEz\n9wf5CvLiENmVWGwm64t6KSEAkA4NJ1hzgHUZPCjPHZE2SmhO/oHaxokTzqtbbENJ\n1QIDAQAB\n-----END PUBLIC KEY-----\n"
|
||||
},
|
||||
"published": "2016-11-01T00:00:00Z",
|
||||
"summary": "<p>Designer & developer. Creator of Kirby CMS</p>",
|
||||
"tag": [],
|
||||
"type": "Person",
|
||||
"url": "https://mastodon.social/@bastianallgeier"
|
||||
}
|
||||
112
test/fixtures/denniskoch.json
vendored
Normal file
112
test/fixtures/denniskoch.json
vendored
Normal file
|
|
@ -0,0 +1,112 @@
|
|||
{
|
||||
"@context": [
|
||||
"https://www.w3.org/ns/activitystreams",
|
||||
"https://w3id.org/security/v1",
|
||||
{
|
||||
"Curve25519Key": "toot:Curve25519Key",
|
||||
"Device": "toot:Device",
|
||||
"Ed25519Key": "toot:Ed25519Key",
|
||||
"Ed25519Signature": "toot:Ed25519Signature",
|
||||
"EncryptedMessage": "toot:EncryptedMessage",
|
||||
"PropertyValue": "schema:PropertyValue",
|
||||
"alsoKnownAs": {
|
||||
"@id": "as:alsoKnownAs",
|
||||
"@type": "@id"
|
||||
},
|
||||
"cipherText": "toot:cipherText",
|
||||
"claim": {
|
||||
"@id": "toot:claim",
|
||||
"@type": "@id"
|
||||
},
|
||||
"deviceId": "toot:deviceId",
|
||||
"devices": {
|
||||
"@id": "toot:devices",
|
||||
"@type": "@id"
|
||||
},
|
||||
"discoverable": "toot:discoverable",
|
||||
"featured": {
|
||||
"@id": "toot:featured",
|
||||
"@type": "@id"
|
||||
},
|
||||
"featuredTags": {
|
||||
"@id": "toot:featuredTags",
|
||||
"@type": "@id"
|
||||
},
|
||||
"fingerprintKey": {
|
||||
"@id": "toot:fingerprintKey",
|
||||
"@type": "@id"
|
||||
},
|
||||
"focalPoint": {
|
||||
"@container": "@list",
|
||||
"@id": "toot:focalPoint"
|
||||
},
|
||||
"identityKey": {
|
||||
"@id": "toot:identityKey",
|
||||
"@type": "@id"
|
||||
},
|
||||
"indexable": "toot:indexable",
|
||||
"manuallyApprovesFollowers": "as:manuallyApprovesFollowers",
|
||||
"memorial": "toot:memorial",
|
||||
"messageFranking": "toot:messageFranking",
|
||||
"messageType": "toot:messageType",
|
||||
"movedTo": {
|
||||
"@id": "as:movedTo",
|
||||
"@type": "@id"
|
||||
},
|
||||
"publicKeyBase64": "toot:publicKeyBase64",
|
||||
"schema": "http://schema.org#",
|
||||
"suspended": "toot:suspended",
|
||||
"toot": "http://joinmastodon.org/ns#",
|
||||
"value": "schema:value"
|
||||
}
|
||||
],
|
||||
"attachment": [
|
||||
{
|
||||
"name": "GitHub",
|
||||
"type": "PropertyValue",
|
||||
"value": "<a href=\"https://github.com/pxlrbt/\" target=\"_blank\" rel=\"nofollow noopener noreferrer me\" translate=\"no\"><span class=\"invisible\">https://</span><span class=\"\">github.com/pxlrbt/</span><span class=\"invisible\"></span></a>"
|
||||
},
|
||||
{
|
||||
"name": "Discord",
|
||||
"type": "PropertyValue",
|
||||
"value": "pxlrbt#6029"
|
||||
}
|
||||
],
|
||||
"devices": "https://phpc.social/users/denniskoch/collections/devices",
|
||||
"discoverable": true,
|
||||
"endpoints": {
|
||||
"sharedInbox": "https://phpc.social/inbox"
|
||||
},
|
||||
"featured": "https://phpc.social/users/denniskoch/collections/featured",
|
||||
"featuredTags": "https://phpc.social/users/denniskoch/collections/tags",
|
||||
"followers": "https://phpc.social/users/denniskoch/followers",
|
||||
"following": "https://phpc.social/users/denniskoch/following",
|
||||
"icon": {
|
||||
"mediaType": "image/jpeg",
|
||||
"type": "Image",
|
||||
"url": "https://media.phpc.social/accounts/avatars/109/364/097/179/042/485/original/6e770c7b3f5ef72d.jpg"
|
||||
},
|
||||
"id": "https://phpc.social/users/denniskoch",
|
||||
"image": {
|
||||
"mediaType": "image/jpeg",
|
||||
"type": "Image",
|
||||
"url": "https://media.phpc.social/accounts/headers/109/364/097/179/042/485/original/709da24705260c04.jpg"
|
||||
},
|
||||
"inbox": "https://phpc.social/users/denniskoch/inbox",
|
||||
"indexable": true,
|
||||
"manuallyApprovesFollowers": false,
|
||||
"memorial": false,
|
||||
"name": "Dennis Koch",
|
||||
"outbox": "https://phpc.social/users/denniskoch/outbox",
|
||||
"preferredUsername": "denniskoch",
|
||||
"publicKey": {
|
||||
"id": "https://phpc.social/users/denniskoch#main-key",
|
||||
"owner": "https://phpc.social/users/denniskoch",
|
||||
"publicKeyPem": "-----BEGIN PUBLIC KEY-----\nMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA4dmcSlqLj18gPvuslkmt\nQTniZ8ybO4pgvMvPLYtBuTBUjo49vJ/8Sw6jB5zcKb1haqIdny7Rv/vY3kCdCXcP\nloh1I+jthEgqLT8JpZWGwLGwg9piFhrMGADmt3N8du7HfglzuZ8LlVpnZ8feCw7I\nS2ua/ZCxE47mI45Z3ed2kkFYKWopWWqFn2lan/1OyHrcFKtCvaVjRdvo0UUt2tgl\nvyJI4+zN8FnrCbsMtcbI5nSzfJIrOc4LeaGmLJh+0o2rwoOQZc2487XWbeyfhjsq\nPRBpYN7pfHWQDvzQIN075LHTf9zDFsm6+HqY7Zs5rYxr72rvcX7d9JcP6CasIosY\nqwIDAQAB\n-----END PUBLIC KEY-----\n"
|
||||
},
|
||||
"published": "2022-11-18T00:00:00Z",
|
||||
"summary": "<p>🧑💻 Full Stack Developer<br />🚀 Laravel, Filament, Livewire, Vue, Inertia<br />🌍 Germany</p>",
|
||||
"tag": [],
|
||||
"type": "Person",
|
||||
"url": "https://phpc.social/@denniskoch"
|
||||
}
|
||||
62
test/fixtures/receiver_worker_signature_activity.json
vendored
Normal file
62
test/fixtures/receiver_worker_signature_activity.json
vendored
Normal file
|
|
@ -0,0 +1,62 @@
|
|||
{
|
||||
"@context": [
|
||||
"https://www.w3.org/ns/activitystreams",
|
||||
{
|
||||
"atomUri": "ostatus:atomUri",
|
||||
"blurhash": "toot:blurhash",
|
||||
"conversation": "ostatus:conversation",
|
||||
"focalPoint": {
|
||||
"@container": "@list",
|
||||
"@id": "toot:focalPoint"
|
||||
},
|
||||
"inReplyToAtomUri": "ostatus:inReplyToAtomUri",
|
||||
"ostatus": "http://ostatus.org#",
|
||||
"sensitive": "as:sensitive",
|
||||
"toot": "http://joinmastodon.org/ns#",
|
||||
"votersCount": "toot:votersCount"
|
||||
}
|
||||
],
|
||||
"atomUri": "https://chaos.social/users/distantnative/statuses/109336635639931467",
|
||||
"attachment": [
|
||||
{
|
||||
"blurhash": "UAK1zS00OXIUxuMxIUM{?b-:-;W:Di?b%2M{",
|
||||
"height": 960,
|
||||
"mediaType": "image/jpeg",
|
||||
"name": null,
|
||||
"type": "Document",
|
||||
"url": "https://assets.chaos.social/media_attachments/files/109/336/634/286/114/657/original/2e6122063d8bfb26.jpeg",
|
||||
"width": 346
|
||||
}
|
||||
],
|
||||
"attributedTo": "https://chaos.social/users/distantnative",
|
||||
"cc": [
|
||||
"https://chaos.social/users/distantnative/followers"
|
||||
],
|
||||
"content": "<p>Favorite piece of anthropology meta discourse.</p>",
|
||||
"contentMap": {
|
||||
"en": "<p>Favorite piece of anthropology meta discourse.</p>"
|
||||
},
|
||||
"conversation": "tag:chaos.social,2022-11-13:objectId=71843781:objectType=Conversation",
|
||||
"id": "https://chaos.social/users/distantnative/statuses/109336635639931467",
|
||||
"inReplyTo": null,
|
||||
"inReplyToAtomUri": null,
|
||||
"published": "2022-11-13T13:04:20Z",
|
||||
"replies": {
|
||||
"first": {
|
||||
"items": [],
|
||||
"next": "https://chaos.social/users/distantnative/statuses/109336635639931467/replies?only_other_accounts=true&page=true",
|
||||
"partOf": "https://chaos.social/users/distantnative/statuses/109336635639931467/replies",
|
||||
"type": "CollectionPage"
|
||||
},
|
||||
"id": "https://chaos.social/users/distantnative/statuses/109336635639931467/replies",
|
||||
"type": "Collection"
|
||||
},
|
||||
"sensitive": false,
|
||||
"summary": null,
|
||||
"tag": [],
|
||||
"to": [
|
||||
"https://www.w3.org/ns/activitystreams#Public"
|
||||
],
|
||||
"type": "Note",
|
||||
"url": "https://chaos.social/@distantnative/109336635639931467"
|
||||
}
|
||||
|
|
@ -51,7 +51,6 @@ defmodule Mix.Tasks.Pleroma.ConfigTest do
|
|||
clear_config(:configurable_from_database, true)
|
||||
end
|
||||
|
||||
@tag capture_log: true
|
||||
test "config migration refused when deprecated settings are found" do
|
||||
clear_config([:media_proxy, :whitelist], ["domain_without_scheme.com"])
|
||||
assert config_records() == []
|
||||
|
|
|
|||
|
|
@ -251,7 +251,7 @@ defmodule Mix.Tasks.Pleroma.DatabaseTest do
|
|||
|> Repo.update!()
|
||||
|
||||
{:ok, old_favourite_activity} =
|
||||
CommonAPI.favorite(remote_user2, old_remote_post_activity.id)
|
||||
CommonAPI.favorite(old_remote_post_activity.id, remote_user2)
|
||||
|
||||
old_favourite_activity
|
||||
|> Ecto.Changeset.change(%{local: false, updated_at: old_insert_date})
|
||||
|
|
@ -302,7 +302,7 @@ defmodule Mix.Tasks.Pleroma.DatabaseTest do
|
|||
|> Ecto.Changeset.change(%{local: false, updated_at: old_insert_date})
|
||||
|> Repo.update!()
|
||||
|
||||
{:ok, old_favourite_activity} = CommonAPI.favorite(local_user, old_remote_post3_activity.id)
|
||||
{:ok, old_favourite_activity} = CommonAPI.favorite(old_remote_post3_activity.id, local_user)
|
||||
|
||||
old_favourite_activity
|
||||
|> Ecto.Changeset.change(%{local: true, updated_at: old_insert_date})
|
||||
|
|
@ -586,7 +586,7 @@ defmodule Mix.Tasks.Pleroma.DatabaseTest do
|
|||
{:ok, %{id: id, object: object}} = CommonAPI.post(user, %{status: "test"})
|
||||
{:ok, %{object: object2}} = CommonAPI.post(user, %{status: "test test"})
|
||||
|
||||
CommonAPI.favorite(user2, id)
|
||||
CommonAPI.favorite(id, user2)
|
||||
|
||||
likes = %{
|
||||
"first" =>
|
||||
|
|
|
|||
|
|
@ -249,7 +249,7 @@ defmodule Pleroma.ActivityTest do
|
|||
{:ok, %{id: id, object: %{data: %{"id" => obj_id}}}} =
|
||||
Pleroma.Web.CommonAPI.post(user, %{status: "cofe"})
|
||||
|
||||
Pleroma.Web.CommonAPI.favorite(another, id)
|
||||
Pleroma.Web.CommonAPI.favorite(id, another)
|
||||
|
||||
assert obj_id
|
||||
|> Pleroma.Activity.Queries.by_object_id()
|
||||
|
|
|
|||
|
|
@ -312,7 +312,7 @@ defmodule Pleroma.ConfigDBTest do
|
|||
test "proxy tuple with domain" do
|
||||
assert ConfigDB.to_elixir_types(%{
|
||||
"tuple" => [":proxy_url", %{"tuple" => [":socks5", "domain.com", 1234]}]
|
||||
}) == {:proxy_url, {:socks5, 'domain.com', 1234}}
|
||||
}) == {:proxy_url, {:socks5, ~c"domain.com", 1234}}
|
||||
end
|
||||
|
||||
test "proxy tuple with ip" do
|
||||
|
|
|
|||
|
|
@ -46,7 +46,6 @@ defmodule Pleroma.Gun.ConnectionPoolTest do
|
|||
end
|
||||
end
|
||||
|
||||
@tag :erratic
|
||||
test "connection limit is respected with concurrent requests" do
|
||||
clear_config([:connections_pool, :max_connections]) do
|
||||
clear_config([:connections_pool, :max_connections], 1)
|
||||
|
|
|
|||
|
|
@ -55,23 +55,23 @@ defmodule Pleroma.HTTP.AdapterHelper.GunTest do
|
|||
|
||||
uri = URI.parse("https://some-domain.com")
|
||||
opts = Gun.options([receive_conn: false], uri)
|
||||
assert opts[:proxy] == {'localhost', 8123}
|
||||
assert opts[:proxy] == {~c"localhost", 8123}
|
||||
end
|
||||
|
||||
test "parses tuple proxy scheme host and port" do
|
||||
clear_config([:http, :proxy_url], {:socks, 'localhost', 1234})
|
||||
clear_config([:http, :proxy_url], {:socks, ~c"localhost", 1234})
|
||||
|
||||
uri = URI.parse("https://some-domain.com")
|
||||
opts = Gun.options([receive_conn: false], uri)
|
||||
assert opts[:proxy] == {:socks, 'localhost', 1234}
|
||||
assert opts[:proxy] == {:socks, ~c"localhost", 1234}
|
||||
end
|
||||
|
||||
test "passed opts have more weight than defaults" do
|
||||
clear_config([:http, :proxy_url], {:socks5, 'localhost', 1234})
|
||||
clear_config([:http, :proxy_url], {:socks5, ~c"localhost", 1234})
|
||||
uri = URI.parse("https://some-domain.com")
|
||||
opts = Gun.options([receive_conn: false, proxy: {'example.com', 4321}], uri)
|
||||
opts = Gun.options([receive_conn: false, proxy: {~c"example.com", 4321}], uri)
|
||||
|
||||
assert opts[:proxy] == {'example.com', 4321}
|
||||
assert opts[:proxy] == {~c"example.com", 4321}
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -17,12 +17,12 @@ defmodule Pleroma.HTTP.AdapterHelperTest do
|
|||
end
|
||||
|
||||
test "localhost with port" do
|
||||
assert AdapterHelper.format_proxy("localhost:8123") == {'localhost', 8123}
|
||||
assert AdapterHelper.format_proxy("localhost:8123") == {~c"localhost", 8123}
|
||||
end
|
||||
|
||||
test "tuple" do
|
||||
assert AdapterHelper.format_proxy({:socks4, :localhost, 9050}) ==
|
||||
{:socks4, 'localhost', 9050}
|
||||
{:socks4, ~c"localhost", 9050}
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -404,7 +404,7 @@ defmodule Pleroma.Integration.MastodonWebsocketTest do
|
|||
|
||||
test "receives private statuses", %{user: reading_user, token: token} do
|
||||
user = insert(:user)
|
||||
CommonAPI.follow(reading_user, user)
|
||||
CommonAPI.follow(user, reading_user)
|
||||
|
||||
{:ok, _} = start_socket("?stream=user&access_token=#{token.token}")
|
||||
|
||||
|
|
@ -431,7 +431,7 @@ defmodule Pleroma.Integration.MastodonWebsocketTest do
|
|||
|
||||
test "receives edits", %{user: reading_user, token: token} do
|
||||
user = insert(:user)
|
||||
CommonAPI.follow(reading_user, user)
|
||||
CommonAPI.follow(user, reading_user)
|
||||
|
||||
{:ok, _} = start_socket("?stream=user&access_token=#{token.token}")
|
||||
|
||||
|
|
@ -440,7 +440,7 @@ defmodule Pleroma.Integration.MastodonWebsocketTest do
|
|||
|
||||
assert_receive {:text, _raw_json}, 1_000
|
||||
|
||||
{:ok, _} = CommonAPI.update(user, activity, %{status: "mew mew", visibility: "private"})
|
||||
{:ok, _} = CommonAPI.update(activity, user, %{status: "mew mew", visibility: "private"})
|
||||
|
||||
assert_receive {:text, raw_json}, 1_000
|
||||
|
||||
|
|
@ -459,7 +459,7 @@ defmodule Pleroma.Integration.MastodonWebsocketTest do
|
|||
|
||||
test "receives notifications", %{user: reading_user, token: token} do
|
||||
user = insert(:user)
|
||||
CommonAPI.follow(reading_user, user)
|
||||
CommonAPI.follow(user, reading_user)
|
||||
|
||||
{:ok, _} = start_socket("?stream=user:notification&access_token=#{token.token}")
|
||||
|
||||
|
|
|
|||
|
|
@ -28,13 +28,13 @@ defmodule Pleroma.JobQueueMonitorTest do
|
|||
queue: "background",
|
||||
stack: [
|
||||
{Pleroma.Workers.BackgroundWorker, :perform, 2,
|
||||
[file: 'lib/pleroma/workers/background_worker.ex', line: 31]},
|
||||
[file: ~c"lib/pleroma/workers/background_worker.ex", line: 31]},
|
||||
{Oban.Queue.Executor, :safe_call, 1,
|
||||
[file: 'lib/oban/queue/executor.ex', line: 42]},
|
||||
{:timer, :tc, 3, [file: 'timer.erl', line: 197]},
|
||||
{Oban.Queue.Executor, :call, 2, [file: 'lib/oban/queue/executor.ex', line: 23]},
|
||||
{Task.Supervised, :invoke_mfa, 2, [file: 'lib/task/supervised.ex', line: 90]},
|
||||
{:proc_lib, :init_p_do_apply, 3, [file: 'proc_lib.erl', line: 249]}
|
||||
[file: ~c"lib/oban/queue/executor.ex", line: 42]},
|
||||
{:timer, :tc, 3, [file: ~c"timer.erl", line: 197]},
|
||||
{Oban.Queue.Executor, :call, 2, [file: ~c"lib/oban/queue/executor.ex", line: 23]},
|
||||
{Task.Supervised, :invoke_mfa, 2, [file: ~c"lib/task/supervised.ex", line: 90]},
|
||||
{:proc_lib, :init_p_do_apply, 3, [file: ~c"proc_lib.erl", line: 249]}
|
||||
],
|
||||
worker: "Pleroma.Workers.BackgroundWorker"
|
||||
}}
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ defmodule Pleroma.MigrationHelper.NotificationBackfillTest do
|
|||
{:ok, post} = CommonAPI.post(user, %{status: "yeah, @#{other_user.nickname}"})
|
||||
{:ok, chat} = CommonAPI.post_chat_message(user, other_user, "yo")
|
||||
{:ok, react} = CommonAPI.react_with_emoji(post.id, other_user, "☕")
|
||||
{:ok, like} = CommonAPI.favorite(other_user, post.id)
|
||||
{:ok, like} = CommonAPI.favorite(post.id, other_user)
|
||||
{:ok, react_2} = CommonAPI.react_with_emoji(post.id, other_user, "☕")
|
||||
|
||||
data =
|
||||
|
|
|
|||
|
|
@ -165,7 +165,7 @@ defmodule Pleroma.NotificationTest do
|
|||
{:ok, _activity_two} = CommonAPI.repeat(activity_one.id, repeated_user)
|
||||
|
||||
{:ok, _edit_activity} =
|
||||
CommonAPI.update(user, activity_one, %{
|
||||
CommonAPI.update(activity_one, user, %{
|
||||
status: "hey @#{other_user.nickname}! mew mew"
|
||||
})
|
||||
|
||||
|
|
@ -180,8 +180,8 @@ defmodule Pleroma.NotificationTest do
|
|||
question = insert(:question, user: user1)
|
||||
activity = insert(:question_activity, question: question)
|
||||
|
||||
{:ok, _, _} = CommonAPI.vote(user2, question, [0])
|
||||
{:ok, _, _} = CommonAPI.vote(user3, question, [1])
|
||||
{:ok, _, _} = CommonAPI.vote(question, user2, [0])
|
||||
{:ok, _, _} = CommonAPI.vote(question, user3, [1])
|
||||
|
||||
{:ok, notifications} = Notification.create_poll_notifications(activity)
|
||||
|
||||
|
|
@ -209,7 +209,7 @@ defmodule Pleroma.NotificationTest do
|
|||
notification_settings: %Pleroma.User.NotificationSetting{block_from_strangers: true}
|
||||
)
|
||||
|
||||
CommonAPI.follow(follower, followed)
|
||||
CommonAPI.follow(followed, follower)
|
||||
{:ok, activity} = CommonAPI.post(follower, %{status: "hey @#{followed.nickname}"})
|
||||
refute Notification.create_notification(activity, followed)
|
||||
end
|
||||
|
|
@ -222,7 +222,7 @@ defmodule Pleroma.NotificationTest do
|
|||
notification_settings: %Pleroma.User.NotificationSetting{block_from_strangers: true}
|
||||
)
|
||||
|
||||
CommonAPI.follow(receiver, poster)
|
||||
CommonAPI.follow(poster, receiver)
|
||||
{:ok, activity} = CommonAPI.post(poster, %{status: "hey @#{receiver.nickname}"})
|
||||
assert Notification.create_notification(activity, receiver)
|
||||
end
|
||||
|
|
@ -238,7 +238,7 @@ defmodule Pleroma.NotificationTest do
|
|||
user = insert(:user)
|
||||
subscriber = insert(:user)
|
||||
|
||||
{:ok, _, _, _} = CommonAPI.follow(subscriber, user)
|
||||
{:ok, _, _, _} = CommonAPI.follow(user, subscriber)
|
||||
User.subscribe(subscriber, user)
|
||||
{:ok, status} = CommonAPI.post(user, %{status: "Akariiiin"})
|
||||
{:ok, [_notif]} = Notification.create_notifications(status)
|
||||
|
|
@ -295,7 +295,7 @@ defmodule Pleroma.NotificationTest do
|
|||
insert(:filter, user: user, phrase: "tesla", hide: true)
|
||||
|
||||
{:ok, activity_one} = CommonAPI.post(user, %{status: "wow tesla"})
|
||||
{:ok, activity_two} = CommonAPI.favorite(other_user, activity_one.id)
|
||||
{:ok, activity_two} = CommonAPI.favorite(activity_one.id, other_user)
|
||||
|
||||
{:ok, [notification]} = Notification.create_notifications(activity_two)
|
||||
|
||||
|
|
@ -309,7 +309,7 @@ defmodule Pleroma.NotificationTest do
|
|||
user = insert(:user)
|
||||
followed_user = insert(:user, is_locked: false)
|
||||
|
||||
{:ok, _, _, _activity} = CommonAPI.follow(user, followed_user)
|
||||
{:ok, _, _, _activity} = CommonAPI.follow(followed_user, user)
|
||||
assert FollowingRelationship.following?(user, followed_user)
|
||||
assert [notification] = Notification.for_user(followed_user)
|
||||
|
||||
|
|
@ -324,7 +324,7 @@ defmodule Pleroma.NotificationTest do
|
|||
user = insert(:user)
|
||||
followed_user = insert(:user, is_locked: true)
|
||||
|
||||
{:ok, _, _, _activity} = CommonAPI.follow(user, followed_user)
|
||||
{:ok, _, _, _activity} = CommonAPI.follow(followed_user, user)
|
||||
refute FollowingRelationship.following?(user, followed_user)
|
||||
assert [notification] = Notification.for_user(followed_user)
|
||||
|
||||
|
|
@ -339,19 +339,22 @@ defmodule Pleroma.NotificationTest do
|
|||
|> Repo.preload(:activity)
|
||||
|
||||
assert %{type: "follow"} =
|
||||
NotificationView.render("show.json", notification: notification, for: followed_user)
|
||||
NotificationView.render("show.json",
|
||||
notification: notification,
|
||||
for: followed_user
|
||||
)
|
||||
end
|
||||
|
||||
test "it doesn't create a notification for follow-unfollow-follow chains" do
|
||||
user = insert(:user)
|
||||
followed_user = insert(:user, is_locked: false)
|
||||
|
||||
{:ok, _, _, _activity} = CommonAPI.follow(user, followed_user)
|
||||
{:ok, _, _, _activity} = CommonAPI.follow(followed_user, user)
|
||||
assert FollowingRelationship.following?(user, followed_user)
|
||||
assert [notification] = Notification.for_user(followed_user)
|
||||
|
||||
CommonAPI.unfollow(user, followed_user)
|
||||
{:ok, _, _, _activity_dupe} = CommonAPI.follow(user, followed_user)
|
||||
CommonAPI.unfollow(followed_user, user)
|
||||
{:ok, _, _, _activity_dupe} = CommonAPI.follow(followed_user, user)
|
||||
|
||||
notification_id = notification.id
|
||||
assert [%{id: ^notification_id}] = Notification.for_user(followed_user)
|
||||
|
|
@ -360,7 +363,7 @@ defmodule Pleroma.NotificationTest do
|
|||
test "dismisses the notification on follow request rejection" do
|
||||
user = insert(:user, is_locked: true)
|
||||
follower = insert(:user)
|
||||
{:ok, _, _, _follow_activity} = CommonAPI.follow(follower, user)
|
||||
{:ok, _, _, _follow_activity} = CommonAPI.follow(user, follower)
|
||||
assert [_notification] = Notification.for_user(user)
|
||||
{:ok, _follower} = CommonAPI.reject_follow_request(follower, user)
|
||||
assert [] = Notification.for_user(user)
|
||||
|
|
@ -614,7 +617,7 @@ defmodule Pleroma.NotificationTest do
|
|||
status: "hey @#{other_user.nickname}!"
|
||||
})
|
||||
|
||||
{:ok, activity_two} = CommonAPI.favorite(third_user, activity_one.id)
|
||||
{:ok, activity_two} = CommonAPI.favorite(activity_one.id, third_user)
|
||||
|
||||
enabled_receivers = Notification.get_notified_from_activity(activity_two)
|
||||
|
||||
|
|
@ -690,7 +693,7 @@ defmodule Pleroma.NotificationTest do
|
|||
|
||||
{:ok, activity} = CommonAPI.post(user, %{status: "hey @#{other_user.nickname}!"})
|
||||
|
||||
{:ok, _} = CommonAPI.add_mute(other_user, activity)
|
||||
{:ok, _} = CommonAPI.add_mute(activity, other_user)
|
||||
|
||||
{:ok, same_context_activity} =
|
||||
CommonAPI.post(user, %{
|
||||
|
|
@ -745,7 +748,7 @@ defmodule Pleroma.NotificationTest do
|
|||
{:ok, _activity_two} = CommonAPI.repeat(activity_one.id, repeated_user)
|
||||
|
||||
{:ok, edit_activity} =
|
||||
CommonAPI.update(user, activity_one, %{
|
||||
CommonAPI.update(activity_one, user, %{
|
||||
status: "hey @#{other_user.nickname}! mew mew"
|
||||
})
|
||||
|
||||
|
|
@ -765,7 +768,7 @@ defmodule Pleroma.NotificationTest do
|
|||
|
||||
assert Enum.empty?(Notification.for_user(user))
|
||||
|
||||
{:ok, _} = CommonAPI.favorite(other_user, activity.id)
|
||||
{:ok, _} = CommonAPI.favorite(activity.id, other_user)
|
||||
|
||||
assert length(Notification.for_user(user)) == 1
|
||||
|
||||
|
|
@ -782,7 +785,7 @@ defmodule Pleroma.NotificationTest do
|
|||
|
||||
assert Enum.empty?(Notification.for_user(user))
|
||||
|
||||
{:ok, _} = CommonAPI.favorite(other_user, activity.id)
|
||||
{:ok, _} = CommonAPI.favorite(activity.id, other_user)
|
||||
|
||||
assert length(Notification.for_user(user)) == 1
|
||||
|
||||
|
|
@ -837,7 +840,7 @@ defmodule Pleroma.NotificationTest do
|
|||
|
||||
assert Enum.empty?(Notification.for_user(user))
|
||||
|
||||
{:error, :not_found} = CommonAPI.favorite(other_user, activity.id)
|
||||
{:error, :not_found} = CommonAPI.favorite(activity.id, other_user)
|
||||
|
||||
assert Enum.empty?(Notification.for_user(user))
|
||||
end
|
||||
|
|
@ -1087,7 +1090,7 @@ defmodule Pleroma.NotificationTest do
|
|||
another_user = insert(:user)
|
||||
|
||||
{:ok, activity} = CommonAPI.post(user, %{status: "Give me my cofe!"})
|
||||
{:ok, _} = CommonAPI.favorite(another_user, activity.id)
|
||||
{:ok, _} = CommonAPI.favorite(activity.id, another_user)
|
||||
|
||||
assert length(Notification.for_user(user)) == 1
|
||||
end
|
||||
|
|
@ -1098,7 +1101,7 @@ defmodule Pleroma.NotificationTest do
|
|||
|
||||
insert(:filter, user: followed_user, phrase: "test", hide: true)
|
||||
|
||||
{:ok, _, _, _activity} = CommonAPI.follow(user, followed_user)
|
||||
{:ok, _, _, _activity} = CommonAPI.follow(followed_user, user)
|
||||
refute FollowingRelationship.following?(user, followed_user)
|
||||
assert [notification] = Notification.for_user(followed_user)
|
||||
|
||||
|
|
|
|||
|
|
@ -84,7 +84,6 @@ defmodule Pleroma.Object.FetcherTest do
|
|||
:ok
|
||||
end
|
||||
|
||||
@tag capture_log: true
|
||||
test "it works when fetching the OP actor errors out" do
|
||||
# Here we simulate a case where the author of the OP can't be read
|
||||
assert {:ok, _} =
|
||||
|
|
|
|||
|
|
@ -403,7 +403,7 @@ defmodule Pleroma.ObjectTest do
|
|||
|
||||
user = insert(:user)
|
||||
activity = Activity.get_create_by_object_ap_id(object.data["id"])
|
||||
{:ok, activity} = CommonAPI.favorite(user, activity.id)
|
||||
{:ok, activity} = CommonAPI.favorite(activity.id, user)
|
||||
object = Object.get_by_ap_id(activity.data["object"])
|
||||
|
||||
assert object.data["like_count"] == 1
|
||||
|
|
|
|||
|
|
@ -0,0 +1,43 @@
|
|||
# Pleroma: A lightweight social networking server
|
||||
# Copyright © 2017-2022 Pleroma Authors <https://pleroma.social/>
|
||||
# SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
defmodule Pleroma.Repo.Migrations.PublisherMigrationChangeTest do
|
||||
use Oban.Testing, repo: Pleroma.Repo
|
||||
use Pleroma.DataCase
|
||||
import Pleroma.Factory
|
||||
import Pleroma.Tests.Helpers
|
||||
|
||||
alias Pleroma.Activity
|
||||
alias Pleroma.Workers.PublisherWorker
|
||||
|
||||
setup_all do: require_migration("20240729163838_publisher_job_change")
|
||||
|
||||
describe "up/0" do
|
||||
test "migrates publisher jobs to new format", %{migration: migration} do
|
||||
user = insert(:user)
|
||||
|
||||
%Activity{id: activity_id, data: %{"id" => ap_id}} =
|
||||
insert(:note_activity, user: user)
|
||||
|
||||
{:ok, %{id: job_id}} =
|
||||
PublisherWorker.new(%{
|
||||
"actor_id" => user.id,
|
||||
"json" => "{}",
|
||||
"id" => ap_id,
|
||||
"inbox" => "https://example.com/inbox",
|
||||
"unreachable_since" => nil
|
||||
})
|
||||
|> Oban.insert()
|
||||
|
||||
assert [%{id: ^job_id, args: %{"id" => ^ap_id}}] = all_enqueued(worker: PublisherWorker)
|
||||
|
||||
assert migration.up() == :ok
|
||||
|
||||
assert_enqueued(
|
||||
worker: PublisherWorker,
|
||||
args: %{"id" => ap_id, "activity_id" => activity_id}
|
||||
)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -18,7 +18,7 @@ defmodule Pleroma.ResilienceTest do
|
|||
other_user = insert(:user)
|
||||
|
||||
{:ok, post_one} = CommonAPI.post(user, %{status: "Here is a post"})
|
||||
{:ok, like} = CommonAPI.favorite(other_user, post_one.id)
|
||||
{:ok, like} = CommonAPI.favorite(post_one.id, other_user)
|
||||
|
||||
%{
|
||||
user: user,
|
||||
|
|
@ -90,7 +90,7 @@ defmodule Pleroma.ResilienceTest do
|
|||
|> json_response(200)
|
||||
|
||||
# Favoriting again doesn't hurt
|
||||
{:ok, _like_two} = CommonAPI.favorite(other_user, post.id)
|
||||
{:ok, _like_two} = CommonAPI.favorite(post.id, other_user)
|
||||
|
||||
post = Repo.get(Activity, post.id)
|
||||
|
||||
|
|
|
|||
|
|
@ -73,8 +73,8 @@ defmodule Pleroma.StatsTest do
|
|||
user = insert(:user)
|
||||
other_user = insert(:user)
|
||||
{:ok, activity} = CommonAPI.post(user, %{visibility: "public", status: "hey"})
|
||||
_ = CommonAPI.follow(user, other_user)
|
||||
CommonAPI.favorite(other_user, activity.id)
|
||||
_ = CommonAPI.follow(other_user, user)
|
||||
CommonAPI.favorite(activity.id, other_user)
|
||||
CommonAPI.repeat(activity.id, other_user)
|
||||
|
||||
assert %{"direct" => 0, "private" => 0, "public" => 1, "unlisted" => 0} =
|
||||
|
|
|
|||
|
|
@ -9,29 +9,31 @@ defmodule Pleroma.Upload.Filter.Exiftool.StripLocationTest do
|
|||
test "apply exiftool filter" do
|
||||
assert Pleroma.Utils.command_available?("exiftool")
|
||||
|
||||
File.cp!(
|
||||
"test/fixtures/DSCN0010.jpg",
|
||||
"test/fixtures/DSCN0010_tmp.jpg"
|
||||
)
|
||||
~w{jpg png}
|
||||
|> Enum.map(fn type ->
|
||||
File.cp!(
|
||||
"test/fixtures/DSCN0010.#{type}",
|
||||
"test/fixtures/DSCN0010_tmp.#{type}"
|
||||
)
|
||||
|
||||
upload = %Pleroma.Upload{
|
||||
name: "image_with_GPS_data.jpg",
|
||||
content_type: "image/jpeg",
|
||||
path: Path.absname("test/fixtures/DSCN0010.jpg"),
|
||||
tempfile: Path.absname("test/fixtures/DSCN0010_tmp.jpg")
|
||||
}
|
||||
upload = %Pleroma.Upload{
|
||||
name: "image_with_GPS_data.#{type}",
|
||||
content_type: "image/jpeg",
|
||||
path: Path.absname("test/fixtures/DSCN0010.#{type}"),
|
||||
tempfile: Path.absname("test/fixtures/DSCN0010_tmp.#{type}")
|
||||
}
|
||||
|
||||
assert Filter.Exiftool.StripLocation.filter(upload) == {:ok, :filtered}
|
||||
assert Filter.Exiftool.StripLocation.filter(upload) == {:ok, :filtered}
|
||||
|
||||
{exif_original, 0} = System.cmd("exiftool", ["test/fixtures/DSCN0010.jpg"])
|
||||
{exif_filtered, 0} = System.cmd("exiftool", ["test/fixtures/DSCN0010_tmp.jpg"])
|
||||
{exif_original, 0} = System.cmd("exiftool", ["test/fixtures/DSCN0010.#{type}"])
|
||||
{exif_filtered, 0} = System.cmd("exiftool", ["test/fixtures/DSCN0010_tmp.#{type}"])
|
||||
|
||||
refute exif_original == exif_filtered
|
||||
assert String.match?(exif_original, ~r/GPS/)
|
||||
refute String.match?(exif_filtered, ~r/GPS/)
|
||||
assert String.match?(exif_original, ~r/GPS/)
|
||||
refute String.match?(exif_filtered, ~r/GPS/)
|
||||
end)
|
||||
end
|
||||
|
||||
test "verify webp, heic, svg files are skipped" do
|
||||
test "verify webp, heic, svg files are skipped" do
|
||||
uploads =
|
||||
~w{webp heic svg svg+xml}
|
||||
|> Enum.map(fn type ->
|
||||
|
|
|
|||
|
|
@ -1,51 +0,0 @@
|
|||
# Pleroma: A lightweight social networking server
|
||||
# Copyright © 2017-2023 Pleroma Authors <https://pleroma.social/>
|
||||
# SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
defmodule Pleroma.User.BackupAsyncTest do
|
||||
use Pleroma.DataCase, async: true
|
||||
|
||||
import Pleroma.Factory
|
||||
import Mox
|
||||
|
||||
alias Pleroma.UnstubbedConfigMock, as: ConfigMock
|
||||
alias Pleroma.User.Backup
|
||||
alias Pleroma.User.Backup.ProcessorMock
|
||||
|
||||
setup do
|
||||
user = insert(:user, %{nickname: "cofe", name: "Cofe", ap_id: "http://cofe.io/users/cofe"})
|
||||
|
||||
{:ok, backup} = user |> Backup.new() |> Repo.insert()
|
||||
%{backup: backup}
|
||||
end
|
||||
|
||||
@tag capture_log: true
|
||||
test "it handles unrecoverable exceptions", %{backup: backup} do
|
||||
ProcessorMock
|
||||
|> expect(:do_process, fn _, _ ->
|
||||
raise "mock exception"
|
||||
end)
|
||||
|
||||
ConfigMock
|
||||
|> stub_with(Pleroma.Config)
|
||||
|
||||
{:error, %{backup: backup, reason: :exit}} = Backup.process(backup, ProcessorMock)
|
||||
|
||||
assert backup.state == :failed
|
||||
end
|
||||
|
||||
@tag capture_log: true
|
||||
test "it handles timeouts", %{backup: backup} do
|
||||
ProcessorMock
|
||||
|> expect(:do_process, fn _, _ ->
|
||||
Process.sleep(:timer.seconds(4))
|
||||
end)
|
||||
|
||||
ConfigMock
|
||||
|> expect(:get, fn [Pleroma.User.Backup, :process_wait_time] -> :timer.seconds(2) end)
|
||||
|
||||
{:error, %{backup: backup, reason: :timeout}} = Backup.process(backup, ProcessorMock)
|
||||
|
||||
assert backup.state == :failed
|
||||
end
|
||||
end
|
||||
|
|
@ -6,7 +6,6 @@ defmodule Pleroma.User.BackupTest do
|
|||
use Oban.Testing, repo: Pleroma.Repo
|
||||
use Pleroma.DataCase
|
||||
|
||||
import Mock
|
||||
import Pleroma.Factory
|
||||
import Swoosh.TestAssertions
|
||||
import Mox
|
||||
|
|
@ -16,7 +15,6 @@ defmodule Pleroma.User.BackupTest do
|
|||
alias Pleroma.UnstubbedConfigMock, as: ConfigMock
|
||||
alias Pleroma.Uploaders.S3.ExAwsMock
|
||||
alias Pleroma.User.Backup
|
||||
alias Pleroma.User.Backup.ProcessorMock
|
||||
alias Pleroma.Web.CommonAPI
|
||||
alias Pleroma.Workers.BackupWorker
|
||||
|
||||
|
|
@ -28,79 +26,56 @@ defmodule Pleroma.User.BackupTest do
|
|||
ConfigMock
|
||||
|> stub_with(Pleroma.Config)
|
||||
|
||||
ProcessorMock
|
||||
|> stub_with(Pleroma.User.Backup.Processor)
|
||||
|
||||
:ok
|
||||
end
|
||||
|
||||
test "it does not requrie enabled email" do
|
||||
clear_config([Pleroma.Emails.Mailer, :enabled], false)
|
||||
user = insert(:user)
|
||||
assert {:ok, _} = Backup.create(user)
|
||||
assert {:ok, _} = Backup.user(user)
|
||||
end
|
||||
|
||||
test "it does not require user's email" do
|
||||
user = insert(:user, %{email: nil})
|
||||
assert {:ok, _} = Backup.create(user)
|
||||
assert {:ok, _} = Backup.user(user)
|
||||
end
|
||||
|
||||
test "it creates a backup record and an Oban job" do
|
||||
%{id: user_id} = user = insert(:user)
|
||||
assert {:ok, %Oban.Job{args: args}} = Backup.create(user)
|
||||
user = insert(:user)
|
||||
assert {:ok, %Backup{} = backup} = Backup.user(user)
|
||||
assert {:ok, %Oban.Job{args: args}} = Backup.schedule_backup(backup)
|
||||
assert_enqueued(worker: BackupWorker, args: args)
|
||||
|
||||
backup = Backup.get(args["backup_id"])
|
||||
assert %Backup{user_id: ^user_id, processed: false, file_size: 0, state: :pending} = backup
|
||||
backup = Backup.get_by_id(args["backup_id"])
|
||||
assert %Backup{processed: false, file_size: 0} = backup
|
||||
end
|
||||
|
||||
test "it return an error if the export limit is over" do
|
||||
%{id: user_id} = user = insert(:user)
|
||||
user = insert(:user)
|
||||
limit_days = Pleroma.Config.get([Backup, :limit_days])
|
||||
assert {:ok, %Oban.Job{args: args}} = Backup.create(user)
|
||||
backup = Backup.get(args["backup_id"])
|
||||
assert %Backup{user_id: ^user_id, processed: false, file_size: 0} = backup
|
||||
{:ok, first_backup} = Backup.user(user)
|
||||
{:ok, _run_backup} = Backup.run(first_backup)
|
||||
|
||||
assert Backup.create(user) == {:error, "Last export was less than #{limit_days} days ago"}
|
||||
assert Backup.user(user) == {:error, "Last export was less than #{limit_days} days ago"}
|
||||
end
|
||||
|
||||
test "it process a backup record" do
|
||||
clear_config([Pleroma.Upload, :uploader], Pleroma.Uploaders.Local)
|
||||
%{id: user_id} = user = insert(:user)
|
||||
|
||||
assert {:ok, %Oban.Job{args: %{"backup_id" => backup_id} = args}} = Backup.create(user)
|
||||
assert {:ok, backup} = perform_job(BackupWorker, args)
|
||||
assert {:ok, %Backup{id: backup_id}} = Backup.user(user)
|
||||
|
||||
oban_args = %{"op" => "process", "backup_id" => backup_id}
|
||||
|
||||
assert {:ok, backup} = perform_job(BackupWorker, oban_args)
|
||||
assert backup.file_size > 0
|
||||
assert %Backup{id: ^backup_id, processed: true, user_id: ^user_id, state: :complete} = backup
|
||||
assert match?(%Backup{id: ^backup_id, processed: true, user_id: ^user_id}, backup)
|
||||
|
||||
delete_job_args = %{"op" => "delete", "backup_id" => backup_id}
|
||||
|
||||
assert_enqueued(worker: BackupWorker, args: delete_job_args)
|
||||
assert {:ok, backup} = perform_job(BackupWorker, delete_job_args)
|
||||
refute Backup.get(backup_id)
|
||||
|
||||
email = Pleroma.Emails.UserEmail.backup_is_ready_email(backup)
|
||||
|
||||
assert_email_sent(
|
||||
to: {user.name, user.email},
|
||||
html_body: email.html_body
|
||||
)
|
||||
end
|
||||
|
||||
test "it updates states of the backup" do
|
||||
clear_config([Pleroma.Upload, :uploader], Pleroma.Uploaders.Local)
|
||||
%{id: user_id} = user = insert(:user)
|
||||
|
||||
assert {:ok, %Oban.Job{args: %{"backup_id" => backup_id} = args}} = Backup.create(user)
|
||||
assert {:ok, backup} = perform_job(BackupWorker, args)
|
||||
assert backup.file_size > 0
|
||||
assert %Backup{id: ^backup_id, processed: true, user_id: ^user_id, state: :complete} = backup
|
||||
|
||||
delete_job_args = %{"op" => "delete", "backup_id" => backup_id}
|
||||
|
||||
assert_enqueued(worker: BackupWorker, args: delete_job_args)
|
||||
assert {:ok, backup} = perform_job(BackupWorker, delete_job_args)
|
||||
refute Backup.get(backup_id)
|
||||
refute Backup.get_by_id(backup_id)
|
||||
|
||||
email = Pleroma.Emails.UserEmail.backup_is_ready_email(backup)
|
||||
|
||||
|
|
@ -114,10 +89,15 @@ defmodule Pleroma.User.BackupTest do
|
|||
clear_config([Pleroma.Upload, :uploader], Pleroma.Uploaders.Local)
|
||||
%{id: user_id} = user = insert(:user, %{email: nil})
|
||||
|
||||
assert {:ok, %Oban.Job{args: %{"backup_id" => backup_id} = args}} = Backup.create(user)
|
||||
assert {:ok, backup} = perform_job(BackupWorker, args)
|
||||
assert backup.file_size > 0
|
||||
assert %Backup{id: ^backup_id, processed: true, user_id: ^user_id} = backup
|
||||
assert {:ok, %Backup{} = backup} = Backup.user(user)
|
||||
|
||||
expected_args = %{"op" => "process", "backup_id" => backup.id}
|
||||
|
||||
assert_enqueued(worker: BackupWorker, args: %{"backup_id" => backup.id})
|
||||
assert {:ok, completed_backup} = perform_job(BackupWorker, expected_args)
|
||||
assert completed_backup.file_size > 0
|
||||
assert completed_backup.processed
|
||||
assert completed_backup.user_id == user_id
|
||||
|
||||
assert_no_email_sent()
|
||||
end
|
||||
|
|
@ -127,10 +107,13 @@ defmodule Pleroma.User.BackupTest do
|
|||
clear_config([Pleroma.Upload, :uploader], Pleroma.Uploaders.Local)
|
||||
%{id: user_id} = user = insert(:user)
|
||||
|
||||
assert {:ok, %Oban.Job{args: %{"backup_id" => backup_id} = args}} = Backup.create(user)
|
||||
assert {:ok, backup} = perform_job(BackupWorker, args)
|
||||
assert {:ok, %Backup{id: backup_id}} = Backup.user(user)
|
||||
|
||||
oban_args = %{"op" => "process", "backup_id" => backup_id}
|
||||
|
||||
assert {:ok, backup} = perform_job(BackupWorker, oban_args)
|
||||
assert backup.file_size > 0
|
||||
assert %Backup{id: ^backup_id, processed: true, user_id: ^user_id} = backup
|
||||
assert match?(%Backup{id: ^backup_id, processed: true, user_id: ^user_id}, backup)
|
||||
|
||||
assert_no_email_sent()
|
||||
end
|
||||
|
|
@ -139,10 +122,15 @@ defmodule Pleroma.User.BackupTest do
|
|||
clear_config([Pleroma.Upload, :uploader], Pleroma.Uploaders.Local)
|
||||
%{id: user_id} = user = insert(:user, %{email: ""})
|
||||
|
||||
assert {:ok, %Oban.Job{args: %{"backup_id" => backup_id} = args}} = Backup.create(user)
|
||||
assert {:ok, backup} = perform_job(BackupWorker, args)
|
||||
assert {:ok, %Backup{id: backup_id} = backup} = Backup.user(user)
|
||||
|
||||
expected_args = %{"op" => "process", "backup_id" => backup.id}
|
||||
|
||||
assert_enqueued(worker: BackupWorker, args: expected_args)
|
||||
|
||||
assert {:ok, backup} = perform_job(BackupWorker, expected_args)
|
||||
assert backup.file_size > 0
|
||||
assert %Backup{id: ^backup_id, processed: true, user_id: ^user_id} = backup
|
||||
assert match?(%Backup{id: ^backup_id, processed: true, user_id: ^user_id}, backup)
|
||||
|
||||
assert_no_email_sent()
|
||||
end
|
||||
|
|
@ -152,16 +140,13 @@ defmodule Pleroma.User.BackupTest do
|
|||
clear_config([Pleroma.Upload, :uploader], Pleroma.Uploaders.Local)
|
||||
user = insert(:user)
|
||||
|
||||
assert {:ok, job1} = Backup.create(user)
|
||||
|
||||
assert {:ok, %Backup{}} = ObanHelpers.perform(job1)
|
||||
assert {:ok, job2} = Backup.create(user)
|
||||
assert Pleroma.Repo.aggregate(Backup, :count) == 2
|
||||
assert {:ok, backup2} = ObanHelpers.perform(job2)
|
||||
assert {:ok, %{id: backup_one_id}} = Backup.user(user)
|
||||
assert {:ok, %{id: _backup_two_id}} = Backup.user(user)
|
||||
|
||||
# Run the backups
|
||||
ObanHelpers.perform_all()
|
||||
|
||||
assert [^backup2] = Pleroma.Repo.all(Backup)
|
||||
assert_enqueued(worker: BackupWorker, args: %{"op" => "delete", "backup_id" => backup_one_id})
|
||||
end
|
||||
|
||||
test "it creates a zip archive with user data" do
|
||||
|
|
@ -177,18 +162,21 @@ defmodule Pleroma.User.BackupTest do
|
|||
{:ok, %{object: %{data: %{"id" => id3}}} = status3} =
|
||||
CommonAPI.post(user, %{status: "status3"})
|
||||
|
||||
CommonAPI.favorite(user, status1.id)
|
||||
CommonAPI.favorite(user, status2.id)
|
||||
CommonAPI.favorite(status1.id, user)
|
||||
CommonAPI.favorite(status2.id, user)
|
||||
|
||||
Bookmark.create(user.id, status2.id)
|
||||
Bookmark.create(user.id, status3.id)
|
||||
|
||||
CommonAPI.follow(user, other_user)
|
||||
CommonAPI.follow(other_user, user)
|
||||
|
||||
assert {:ok, backup} = user |> Backup.new() |> Repo.insert()
|
||||
assert {:ok, path} = Backup.export(backup, self())
|
||||
assert {:ok, zipfile} = :zip.zip_open(String.to_charlist(path), [:memory])
|
||||
assert {:ok, {'actor.json', json}} = :zip.zip_get('actor.json', zipfile)
|
||||
assert {:ok, backup} = Backup.user(user)
|
||||
assert {:ok, run_backup} = Backup.run(backup)
|
||||
|
||||
tempfile = Path.join([run_backup.tempdir, run_backup.file_name])
|
||||
|
||||
assert {:ok, zipfile} = :zip.zip_open(String.to_charlist(tempfile), [:memory])
|
||||
assert {:ok, {~c"actor.json", json}} = :zip.zip_get(~c"actor.json", zipfile)
|
||||
|
||||
assert %{
|
||||
"@context" => [
|
||||
|
|
@ -213,7 +201,7 @@ defmodule Pleroma.User.BackupTest do
|
|||
"url" => "http://cofe.io/users/cofe"
|
||||
} = Jason.decode!(json)
|
||||
|
||||
assert {:ok, {'outbox.json', json}} = :zip.zip_get('outbox.json', zipfile)
|
||||
assert {:ok, {~c"outbox.json", json}} = :zip.zip_get(~c"outbox.json", zipfile)
|
||||
|
||||
assert %{
|
||||
"@context" => "https://www.w3.org/ns/activitystreams",
|
||||
|
|
@ -244,7 +232,7 @@ defmodule Pleroma.User.BackupTest do
|
|||
"type" => "OrderedCollection"
|
||||
} = Jason.decode!(json)
|
||||
|
||||
assert {:ok, {'likes.json', json}} = :zip.zip_get('likes.json', zipfile)
|
||||
assert {:ok, {~c"likes.json", json}} = :zip.zip_get(~c"likes.json", zipfile)
|
||||
|
||||
assert %{
|
||||
"@context" => "https://www.w3.org/ns/activitystreams",
|
||||
|
|
@ -254,7 +242,7 @@ defmodule Pleroma.User.BackupTest do
|
|||
"type" => "OrderedCollection"
|
||||
} = Jason.decode!(json)
|
||||
|
||||
assert {:ok, {'bookmarks.json', json}} = :zip.zip_get('bookmarks.json', zipfile)
|
||||
assert {:ok, {~c"bookmarks.json", json}} = :zip.zip_get(~c"bookmarks.json", zipfile)
|
||||
|
||||
assert %{
|
||||
"@context" => "https://www.w3.org/ns/activitystreams",
|
||||
|
|
@ -264,7 +252,7 @@ defmodule Pleroma.User.BackupTest do
|
|||
"type" => "OrderedCollection"
|
||||
} = Jason.decode!(json)
|
||||
|
||||
assert {:ok, {'following.json', json}} = :zip.zip_get('following.json', zipfile)
|
||||
assert {:ok, {~c"following.json", json}} = :zip.zip_get(~c"following.json", zipfile)
|
||||
|
||||
assert %{
|
||||
"@context" => "https://www.w3.org/ns/activitystreams",
|
||||
|
|
@ -275,56 +263,34 @@ defmodule Pleroma.User.BackupTest do
|
|||
} = Jason.decode!(json)
|
||||
|
||||
:zip.zip_close(zipfile)
|
||||
File.rm!(path)
|
||||
File.rm_rf!(run_backup.tempdir)
|
||||
end
|
||||
|
||||
test "it counts the correct number processed" do
|
||||
test "correct number processed" do
|
||||
user = insert(:user, %{nickname: "cofe", name: "Cofe", ap_id: "http://cofe.io/users/cofe"})
|
||||
|
||||
Enum.map(1..120, fn i ->
|
||||
{:ok, status} = CommonAPI.post(user, %{status: "status #{i}"})
|
||||
CommonAPI.favorite(user, status.id)
|
||||
CommonAPI.favorite(status.id, user)
|
||||
Bookmark.create(user.id, status.id)
|
||||
end)
|
||||
|
||||
assert {:ok, backup} = user |> Backup.new() |> Repo.insert()
|
||||
{:ok, backup} = Backup.process(backup)
|
||||
{:ok, backup} = Backup.run(backup)
|
||||
|
||||
assert backup.processed_number == 1 + 120 + 120 + 120
|
||||
zip_path = Path.join([backup.tempdir, backup.file_name])
|
||||
|
||||
Backup.delete(backup)
|
||||
end
|
||||
assert {:ok, zipfile} = :zip.zip_open(String.to_charlist(zip_path), [:memory])
|
||||
|
||||
test "it handles errors" do
|
||||
user = insert(:user, %{nickname: "cofe", name: "Cofe", ap_id: "http://cofe.io/users/cofe"})
|
||||
backup_parts = [~c"likes.json", ~c"bookmarks.json", ~c"outbox.json"]
|
||||
|
||||
Enum.map(1..120, fn i ->
|
||||
{:ok, _status} = CommonAPI.post(user, %{status: "status #{i}"})
|
||||
Enum.each(backup_parts, fn part ->
|
||||
assert {:ok, {_part, part_json}} = :zip.zip_get(part, zipfile)
|
||||
{:ok, decoded_part} = Jason.decode(part_json)
|
||||
assert decoded_part["totalItems"] == 120
|
||||
end)
|
||||
|
||||
assert {:ok, backup} = user |> Backup.new() |> Repo.insert()
|
||||
|
||||
with_mock Pleroma.Web.ActivityPub.Transmogrifier,
|
||||
[:passthrough],
|
||||
prepare_outgoing: fn data ->
|
||||
object =
|
||||
data["object"]
|
||||
|> Pleroma.Object.normalize(fetch: false)
|
||||
|> Map.get(:data)
|
||||
|
||||
data = data |> Map.put("object", object)
|
||||
|
||||
if String.contains?(data["object"]["content"], "119"),
|
||||
do: raise(%Postgrex.Error{}),
|
||||
else: {:ok, data}
|
||||
end do
|
||||
{:ok, backup} = Backup.process(backup)
|
||||
assert backup.processed
|
||||
assert backup.state == :complete
|
||||
assert backup.processed_number == 1 + 119
|
||||
|
||||
Backup.delete(backup)
|
||||
end
|
||||
Backup.delete_archive(backup)
|
||||
end
|
||||
|
||||
describe "it uploads and deletes a backup archive" do
|
||||
|
|
@ -337,18 +303,17 @@ defmodule Pleroma.User.BackupTest do
|
|||
{:ok, status1} = CommonAPI.post(user, %{status: "status1"})
|
||||
{:ok, status2} = CommonAPI.post(user, %{status: "status2"})
|
||||
{:ok, status3} = CommonAPI.post(user, %{status: "status3"})
|
||||
CommonAPI.favorite(user, status1.id)
|
||||
CommonAPI.favorite(user, status2.id)
|
||||
CommonAPI.favorite(status1.id, user)
|
||||
CommonAPI.favorite(status2.id, user)
|
||||
Bookmark.create(user.id, status2.id)
|
||||
Bookmark.create(user.id, status3.id)
|
||||
|
||||
assert {:ok, backup} = user |> Backup.new() |> Repo.insert()
|
||||
assert {:ok, path} = Backup.export(backup, self())
|
||||
|
||||
[path: path, backup: backup]
|
||||
[backup: backup]
|
||||
end
|
||||
|
||||
test "S3", %{path: path, backup: backup} do
|
||||
test "S3", %{backup: backup} do
|
||||
clear_config([Pleroma.Upload, :uploader], Pleroma.Uploaders.S3)
|
||||
clear_config([Pleroma.Uploaders.S3, :streaming_enabled], false)
|
||||
|
||||
|
|
@ -358,15 +323,17 @@ defmodule Pleroma.User.BackupTest do
|
|||
%{http_method: :delete} -> {:ok, %{status_code: 204}}
|
||||
end)
|
||||
|
||||
assert {:ok, %Pleroma.Upload{}} = Backup.upload(backup, path)
|
||||
assert {:ok, _backup} = Backup.delete(backup)
|
||||
assert {:ok, backup} = Backup.run(backup)
|
||||
assert {:ok, %Backup{processed: true}} = Backup.upload(backup)
|
||||
assert {:ok, _backup} = Backup.delete_archive(backup)
|
||||
end
|
||||
|
||||
test "Local", %{path: path, backup: backup} do
|
||||
test "Local", %{backup: backup} do
|
||||
clear_config([Pleroma.Upload, :uploader], Pleroma.Uploaders.Local)
|
||||
|
||||
assert {:ok, %Pleroma.Upload{}} = Backup.upload(backup, path)
|
||||
assert {:ok, _backup} = Backup.delete(backup)
|
||||
assert {:ok, backup} = Backup.run(backup)
|
||||
assert {:ok, %Backup{processed: true}} = Backup.upload(backup)
|
||||
assert {:ok, _backup} = Backup.delete_archive(backup)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -182,8 +182,8 @@ defmodule Pleroma.UserTest do
|
|||
locked = insert(:user, is_locked: true)
|
||||
follower = insert(:user)
|
||||
|
||||
CommonAPI.follow(follower, unlocked)
|
||||
CommonAPI.follow(follower, locked)
|
||||
CommonAPI.follow(unlocked, follower)
|
||||
CommonAPI.follow(locked, follower)
|
||||
|
||||
assert [] = User.get_follow_requests(unlocked)
|
||||
assert [activity] = User.get_follow_requests(locked)
|
||||
|
|
@ -196,9 +196,9 @@ defmodule Pleroma.UserTest do
|
|||
pending_follower = insert(:user)
|
||||
accepted_follower = insert(:user)
|
||||
|
||||
CommonAPI.follow(pending_follower, locked)
|
||||
CommonAPI.follow(pending_follower, locked)
|
||||
CommonAPI.follow(accepted_follower, locked)
|
||||
CommonAPI.follow(locked, pending_follower)
|
||||
CommonAPI.follow(locked, pending_follower)
|
||||
CommonAPI.follow(locked, accepted_follower)
|
||||
|
||||
Pleroma.FollowingRelationship.update(accepted_follower, locked, :follow_accept)
|
||||
|
||||
|
|
@ -209,7 +209,7 @@ defmodule Pleroma.UserTest do
|
|||
locked = insert(:user, is_locked: true)
|
||||
pending_follower = insert(:user, %{is_active: false})
|
||||
|
||||
CommonAPI.follow(pending_follower, locked)
|
||||
CommonAPI.follow(locked, pending_follower)
|
||||
|
||||
refute pending_follower.is_active
|
||||
assert [] = User.get_follow_requests(locked)
|
||||
|
|
@ -219,7 +219,7 @@ defmodule Pleroma.UserTest do
|
|||
followed = insert(:user, is_locked: true)
|
||||
follower = insert(:user)
|
||||
|
||||
CommonAPI.follow(follower, followed)
|
||||
CommonAPI.follow(followed, follower)
|
||||
assert [_activity] = User.get_follow_requests(followed)
|
||||
|
||||
{:ok, _user_relationship} = User.block(followed, follower)
|
||||
|
|
@ -926,7 +926,6 @@ defmodule Pleroma.UserTest do
|
|||
assert user == fetched_user
|
||||
end
|
||||
|
||||
@tag capture_log: true
|
||||
test "returns nil if no user could be fetched" do
|
||||
{:error, fetched_user} = User.get_or_fetch_by_nickname("nonexistent@social.heldscal.la")
|
||||
assert fetched_user == "not found nonexistent@social.heldscal.la"
|
||||
|
|
@ -953,9 +952,16 @@ defmodule Pleroma.UserTest do
|
|||
|
||||
{:ok, user} = User.get_or_fetch_by_ap_id("http://mastodon.example.org/users/admin")
|
||||
|
||||
assert user.inbox
|
||||
# Oban job was generated to refresh the stale user
|
||||
assert_enqueued(worker: "Pleroma.Workers.UserRefreshWorker", args: %{"ap_id" => user.ap_id})
|
||||
|
||||
refute user.last_refreshed_at == orig_user.last_refreshed_at
|
||||
# Run job to refresh the user; just capture its output instead of fetching it again
|
||||
assert {:ok, updated_user} =
|
||||
perform_job(Pleroma.Workers.UserRefreshWorker, %{"ap_id" => user.ap_id})
|
||||
|
||||
assert updated_user.inbox
|
||||
|
||||
refute updated_user.last_refreshed_at == orig_user.last_refreshed_at
|
||||
end
|
||||
|
||||
test "if nicknames clash, the old user gets a prefix with the old id to the nickname" do
|
||||
|
|
@ -983,7 +989,6 @@ defmodule Pleroma.UserTest do
|
|||
assert orig_user.nickname == "#{orig_user.id}.admin@mastodon.example.org"
|
||||
end
|
||||
|
||||
@tag capture_log: true
|
||||
test "it returns the old user if stale, but unfetchable" do
|
||||
a_week_ago = NaiveDateTime.add(NaiveDateTime.utc_now(), -604_800)
|
||||
|
||||
|
|
@ -1521,7 +1526,7 @@ defmodule Pleroma.UserTest do
|
|||
|
||||
assert [activity] == ActivityPub.fetch_public_activities(%{}) |> Repo.preload(:bookmark)
|
||||
|
||||
assert [%{activity | thread_muted?: CommonAPI.thread_muted?(user2, activity)}] ==
|
||||
assert [%{activity | thread_muted?: CommonAPI.thread_muted?(activity, user2)}] ==
|
||||
ActivityPub.fetch_activities([user2.ap_id | User.following(user2)], %{
|
||||
user: user2
|
||||
})
|
||||
|
|
@ -1686,8 +1691,8 @@ defmodule Pleroma.UserTest do
|
|||
object_two = insert(:note, user: follower)
|
||||
activity_two = insert(:note_activity, user: follower, note: object_two)
|
||||
|
||||
{:ok, like} = CommonAPI.favorite(user, activity_two.id)
|
||||
{:ok, like_two} = CommonAPI.favorite(follower, activity.id)
|
||||
{:ok, like} = CommonAPI.favorite(activity_two.id, user)
|
||||
{:ok, like_two} = CommonAPI.favorite(activity.id, follower)
|
||||
{:ok, repeat} = CommonAPI.repeat(activity_two.id, user)
|
||||
|
||||
{:ok, job} = User.delete(user)
|
||||
|
|
|
|||
|
|
@ -573,7 +573,6 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubControllerTest do
|
|||
assert Activity.get_by_ap_id(data["id"])
|
||||
end
|
||||
|
||||
@tag capture_log: true
|
||||
test "it inserts an incoming activity into the database" <>
|
||||
"even if we can't fetch the user but have it in our db",
|
||||
%{conn: conn} do
|
||||
|
|
@ -657,7 +656,6 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubControllerTest do
|
|||
assert_receive {:mix_shell, :info, ["https://relay.mastodon.host/actor"]}
|
||||
end
|
||||
|
||||
@tag capture_log: true
|
||||
test "without valid signature, " <>
|
||||
"it only accepts Create activities and requires enabled federation",
|
||||
%{conn: conn} do
|
||||
|
|
@ -1080,7 +1078,6 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubControllerTest do
|
|||
assert Instances.reachable?(sender_host)
|
||||
end
|
||||
|
||||
@tag capture_log: true
|
||||
test "it removes all follower collections but actor's", %{conn: conn} do
|
||||
[actor, recipient] = insert_pair(:user)
|
||||
|
||||
|
|
@ -1143,7 +1140,6 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubControllerTest do
|
|||
assert json_response(ret_conn, 200)
|
||||
end
|
||||
|
||||
@tag capture_log: true
|
||||
test "forwarded report", %{conn: conn} do
|
||||
admin = insert(:user, is_admin: true)
|
||||
actor = insert(:user, local: false)
|
||||
|
|
@ -1219,7 +1215,6 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubControllerTest do
|
|||
)
|
||||
end
|
||||
|
||||
@tag capture_log: true
|
||||
test "forwarded report from mastodon", %{conn: conn} do
|
||||
admin = insert(:user, is_admin: true)
|
||||
actor = insert(:user, local: false)
|
||||
|
|
@ -1229,7 +1224,7 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubControllerTest do
|
|||
|
||||
note = insert(:note_activity, user: reported_user)
|
||||
|
||||
Pleroma.Web.CommonAPI.favorite(another, note.id)
|
||||
Pleroma.Web.CommonAPI.favorite(note.id, another)
|
||||
|
||||
mock_json_body =
|
||||
"test/fixtures/mastodon/application_actor.json"
|
||||
|
|
@ -1407,7 +1402,7 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubControllerTest do
|
|||
|
||||
assert question = Object.normalize(activity, fetch: false)
|
||||
|
||||
{:ok, [activity], _object} = CommonAPI.vote(voter, question, [1])
|
||||
{:ok, [activity], _object} = CommonAPI.vote(question, voter, [1])
|
||||
|
||||
assert outbox_get =
|
||||
conn
|
||||
|
|
@ -1752,7 +1747,7 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubControllerTest do
|
|||
%{conn: conn} do
|
||||
user = insert(:user, hide_followers: true)
|
||||
other_user = insert(:user)
|
||||
{:ok, _other_user, user, _activity} = CommonAPI.follow(other_user, user)
|
||||
{:ok, _other_user, user, _activity} = CommonAPI.follow(user, other_user)
|
||||
|
||||
result =
|
||||
conn
|
||||
|
|
@ -1848,7 +1843,7 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubControllerTest do
|
|||
%{conn: conn} do
|
||||
user = insert(:user, hide_follows: true)
|
||||
other_user = insert(:user)
|
||||
{:ok, user, _other_user, _activity} = CommonAPI.follow(user, other_user)
|
||||
{:ok, user, _other_user, _activity} = CommonAPI.follow(other_user, user)
|
||||
|
||||
result =
|
||||
conn
|
||||
|
|
|
|||
|
|
@ -1038,7 +1038,7 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubTest do
|
|||
refute activity in activities
|
||||
|
||||
followed_user = insert(:user)
|
||||
CommonAPI.follow(user, followed_user)
|
||||
CommonAPI.follow(followed_user, user)
|
||||
{:ok, repeat_activity} = CommonAPI.repeat(activity.id, followed_user)
|
||||
|
||||
activities = ActivityPub.fetch_activities([], %{blocking_user: user, skip_preload: true})
|
||||
|
|
@ -1171,7 +1171,7 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubTest do
|
|||
note_two = insert(:note, data: %{"context" => "suya.."})
|
||||
activity_two = insert(:note_activity, note: note_two)
|
||||
|
||||
{:ok, _activity_two} = CommonAPI.add_mute(user, activity_two)
|
||||
{:ok, _activity_two} = CommonAPI.add_mute(activity_two, user)
|
||||
|
||||
assert [_activity_one] = ActivityPub.fetch_activities([], %{muting_user: user})
|
||||
end
|
||||
|
|
@ -1182,7 +1182,7 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubTest do
|
|||
note_two = insert(:note, data: %{"context" => "suya.."})
|
||||
activity_two = insert(:note_activity, note: note_two)
|
||||
|
||||
{:ok, _activity_two} = CommonAPI.add_mute(user, activity_two)
|
||||
{:ok, _activity_two} = CommonAPI.add_mute(activity_two, user)
|
||||
|
||||
assert [_activity_two, _activity_one] =
|
||||
ActivityPub.fetch_activities([], %{muting_user: user, with_muted: true})
|
||||
|
|
@ -1358,7 +1358,7 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubTest do
|
|||
activity = insert(:note_activity)
|
||||
user = insert(:user)
|
||||
booster = insert(:user)
|
||||
{:ok, _reblog_mute} = CommonAPI.hide_reblogs(user, booster)
|
||||
{:ok, _reblog_mute} = CommonAPI.hide_reblogs(booster, user)
|
||||
|
||||
{:ok, activity} = CommonAPI.repeat(activity.id, booster)
|
||||
|
||||
|
|
@ -1371,8 +1371,8 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubTest do
|
|||
activity = insert(:note_activity)
|
||||
user = insert(:user)
|
||||
booster = insert(:user)
|
||||
{:ok, _reblog_mute} = CommonAPI.hide_reblogs(user, booster)
|
||||
{:ok, _reblog_mute} = CommonAPI.show_reblogs(user, booster)
|
||||
{:ok, _reblog_mute} = CommonAPI.hide_reblogs(booster, user)
|
||||
{:ok, _reblog_mute} = CommonAPI.show_reblogs(booster, user)
|
||||
|
||||
{:ok, activity} = CommonAPI.repeat(activity.id, booster)
|
||||
|
||||
|
|
@ -1452,7 +1452,7 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubTest do
|
|||
follower = insert(:user)
|
||||
followed = insert(:user)
|
||||
|
||||
{:ok, _, _, follow_activity} = CommonAPI.follow(follower, followed)
|
||||
{:ok, _, _, follow_activity} = CommonAPI.follow(followed, follower)
|
||||
|
||||
with_mock(Utils, [:passthrough], maybe_federate: fn _ -> {:error, :reverted} end) do
|
||||
assert {:error, :reverted} = ActivityPub.unfollow(follower, followed)
|
||||
|
|
@ -1469,7 +1469,7 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubTest do
|
|||
follower = insert(:user)
|
||||
followed = insert(:user)
|
||||
|
||||
{:ok, _, _, follow_activity} = CommonAPI.follow(follower, followed)
|
||||
{:ok, _, _, follow_activity} = CommonAPI.follow(followed, follower)
|
||||
{:ok, activity} = ActivityPub.unfollow(follower, followed)
|
||||
|
||||
assert activity.data["type"] == "Undo"
|
||||
|
|
@ -1486,7 +1486,7 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubTest do
|
|||
follower = insert(:user)
|
||||
followed = insert(:user, %{is_locked: true})
|
||||
|
||||
{:ok, _, _, follow_activity} = CommonAPI.follow(follower, followed)
|
||||
{:ok, _, _, follow_activity} = CommonAPI.follow(followed, follower)
|
||||
{:ok, activity} = ActivityPub.unfollow(follower, followed)
|
||||
|
||||
assert activity.data["type"] == "Undo"
|
||||
|
|
@ -1854,14 +1854,14 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubTest do
|
|||
{:ok, a4} = CommonAPI.post(user2, %{status: "Agent Smith "})
|
||||
{:ok, a5} = CommonAPI.post(user1, %{status: "Red or Blue "})
|
||||
|
||||
{:ok, _} = CommonAPI.favorite(user, a4.id)
|
||||
{:ok, _} = CommonAPI.favorite(other_user, a3.id)
|
||||
{:ok, _} = CommonAPI.favorite(user, a3.id)
|
||||
{:ok, _} = CommonAPI.favorite(other_user, a5.id)
|
||||
{:ok, _} = CommonAPI.favorite(user, a5.id)
|
||||
{:ok, _} = CommonAPI.favorite(other_user, a4.id)
|
||||
{:ok, _} = CommonAPI.favorite(user, a1.id)
|
||||
{:ok, _} = CommonAPI.favorite(other_user, a1.id)
|
||||
{:ok, _} = CommonAPI.favorite(a4.id, user)
|
||||
{:ok, _} = CommonAPI.favorite(a3.id, other_user)
|
||||
{:ok, _} = CommonAPI.favorite(a3.id, user)
|
||||
{:ok, _} = CommonAPI.favorite(a5.id, other_user)
|
||||
{:ok, _} = CommonAPI.favorite(a5.id, user)
|
||||
{:ok, _} = CommonAPI.favorite(a4.id, other_user)
|
||||
{:ok, _} = CommonAPI.favorite(a1.id, user)
|
||||
{:ok, _} = CommonAPI.favorite(a1.id, other_user)
|
||||
result = ActivityPub.fetch_favourites(user)
|
||||
|
||||
assert Enum.map(result, & &1.id) == [a1.id, a5.id, a3.id, a4.id]
|
||||
|
|
@ -2705,7 +2705,6 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubTest do
|
|||
assert user.name == " "
|
||||
end
|
||||
|
||||
@tag capture_log: true
|
||||
test "pin_data_from_featured_collection will ignore unsupported values" do
|
||||
assert %{} ==
|
||||
ActivityPub.pin_data_from_featured_collection(%{
|
||||
|
|
|
|||
|
|
@ -318,7 +318,7 @@ defmodule Pleroma.Web.ActivityPub.MRF.SimplePolicyTest do
|
|||
following_user = insert(:user)
|
||||
non_following_user = insert(:user)
|
||||
|
||||
{:ok, _, _, _} = CommonAPI.follow(following_user, actor)
|
||||
{:ok, _, _, _} = CommonAPI.follow(actor, following_user)
|
||||
|
||||
activity = %{
|
||||
"actor" => actor.ap_id,
|
||||
|
|
|
|||
|
|
@ -65,7 +65,6 @@ defmodule Pleroma.Web.ActivityPub.MRFTest do
|
|||
refute MRF.subdomain_match?(regexes, "example.com")
|
||||
end
|
||||
|
||||
@tag capture_log: true
|
||||
test "logs sensible error on accidental wildcard" do
|
||||
assert_raise Regex.CompileError, fn ->
|
||||
assert capture_log(MRF.subdomains_regex(["*unsafe.tld"])) =~
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@ defmodule Pleroma.Web.ActivityPub.ObjectValidators.ArticleNotePageValidatorTest
|
|||
setup do
|
||||
user = insert(:user)
|
||||
{:ok, activity} = Pleroma.Web.CommonAPI.post(user, %{status: "mew mew :dinosaur:"})
|
||||
{:ok, edit} = Pleroma.Web.CommonAPI.update(user, activity, %{status: "edited :blank:"})
|
||||
{:ok, edit} = Pleroma.Web.CommonAPI.update(activity, user, %{status: "edited :blank:"})
|
||||
|
||||
{:ok, %{"object" => external_rep}} =
|
||||
Pleroma.Web.ActivityPub.Transmogrifier.prepare_outgoing(edit.data)
|
||||
|
|
|
|||
|
|
@ -94,7 +94,7 @@ defmodule Pleroma.Web.ActivityPub.ObjectValidators.LikeValidationTest do
|
|||
user: user,
|
||||
post_activity: post_activity
|
||||
} do
|
||||
_like = CommonAPI.favorite(user, post_activity.id)
|
||||
_like = CommonAPI.favorite(post_activity.id, user)
|
||||
|
||||
refute LikeValidator.cast_and_validate(valid_like).valid?
|
||||
end
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ defmodule Pleroma.Web.ActivityPub.ObjectValidators.UndoHandlingTest do
|
|||
setup do
|
||||
user = insert(:user)
|
||||
{:ok, post_activity} = CommonAPI.post(user, %{status: "uguu"})
|
||||
{:ok, like} = CommonAPI.favorite(user, post_activity.id)
|
||||
{:ok, like} = CommonAPI.favorite(post_activity.id, user)
|
||||
{:ok, valid_like_undo, []} = Builder.undo(user, like)
|
||||
|
||||
%{user: user, like: like, valid_like_undo: valid_like_undo}
|
||||
|
|
|
|||
|
|
@ -132,7 +132,7 @@ defmodule Pleroma.Web.ActivityPub.ObjectValidators.UpdateHandlingTest do
|
|||
setup do
|
||||
user = insert(:user)
|
||||
{:ok, activity} = Pleroma.Web.CommonAPI.post(user, %{status: "mew mew :dinosaur:"})
|
||||
{:ok, edit} = Pleroma.Web.CommonAPI.update(user, activity, %{status: "edited :blank:"})
|
||||
{:ok, edit} = Pleroma.Web.CommonAPI.update(activity, user, %{status: "edited :blank:"})
|
||||
{:ok, external_rep} = Pleroma.Web.ActivityPub.Transmogrifier.prepare_outgoing(edit.data)
|
||||
%{external_rep: external_rep}
|
||||
end
|
||||
|
|
|
|||
|
|
@ -137,6 +137,7 @@ defmodule Pleroma.Web.ActivityPub.PublisherTest do
|
|||
test "publish to url with with different ports" do
|
||||
inbox80 = "http://42.site/users/nick1/inbox"
|
||||
inbox42 = "http://42.site:42/users/nick1/inbox"
|
||||
activity = insert(:note_activity)
|
||||
|
||||
mock(fn
|
||||
%{method: :post, url: "http://42.site:42/users/nick1/inbox"} ->
|
||||
|
|
@ -146,23 +147,19 @@ defmodule Pleroma.Web.ActivityPub.PublisherTest do
|
|||
{:ok, %Tesla.Env{status: 200, body: "port 80"}}
|
||||
end)
|
||||
|
||||
actor = insert(:user)
|
||||
_actor = insert(:user)
|
||||
|
||||
assert {:ok, %{body: "port 42"}} =
|
||||
Publisher.publish_one(%{
|
||||
inbox: inbox42,
|
||||
json: "{}",
|
||||
actor: actor,
|
||||
id: 1,
|
||||
activity_id: activity.id,
|
||||
unreachable_since: true
|
||||
})
|
||||
|
||||
assert {:ok, %{body: "port 80"}} =
|
||||
Publisher.publish_one(%{
|
||||
inbox: inbox80,
|
||||
json: "{}",
|
||||
actor: actor,
|
||||
id: 1,
|
||||
activity_id: activity.id,
|
||||
unreachable_since: true
|
||||
})
|
||||
end
|
||||
|
|
@ -171,10 +168,13 @@ defmodule Pleroma.Web.ActivityPub.PublisherTest do
|
|||
Instances,
|
||||
[:passthrough],
|
||||
[] do
|
||||
actor = insert(:user)
|
||||
_actor = insert(:user)
|
||||
inbox = "http://200.site/users/nick1/inbox"
|
||||
activity = insert(:note_activity)
|
||||
|
||||
assert {:ok, _} =
|
||||
Publisher.publish_one(%{inbox: inbox, activity_id: activity.id})
|
||||
|
||||
assert {:ok, _} = Publisher.publish_one(%{inbox: inbox, json: "{}", actor: actor, id: 1})
|
||||
assert called(Instances.set_reachable(inbox))
|
||||
end
|
||||
|
||||
|
|
@ -182,15 +182,14 @@ defmodule Pleroma.Web.ActivityPub.PublisherTest do
|
|||
Instances,
|
||||
[:passthrough],
|
||||
[] do
|
||||
actor = insert(:user)
|
||||
_actor = insert(:user)
|
||||
inbox = "http://200.site/users/nick1/inbox"
|
||||
activity = insert(:note_activity)
|
||||
|
||||
assert {:ok, _} =
|
||||
Publisher.publish_one(%{
|
||||
inbox: inbox,
|
||||
json: "{}",
|
||||
actor: actor,
|
||||
id: 1,
|
||||
activity_id: activity.id,
|
||||
unreachable_since: NaiveDateTime.utc_now()
|
||||
})
|
||||
|
||||
|
|
@ -201,31 +200,30 @@ defmodule Pleroma.Web.ActivityPub.PublisherTest do
|
|||
Instances,
|
||||
[:passthrough],
|
||||
[] do
|
||||
actor = insert(:user)
|
||||
_actor = insert(:user)
|
||||
inbox = "http://200.site/users/nick1/inbox"
|
||||
activity = insert(:note_activity)
|
||||
|
||||
assert {:ok, _} =
|
||||
Publisher.publish_one(%{
|
||||
inbox: inbox,
|
||||
json: "{}",
|
||||
actor: actor,
|
||||
id: 1,
|
||||
activity_id: activity.id,
|
||||
unreachable_since: nil
|
||||
})
|
||||
|
||||
refute called(Instances.set_reachable(inbox))
|
||||
end
|
||||
|
||||
@tag capture_log: true
|
||||
test_with_mock "calls `Instances.set_unreachable` on target inbox on non-2xx HTTP response code",
|
||||
Instances,
|
||||
[:passthrough],
|
||||
[] do
|
||||
actor = insert(:user)
|
||||
_actor = insert(:user)
|
||||
inbox = "http://404.site/users/nick1/inbox"
|
||||
activity = insert(:note_activity)
|
||||
|
||||
assert {:discard, _} =
|
||||
Publisher.publish_one(%{inbox: inbox, json: "{}", actor: actor, id: 1})
|
||||
assert {:cancel, _} =
|
||||
Publisher.publish_one(%{inbox: inbox, activity_id: activity.id})
|
||||
|
||||
assert called(Instances.set_unreachable(inbox))
|
||||
end
|
||||
|
|
@ -234,12 +232,16 @@ defmodule Pleroma.Web.ActivityPub.PublisherTest do
|
|||
Instances,
|
||||
[:passthrough],
|
||||
[] do
|
||||
actor = insert(:user)
|
||||
_actor = insert(:user)
|
||||
inbox = "http://connrefused.site/users/nick1/inbox"
|
||||
activity = insert(:note_activity)
|
||||
|
||||
assert capture_log(fn ->
|
||||
assert {:error, _} =
|
||||
Publisher.publish_one(%{inbox: inbox, json: "{}", actor: actor, id: 1})
|
||||
Publisher.publish_one(%{
|
||||
inbox: inbox,
|
||||
activity_id: activity.id
|
||||
})
|
||||
end) =~ "connrefused"
|
||||
|
||||
assert called(Instances.set_unreachable(inbox))
|
||||
|
|
@ -249,10 +251,12 @@ defmodule Pleroma.Web.ActivityPub.PublisherTest do
|
|||
Instances,
|
||||
[:passthrough],
|
||||
[] do
|
||||
actor = insert(:user)
|
||||
_actor = insert(:user)
|
||||
inbox = "http://200.site/users/nick1/inbox"
|
||||
activity = insert(:note_activity)
|
||||
|
||||
assert {:ok, _} = Publisher.publish_one(%{inbox: inbox, json: "{}", actor: actor, id: 1})
|
||||
assert {:ok, _} =
|
||||
Publisher.publish_one(%{inbox: inbox, activity_id: activity.id})
|
||||
|
||||
refute called(Instances.set_unreachable(inbox))
|
||||
end
|
||||
|
|
@ -261,16 +265,15 @@ defmodule Pleroma.Web.ActivityPub.PublisherTest do
|
|||
Instances,
|
||||
[:passthrough],
|
||||
[] do
|
||||
actor = insert(:user)
|
||||
_actor = insert(:user)
|
||||
inbox = "http://connrefused.site/users/nick1/inbox"
|
||||
activity = insert(:note_activity)
|
||||
|
||||
assert capture_log(fn ->
|
||||
assert {:error, _} =
|
||||
Publisher.publish_one(%{
|
||||
inbox: inbox,
|
||||
json: "{}",
|
||||
actor: actor,
|
||||
id: 1,
|
||||
activity_id: activity.id,
|
||||
unreachable_since: NaiveDateTime.utc_now()
|
||||
})
|
||||
end) =~ "connrefused"
|
||||
|
|
@ -310,8 +313,7 @@ defmodule Pleroma.Web.ActivityPub.PublisherTest do
|
|||
assert not called(
|
||||
Publisher.enqueue_one(%{
|
||||
inbox: "https://domain.com/users/nick1/inbox",
|
||||
actor_id: actor.id,
|
||||
id: note_activity.data["id"]
|
||||
activity_id: note_activity.id
|
||||
})
|
||||
)
|
||||
end
|
||||
|
|
@ -347,8 +349,7 @@ defmodule Pleroma.Web.ActivityPub.PublisherTest do
|
|||
Publisher.enqueue_one(
|
||||
%{
|
||||
inbox: "https://domain.com/users/nick1/inbox",
|
||||
actor_id: actor.id,
|
||||
id: note_activity.data["id"]
|
||||
activity_id: note_activity.id
|
||||
},
|
||||
priority: 1
|
||||
)
|
||||
|
|
@ -371,8 +372,7 @@ defmodule Pleroma.Web.ActivityPub.PublisherTest do
|
|||
Publisher.enqueue_one(
|
||||
%{
|
||||
inbox: :_,
|
||||
actor_id: actor.id,
|
||||
id: note_activity.data["id"]
|
||||
activity_id: note_activity.id
|
||||
},
|
||||
priority: 0
|
||||
)
|
||||
|
|
@ -406,8 +406,7 @@ defmodule Pleroma.Web.ActivityPub.PublisherTest do
|
|||
assert called(
|
||||
Publisher.enqueue_one(%{
|
||||
inbox: "https://domain.com/users/nick1/inbox",
|
||||
actor_id: actor.id,
|
||||
id: note_activity.data["id"]
|
||||
activity_id: note_activity.id
|
||||
})
|
||||
)
|
||||
end
|
||||
|
|
@ -457,8 +456,7 @@ defmodule Pleroma.Web.ActivityPub.PublisherTest do
|
|||
Publisher.enqueue_one(
|
||||
%{
|
||||
inbox: "https://domain.com/users/nick1/inbox",
|
||||
actor_id: actor.id,
|
||||
id: delete.data["id"]
|
||||
activity_id: delete.id
|
||||
},
|
||||
priority: 1
|
||||
)
|
||||
|
|
@ -468,8 +466,7 @@ defmodule Pleroma.Web.ActivityPub.PublisherTest do
|
|||
Publisher.enqueue_one(
|
||||
%{
|
||||
inbox: "https://domain2.com/users/nick1/inbox",
|
||||
actor_id: actor.id,
|
||||
id: delete.data["id"]
|
||||
activity_id: delete.id
|
||||
},
|
||||
priority: 1
|
||||
)
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@ defmodule Pleroma.Web.ActivityPub.RelayTest do
|
|||
test "returns activity" do
|
||||
user = insert(:user)
|
||||
service_actor = Relay.get_actor()
|
||||
CommonAPI.follow(service_actor, user)
|
||||
CommonAPI.follow(user, service_actor)
|
||||
assert "#{user.ap_id}/followers" in User.following(service_actor)
|
||||
assert {:ok, %Activity{} = activity} = Relay.unfollow(user.ap_id)
|
||||
assert activity.actor == "#{Pleroma.Web.Endpoint.url()}/relay"
|
||||
|
|
@ -74,7 +74,7 @@ defmodule Pleroma.Web.ActivityPub.RelayTest do
|
|||
end)
|
||||
|
||||
service_actor = Relay.get_actor()
|
||||
CommonAPI.follow(service_actor, user)
|
||||
CommonAPI.follow(user, service_actor)
|
||||
assert "#{user.ap_id}/followers" in User.following(service_actor)
|
||||
|
||||
assert Pleroma.Repo.get_by(
|
||||
|
|
@ -113,7 +113,6 @@ defmodule Pleroma.Web.ActivityPub.RelayTest do
|
|||
assert Relay.publish(activity) == {:error, "Not implemented"}
|
||||
end
|
||||
|
||||
@tag capture_log: true
|
||||
test "returns error when activity not public" do
|
||||
activity = insert(:direct_note_activity)
|
||||
assert Relay.publish(activity) == {:error, false}
|
||||
|
|
|
|||
|
|
@ -50,7 +50,7 @@ defmodule Pleroma.Web.ActivityPub.SideEffects.DeleteTest do
|
|||
|
||||
{:ok, op} = CommonAPI.post(other_user, %{status: "big oof"})
|
||||
{:ok, post} = CommonAPI.post(user, %{status: "hey", in_reply_to_id: op})
|
||||
{:ok, favorite} = CommonAPI.favorite(user, post.id)
|
||||
{:ok, favorite} = CommonAPI.favorite(post.id, user)
|
||||
object = Object.normalize(post, fetch: false)
|
||||
{:ok, delete_data, _meta} = Builder.delete(user, object.data["id"])
|
||||
{:ok, delete, _meta} = ActivityPub.persist(delete_data, local: true)
|
||||
|
|
|
|||
|
|
@ -516,10 +516,10 @@ defmodule Pleroma.Web.ActivityPub.SideEffectsTest do
|
|||
poster = insert(:user)
|
||||
user = insert(:user)
|
||||
{:ok, post} = CommonAPI.post(poster, %{status: "hey"})
|
||||
{:ok, like} = CommonAPI.favorite(user, post.id)
|
||||
{:ok, like} = CommonAPI.favorite(post.id, user)
|
||||
{:ok, reaction} = CommonAPI.react_with_emoji(post.id, user, "👍")
|
||||
{:ok, announce} = CommonAPI.repeat(post.id, user)
|
||||
{:ok, block} = CommonAPI.block(user, poster)
|
||||
{:ok, block} = CommonAPI.block(poster, user)
|
||||
|
||||
{:ok, undo_data, _meta} = Builder.undo(user, like)
|
||||
{:ok, like_undo, _meta} = ActivityPub.persist(undo_data, local: true)
|
||||
|
|
@ -834,7 +834,7 @@ defmodule Pleroma.Web.ActivityPub.SideEffectsTest do
|
|||
user = insert(:user)
|
||||
followed = insert(:user)
|
||||
|
||||
{:ok, _, _, follow_activity} = CommonAPI.follow(user, followed)
|
||||
{:ok, _, _, follow_activity} = CommonAPI.follow(followed, user)
|
||||
|
||||
{:ok, reject_data, []} = Builder.reject(followed, follow_activity)
|
||||
{:ok, reject, _meta} = ActivityPub.persist(reject_data, local: true)
|
||||
|
|
@ -965,7 +965,7 @@ defmodule Pleroma.Web.ActivityPub.SideEffectsTest do
|
|||
group: group,
|
||||
poster: poster
|
||||
} do
|
||||
{:ok, _} = CommonAPI.block(group, poster)
|
||||
{:ok, _} = CommonAPI.block(poster, group)
|
||||
create_activity_data = make_create.([group])
|
||||
{:ok, create_activity, _meta} = ActivityPub.persist(create_activity_data, local: false)
|
||||
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier.AcceptHandlingTest do
|
|||
{:ok, follower, followed} = User.follow(follower, followed)
|
||||
assert User.following?(follower, followed) == true
|
||||
|
||||
{:ok, _, _, follow_activity} = CommonAPI.follow(follower, followed)
|
||||
{:ok, _, _, follow_activity} = CommonAPI.follow(followed, follower)
|
||||
|
||||
accept_data =
|
||||
File.read!("test/fixtures/mastodon-accept-activity.json")
|
||||
|
|
@ -48,7 +48,7 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier.AcceptHandlingTest do
|
|||
follower = insert(:user)
|
||||
followed = insert(:user, is_locked: true)
|
||||
|
||||
{:ok, _, _, follow_activity} = CommonAPI.follow(follower, followed)
|
||||
{:ok, _, _, follow_activity} = CommonAPI.follow(followed, follower)
|
||||
|
||||
accept_data =
|
||||
File.read!("test/fixtures/mastodon-accept-activity.json")
|
||||
|
|
|
|||
|
|
@ -83,7 +83,6 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier.AnnounceHandlingTest do
|
|||
assert(Activity.get_create_by_object_ap_id(data["object"]))
|
||||
end
|
||||
|
||||
@tag capture_log: true
|
||||
test "it works for incoming announces with an existing activity" do
|
||||
user = insert(:user)
|
||||
{:ok, activity} = CommonAPI.post(user, %{status: "hey"})
|
||||
|
|
@ -136,7 +135,6 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier.AnnounceHandlingTest do
|
|||
assert object.data["content"] == "this is a private toot"
|
||||
end
|
||||
|
||||
@tag capture_log: true
|
||||
test "it rejects incoming announces with an inlined activity from another origin" do
|
||||
Tesla.Mock.mock(fn
|
||||
%{method: :get} -> %Tesla.Env{status: 404, body: ""}
|
||||
|
|
|
|||
|
|
@ -86,7 +86,6 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier.DeleteHandlingTest do
|
|||
assert match?({:error, _}, Transmogrifier.handle_incoming(data))
|
||||
end
|
||||
|
||||
@tag capture_log: true
|
||||
test "it works for incoming user deletes" do
|
||||
%{ap_id: ap_id} = insert(:user, ap_id: "http://mastodon.example.org/users/admin")
|
||||
|
||||
|
|
|
|||
|
|
@ -56,7 +56,6 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier.NoteHandlingTest do
|
|||
assert activity == returned_activity
|
||||
end
|
||||
|
||||
@tag capture_log: true
|
||||
test "it fetches reply-to activities if we don't have them" do
|
||||
data =
|
||||
File.read!("test/fixtures/mastodon-post-activity.json")
|
||||
|
|
@ -104,7 +103,6 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier.NoteHandlingTest do
|
|||
end
|
||||
end
|
||||
|
||||
@tag capture_log: true
|
||||
test "it does not crash if the object in inReplyTo can't be fetched" do
|
||||
data =
|
||||
File.read!("test/fixtures/mastodon-post-activity.json")
|
||||
|
|
@ -581,7 +579,6 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier.NoteHandlingTest do
|
|||
assert modified_object["inReplyTo"] == []
|
||||
end
|
||||
|
||||
@tag capture_log: true
|
||||
test "returns modified object when allowed incoming reply", %{data: data} do
|
||||
object_with_reply =
|
||||
Map.put(
|
||||
|
|
@ -767,7 +764,6 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier.NoteHandlingTest do
|
|||
assert modified.data["context"] == object.data["id"]
|
||||
end
|
||||
|
||||
@tag capture_log: true
|
||||
test "the reply note uses its parent's ID when context is missing and reply is unreachable" do
|
||||
insert(:user, ap_id: "https://mk.absturztau.be/users/8ozbzjs3o8")
|
||||
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier.RejectHandlingTest do
|
|||
followed = insert(:user, is_locked: true)
|
||||
|
||||
{:ok, follower, followed} = User.follow(follower, followed)
|
||||
{:ok, _, _, follow_activity} = CommonAPI.follow(follower, followed)
|
||||
{:ok, _, _, follow_activity} = CommonAPI.follow(followed, follower)
|
||||
|
||||
assert User.following?(follower, followed) == true
|
||||
|
||||
|
|
|
|||
|
|
@ -353,7 +353,7 @@ defmodule Pleroma.Web.ActivityPub.TransmogrifierTest do
|
|||
user = insert(:user)
|
||||
|
||||
{:ok, activity} = CommonAPI.post(user, %{status: "everybody do the dinosaur :dinosaur:"})
|
||||
{:ok, update} = CommonAPI.update(user, activity, %{status: "mew mew :blank:"})
|
||||
{:ok, update} = CommonAPI.update(activity, user, %{status: "mew mew :blank:"})
|
||||
|
||||
{:ok, prepared} = Transmogrifier.prepare_outgoing(update.data)
|
||||
|
||||
|
|
@ -554,7 +554,6 @@ defmodule Pleroma.Web.ActivityPub.TransmogrifierTest do
|
|||
end) =~ "Unsupported URI scheme"
|
||||
end
|
||||
|
||||
@tag capture_log: true
|
||||
test "returns {:ok, %Object{}} for success case" do
|
||||
assert {:ok, %Object{}} =
|
||||
Transmogrifier.get_obj_helper(
|
||||
|
|
|
|||
|
|
@ -215,7 +215,7 @@ defmodule Pleroma.Web.ActivityPub.UtilsTest do
|
|||
})
|
||||
|
||||
object = Object.normalize(activity, fetch: false)
|
||||
{:ok, votes, object} = CommonAPI.vote(other_user, object, [0, 1])
|
||||
{:ok, votes, object} = CommonAPI.vote(object, other_user, [0, 1])
|
||||
assert Enum.sort(Utils.get_existing_votes(other_user.ap_id, object)) == Enum.sort(votes)
|
||||
end
|
||||
|
||||
|
|
@ -233,8 +233,8 @@ defmodule Pleroma.Web.ActivityPub.UtilsTest do
|
|||
})
|
||||
|
||||
object = Object.normalize(activity, fetch: false)
|
||||
{:ok, [vote], object} = CommonAPI.vote(other_user, object, [0])
|
||||
{:ok, _activity} = CommonAPI.favorite(user, activity.id)
|
||||
{:ok, [vote], object} = CommonAPI.vote(object, other_user, [0])
|
||||
{:ok, _activity} = CommonAPI.favorite(activity.id, user)
|
||||
[fetched_vote] = Utils.get_existing_votes(other_user.ap_id, object)
|
||||
assert fetched_vote.id == vote.id
|
||||
end
|
||||
|
|
@ -245,8 +245,8 @@ defmodule Pleroma.Web.ActivityPub.UtilsTest do
|
|||
user = insert(:user, is_locked: true)
|
||||
follower = insert(:user)
|
||||
|
||||
{:ok, _, _, follow_activity} = CommonAPI.follow(follower, user)
|
||||
{:ok, _, _, follow_activity_two} = CommonAPI.follow(follower, user)
|
||||
{:ok, _, _, follow_activity} = CommonAPI.follow(user, follower)
|
||||
{:ok, _, _, follow_activity_two} = CommonAPI.follow(user, follower)
|
||||
|
||||
data =
|
||||
follow_activity_two.data
|
||||
|
|
@ -267,8 +267,8 @@ defmodule Pleroma.Web.ActivityPub.UtilsTest do
|
|||
user = insert(:user)
|
||||
follower = insert(:user)
|
||||
|
||||
{:ok, _, _, follow_activity} = CommonAPI.follow(follower, user)
|
||||
{:ok, _, _, follow_activity_two} = CommonAPI.follow(follower, user)
|
||||
{:ok, _, _, follow_activity} = CommonAPI.follow(user, follower)
|
||||
{:ok, _, _, follow_activity_two} = CommonAPI.follow(user, follower)
|
||||
|
||||
{:ok, follow_activity_two} =
|
||||
Utils.update_follow_state_for_all(follow_activity_two, "reject")
|
||||
|
|
@ -283,8 +283,8 @@ defmodule Pleroma.Web.ActivityPub.UtilsTest do
|
|||
user = insert(:user, is_locked: true)
|
||||
follower = insert(:user)
|
||||
|
||||
{:ok, _, _, follow_activity} = CommonAPI.follow(follower, user)
|
||||
{:ok, _, _, follow_activity_two} = CommonAPI.follow(follower, user)
|
||||
{:ok, _, _, follow_activity} = CommonAPI.follow(user, follower)
|
||||
{:ok, _, _, follow_activity_two} = CommonAPI.follow(user, follower)
|
||||
|
||||
data =
|
||||
follow_activity_two.data
|
||||
|
|
@ -369,7 +369,7 @@ defmodule Pleroma.Web.ActivityPub.UtilsTest do
|
|||
|
||||
user = insert(:user)
|
||||
refute Utils.get_existing_like(user.ap_id, object)
|
||||
{:ok, like_activity} = CommonAPI.favorite(user, note_activity.id)
|
||||
{:ok, like_activity} = CommonAPI.favorite(note_activity.id, user)
|
||||
|
||||
assert ^like_activity = Utils.get_existing_like(user.ap_id, object)
|
||||
end
|
||||
|
|
@ -396,9 +396,9 @@ defmodule Pleroma.Web.ActivityPub.UtilsTest do
|
|||
user1 = insert(:user)
|
||||
user2 = insert(:user)
|
||||
|
||||
assert {:ok, %Activity{} = _} = CommonAPI.block(user1, user2)
|
||||
assert {:ok, %Activity{} = _} = CommonAPI.block(user1, user2)
|
||||
assert {:ok, %Activity{} = activity} = CommonAPI.block(user1, user2)
|
||||
assert {:ok, %Activity{} = _} = CommonAPI.block(user2, user1)
|
||||
assert {:ok, %Activity{} = _} = CommonAPI.block(user2, user1)
|
||||
assert {:ok, %Activity{} = activity} = CommonAPI.block(user2, user1)
|
||||
|
||||
assert Utils.fetch_latest_block(user1, user2) == activity
|
||||
end
|
||||
|
|
@ -560,7 +560,7 @@ defmodule Pleroma.Web.ActivityPub.UtilsTest do
|
|||
target_account = insert(:user)
|
||||
|
||||
{:ok, activity} = CommonAPI.post(posting_account, %{status: "foobar"})
|
||||
{:ok, like} = CommonAPI.favorite(target_account, activity.id)
|
||||
{:ok, like} = CommonAPI.favorite(activity.id, target_account)
|
||||
context = Utils.generate_context_id()
|
||||
content = "foobar"
|
||||
|
||||
|
|
|
|||
|
|
@ -59,7 +59,7 @@ defmodule Pleroma.Web.ActivityPub.ObjectViewTest do
|
|||
object = Object.normalize(note, fetch: false)
|
||||
user = insert(:user)
|
||||
|
||||
{:ok, like_activity} = CommonAPI.favorite(user, note.id)
|
||||
{:ok, like_activity} = CommonAPI.favorite(note.id, user)
|
||||
|
||||
result = ObjectView.render("object.json", %{object: like_activity})
|
||||
|
||||
|
|
|
|||
|
|
@ -138,7 +138,7 @@ defmodule Pleroma.Web.ActivityPub.UserViewTest do
|
|||
test "sets totalItems to zero when followers are hidden" do
|
||||
user = insert(:user)
|
||||
other_user = insert(:user)
|
||||
{:ok, _other_user, user, _activity} = CommonAPI.follow(other_user, user)
|
||||
{:ok, _other_user, user, _activity} = CommonAPI.follow(user, other_user)
|
||||
assert %{"totalItems" => 1} = UserView.render("followers.json", %{user: user})
|
||||
user = Map.merge(user, %{hide_followers_count: true, hide_followers: true})
|
||||
refute UserView.render("followers.json", %{user: user}) |> Map.has_key?("totalItems")
|
||||
|
|
@ -147,7 +147,7 @@ defmodule Pleroma.Web.ActivityPub.UserViewTest do
|
|||
test "sets correct totalItems when followers are hidden but the follower counter is not" do
|
||||
user = insert(:user)
|
||||
other_user = insert(:user)
|
||||
{:ok, _other_user, user, _activity} = CommonAPI.follow(other_user, user)
|
||||
{:ok, _other_user, user, _activity} = CommonAPI.follow(user, other_user)
|
||||
assert %{"totalItems" => 1} = UserView.render("followers.json", %{user: user})
|
||||
user = Map.merge(user, %{hide_followers_count: false, hide_followers: true})
|
||||
assert %{"totalItems" => 1} = UserView.render("followers.json", %{user: user})
|
||||
|
|
@ -158,7 +158,7 @@ defmodule Pleroma.Web.ActivityPub.UserViewTest do
|
|||
test "sets totalItems to zero when follows are hidden" do
|
||||
user = insert(:user)
|
||||
other_user = insert(:user)
|
||||
{:ok, user, _other_user, _activity} = CommonAPI.follow(user, other_user)
|
||||
{:ok, user, _other_user, _activity} = CommonAPI.follow(other_user, user)
|
||||
assert %{"totalItems" => 1} = UserView.render("following.json", %{user: user})
|
||||
user = Map.merge(user, %{hide_follows_count: true, hide_follows: true})
|
||||
assert %{"totalItems" => 0} = UserView.render("following.json", %{user: user})
|
||||
|
|
@ -167,7 +167,7 @@ defmodule Pleroma.Web.ActivityPub.UserViewTest do
|
|||
test "sets correct totalItems when follows are hidden but the follow counter is not" do
|
||||
user = insert(:user)
|
||||
other_user = insert(:user)
|
||||
{:ok, user, _other_user, _activity} = CommonAPI.follow(user, other_user)
|
||||
{:ok, user, _other_user, _activity} = CommonAPI.follow(other_user, user)
|
||||
assert %{"totalItems" => 1} = UserView.render("following.json", %{user: user})
|
||||
user = Map.merge(user, %{hide_follows_count: false, hide_follows: true})
|
||||
assert %{"totalItems" => 1} = UserView.render("following.json", %{user: user})
|
||||
|
|
|
|||
|
|
@ -1096,9 +1096,13 @@ defmodule Pleroma.Web.AdminAPI.AdminAPIControllerTest do
|
|||
|
||||
ObanHelpers.perform_all()
|
||||
|
||||
email = Pleroma.Emails.UserEmail.backup_is_ready_email(backup, admin.id)
|
||||
email = Pleroma.Emails.UserEmail.backup_is_ready_email(backup)
|
||||
|
||||
assert String.contains?(
|
||||
email.html_body,
|
||||
"A full backup of your Pleroma account was requested"
|
||||
)
|
||||
|
||||
assert String.contains?(email.html_body, "Admin @#{admin.nickname} requested a full backup")
|
||||
assert_email_sent(to: {user.name, user.email}, html_body: email.html_body)
|
||||
|
||||
log_message = "@#{admin_nickname} requested account backup for @#{user_nickname}"
|
||||
|
|
|
|||
|
|
@ -194,7 +194,6 @@ defmodule Pleroma.Web.AdminAPI.ConfigControllerTest do
|
|||
|
||||
setup do: clear_config(:configurable_from_database, true)
|
||||
|
||||
@tag capture_log: true
|
||||
test "create new config setting in db", %{conn: conn} do
|
||||
ueberauth = Application.get_env(:ueberauth, Ueberauth)
|
||||
on_exit(fn -> Application.put_env(:ueberauth, Ueberauth, ueberauth) end)
|
||||
|
|
@ -316,7 +315,6 @@ defmodule Pleroma.Web.AdminAPI.ConfigControllerTest do
|
|||
assert Application.get_env(:idna, :key5) == {"string", Pleroma.Captcha.NotReal, []}
|
||||
end
|
||||
|
||||
@tag capture_log: true
|
||||
test "save configs setting without explicit key", %{conn: conn} do
|
||||
adapter = Application.get_env(:http, :adapter)
|
||||
send_user_agent = Application.get_env(:http, :send_user_agent)
|
||||
|
|
@ -611,52 +609,6 @@ defmodule Pleroma.Web.AdminAPI.ConfigControllerTest do
|
|||
]
|
||||
end
|
||||
|
||||
test "saving full setting if value is in full_key_update list", %{conn: conn} do
|
||||
backends = Application.get_env(:logger, :backends)
|
||||
on_exit(fn -> Application.put_env(:logger, :backends, backends) end)
|
||||
|
||||
insert(:config,
|
||||
group: :logger,
|
||||
key: :backends,
|
||||
value: []
|
||||
)
|
||||
|
||||
Pleroma.Config.TransferTask.load_and_update_env([], false)
|
||||
|
||||
assert Application.get_env(:logger, :backends) == []
|
||||
|
||||
conn =
|
||||
conn
|
||||
|> put_req_header("content-type", "application/json")
|
||||
|> post("/api/pleroma/admin/config", %{
|
||||
configs: [
|
||||
%{
|
||||
group: ":logger",
|
||||
key: ":backends",
|
||||
value: [":console"]
|
||||
}
|
||||
]
|
||||
})
|
||||
|
||||
assert json_response_and_validate_schema(conn, 200) == %{
|
||||
"configs" => [
|
||||
%{
|
||||
"group" => ":logger",
|
||||
"key" => ":backends",
|
||||
"value" => [
|
||||
":console"
|
||||
],
|
||||
"db" => [":backends"]
|
||||
}
|
||||
],
|
||||
"need_reboot" => false
|
||||
}
|
||||
|
||||
assert Application.get_env(:logger, :backends) == [
|
||||
:console
|
||||
]
|
||||
end
|
||||
|
||||
test "saving full setting if value is not keyword", %{conn: conn} do
|
||||
insert(:config,
|
||||
group: :tesla,
|
||||
|
|
@ -1229,7 +1181,6 @@ defmodule Pleroma.Web.AdminAPI.ConfigControllerTest do
|
|||
assert ":proxy_url" in db
|
||||
end
|
||||
|
||||
@tag capture_log: true
|
||||
test "doesn't set keys not in the whitelist", %{conn: conn} do
|
||||
clear_config(:database_config_whitelist, [
|
||||
{:pleroma, :key1},
|
||||
|
|
|
|||
|
|
@ -69,8 +69,8 @@ defmodule Pleroma.Web.AdminAPI.UserControllerTest do
|
|||
# Create some activities to check they got deleted later
|
||||
follower = insert(:user)
|
||||
{:ok, _} = CommonAPI.post(user, %{status: "test"})
|
||||
{:ok, _, _, _} = CommonAPI.follow(user, follower)
|
||||
{:ok, _, _, _} = CommonAPI.follow(follower, user)
|
||||
{:ok, _, _, _} = CommonAPI.follow(user, follower)
|
||||
user = Repo.get(User, user.id)
|
||||
assert user.note_count == 1
|
||||
assert user.follower_count == 1
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@ defmodule Pleroma.Web.CommonAPITest do
|
|||
alias Pleroma.Object
|
||||
alias Pleroma.Repo
|
||||
alias Pleroma.Rule
|
||||
alias Pleroma.Tests.ObanHelpers
|
||||
alias Pleroma.UnstubbedConfigMock, as: ConfigMock
|
||||
alias Pleroma.User
|
||||
alias Pleroma.Web.ActivityPub.ActivityPub
|
||||
|
|
@ -22,7 +23,7 @@ defmodule Pleroma.Web.CommonAPITest do
|
|||
alias Pleroma.Web.CommonAPI
|
||||
alias Pleroma.Workers.PollWorker
|
||||
|
||||
import Ecto.Query, only: [from: 2]
|
||||
import Ecto.Query, only: [from: 2, where: 3]
|
||||
import Mock
|
||||
import Mox
|
||||
import Pleroma.Factory
|
||||
|
|
@ -79,8 +80,8 @@ defmodule Pleroma.Web.CommonAPITest do
|
|||
setup do
|
||||
blocker = insert(:user)
|
||||
blocked = insert(:user, local: false)
|
||||
CommonAPI.follow(blocker, blocked)
|
||||
CommonAPI.follow(blocked, blocker)
|
||||
CommonAPI.follow(blocker, blocked)
|
||||
CommonAPI.accept_follow_request(blocker, blocked)
|
||||
CommonAPI.accept_follow_request(blocked, blocked)
|
||||
%{blocker: blocker, blocked: blocked}
|
||||
|
|
@ -94,7 +95,7 @@ defmodule Pleroma.Web.CommonAPITest do
|
|||
assert User.get_follow_state(blocker, blocked) == :follow_accept
|
||||
refute is_nil(Pleroma.Web.ActivityPub.Utils.fetch_latest_follow(blocker, blocked))
|
||||
|
||||
assert {:ok, block} = CommonAPI.block(blocker, blocked)
|
||||
assert {:ok, block} = CommonAPI.block(blocked, blocker)
|
||||
|
||||
assert block.local
|
||||
assert User.blocks?(blocker, blocked)
|
||||
|
|
@ -119,7 +120,7 @@ defmodule Pleroma.Web.CommonAPITest do
|
|||
|
||||
with_mock Pleroma.Web.Federator,
|
||||
publish: fn _ -> nil end do
|
||||
assert {:ok, block} = CommonAPI.block(blocker, blocked)
|
||||
assert {:ok, block} = CommonAPI.block(blocked, blocker)
|
||||
|
||||
assert block.local
|
||||
assert User.blocks?(blocker, blocked)
|
||||
|
|
@ -323,7 +324,7 @@ defmodule Pleroma.Web.CommonAPITest do
|
|||
User.block(blocker, blocked)
|
||||
|
||||
assert User.blocks?(blocker, blocked)
|
||||
assert {:ok, :no_activity} == CommonAPI.unblock(blocker, blocked)
|
||||
assert {:ok, :no_activity} == CommonAPI.unblock(blocked, blocker)
|
||||
refute User.blocks?(blocker, blocked)
|
||||
end
|
||||
end
|
||||
|
|
@ -453,7 +454,7 @@ defmodule Pleroma.Web.CommonAPITest do
|
|||
|
||||
users_serial
|
||||
|> Enum.map(fn user ->
|
||||
CommonAPI.favorite(user, activity.id)
|
||||
CommonAPI.favorite(activity.id, user)
|
||||
end)
|
||||
|
||||
object = Object.get_by_ap_id(activity.data["object"])
|
||||
|
|
@ -462,7 +463,7 @@ defmodule Pleroma.Web.CommonAPITest do
|
|||
users
|
||||
|> Enum.map(fn user ->
|
||||
Task.async(fn ->
|
||||
CommonAPI.favorite(user, activity.id)
|
||||
CommonAPI.favorite(activity.id, user)
|
||||
end)
|
||||
end)
|
||||
|> Enum.map(&Task.await/1)
|
||||
|
|
@ -954,7 +955,7 @@ defmodule Pleroma.Web.CommonAPITest do
|
|||
test "author can repeat own private statuses" do
|
||||
author = insert(:user)
|
||||
follower = insert(:user)
|
||||
CommonAPI.follow(follower, author)
|
||||
CommonAPI.follow(author, follower)
|
||||
|
||||
{:ok, activity} = CommonAPI.post(author, %{status: "cofe", visibility: "private"})
|
||||
|
||||
|
|
@ -973,7 +974,7 @@ defmodule Pleroma.Web.CommonAPITest do
|
|||
|
||||
{:ok, post_activity} = CommonAPI.post(other_user, %{status: "cofe"})
|
||||
|
||||
{:ok, %Activity{data: data}} = CommonAPI.favorite(user, post_activity.id)
|
||||
{:ok, %Activity{data: data}} = CommonAPI.favorite(post_activity.id, user)
|
||||
assert data["type"] == "Like"
|
||||
assert data["actor"] == user.ap_id
|
||||
assert data["object"] == post_activity.data["object"]
|
||||
|
|
@ -993,8 +994,8 @@ defmodule Pleroma.Web.CommonAPITest do
|
|||
other_user = insert(:user)
|
||||
|
||||
{:ok, activity} = CommonAPI.post(other_user, %{status: "cofe"})
|
||||
{:ok, %Activity{}} = CommonAPI.favorite(user, activity.id)
|
||||
assert {:ok, :already_liked} = CommonAPI.favorite(user, activity.id)
|
||||
{:ok, %Activity{}} = CommonAPI.favorite(activity.id, user)
|
||||
assert {:ok, :already_liked} = CommonAPI.favorite(activity.id, user)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -1148,7 +1149,7 @@ defmodule Pleroma.Web.CommonAPITest do
|
|||
}
|
||||
)
|
||||
|
||||
{:ok, favorite_activity} = CommonAPI.favorite(friend2, activity.id)
|
||||
{:ok, favorite_activity} = CommonAPI.favorite(activity.id, friend2)
|
||||
{:ok, repeat_activity} = CommonAPI.repeat(activity.id, friend1)
|
||||
|
||||
assert Repo.aggregate(
|
||||
|
|
@ -1171,8 +1172,8 @@ defmodule Pleroma.Web.CommonAPITest do
|
|||
n.type == "mention" && n.activity_id == reply_activity.id
|
||||
end)
|
||||
|
||||
{:ok, _} = CommonAPI.add_mute(author, activity)
|
||||
assert CommonAPI.thread_muted?(author, activity)
|
||||
{:ok, _} = CommonAPI.add_mute(activity, author)
|
||||
assert CommonAPI.thread_muted?(activity, author)
|
||||
|
||||
assert Repo.aggregate(
|
||||
from(n in Notification, where: n.seen == false and n.user_id == ^friend1.id),
|
||||
|
|
@ -1196,13 +1197,13 @@ defmodule Pleroma.Web.CommonAPITest do
|
|||
end
|
||||
|
||||
test "add mute", %{user: user, activity: activity} do
|
||||
{:ok, _} = CommonAPI.add_mute(user, activity)
|
||||
assert CommonAPI.thread_muted?(user, activity)
|
||||
{:ok, _} = CommonAPI.add_mute(activity, user)
|
||||
assert CommonAPI.thread_muted?(activity, user)
|
||||
end
|
||||
|
||||
test "add expiring mute", %{user: user, activity: activity} do
|
||||
{:ok, _} = CommonAPI.add_mute(user, activity, %{expires_in: 60})
|
||||
assert CommonAPI.thread_muted?(user, activity)
|
||||
{:ok, _} = CommonAPI.add_mute(activity, user, %{expires_in: 60})
|
||||
assert CommonAPI.thread_muted?(activity, user)
|
||||
|
||||
worker = Pleroma.Workers.MuteExpireWorker
|
||||
args = %{"op" => "unmute_conversation", "user_id" => user.id, "activity_id" => activity.id}
|
||||
|
|
@ -1213,24 +1214,24 @@ defmodule Pleroma.Web.CommonAPITest do
|
|||
)
|
||||
|
||||
assert :ok = perform_job(worker, args)
|
||||
refute CommonAPI.thread_muted?(user, activity)
|
||||
refute CommonAPI.thread_muted?(activity, user)
|
||||
end
|
||||
|
||||
test "remove mute", %{user: user, activity: activity} do
|
||||
CommonAPI.add_mute(user, activity)
|
||||
{:ok, _} = CommonAPI.remove_mute(user, activity)
|
||||
refute CommonAPI.thread_muted?(user, activity)
|
||||
CommonAPI.add_mute(activity, user)
|
||||
{:ok, _} = CommonAPI.remove_mute(activity, user)
|
||||
refute CommonAPI.thread_muted?(activity, user)
|
||||
end
|
||||
|
||||
test "remove mute by ids", %{user: user, activity: activity} do
|
||||
CommonAPI.add_mute(user, activity)
|
||||
{:ok, _} = CommonAPI.remove_mute(user.id, activity.id)
|
||||
refute CommonAPI.thread_muted?(user, activity)
|
||||
CommonAPI.add_mute(activity, user)
|
||||
{:ok, _} = CommonAPI.remove_mute(activity.id, user.id)
|
||||
refute CommonAPI.thread_muted?(activity, user)
|
||||
end
|
||||
|
||||
test "check that mutes can't be duplicate", %{user: user, activity: activity} do
|
||||
CommonAPI.add_mute(user, activity)
|
||||
{:error, _} = CommonAPI.add_mute(user, activity)
|
||||
CommonAPI.add_mute(activity, user)
|
||||
{:error, _} = CommonAPI.add_mute(activity, user)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -1403,14 +1404,14 @@ defmodule Pleroma.Web.CommonAPITest do
|
|||
end
|
||||
|
||||
test "add a reblog mute", %{muter: muter, muted: muted} do
|
||||
{:ok, _reblog_mute} = CommonAPI.hide_reblogs(muter, muted)
|
||||
{:ok, _reblog_mute} = CommonAPI.hide_reblogs(muted, muter)
|
||||
|
||||
assert User.showing_reblogs?(muter, muted) == false
|
||||
end
|
||||
|
||||
test "remove a reblog mute", %{muter: muter, muted: muted} do
|
||||
{:ok, _reblog_mute} = CommonAPI.hide_reblogs(muter, muted)
|
||||
{:ok, _reblog_mute} = CommonAPI.show_reblogs(muter, muted)
|
||||
{:ok, _reblog_mute} = CommonAPI.hide_reblogs(muted, muter)
|
||||
{:ok, _reblog_mute} = CommonAPI.show_reblogs(muted, muter)
|
||||
|
||||
assert User.showing_reblogs?(muter, muted) == true
|
||||
end
|
||||
|
|
@ -1419,7 +1420,7 @@ defmodule Pleroma.Web.CommonAPITest do
|
|||
describe "follow/2" do
|
||||
test "directly follows a non-locked local user" do
|
||||
[follower, followed] = insert_pair(:user)
|
||||
{:ok, follower, followed, _} = CommonAPI.follow(follower, followed)
|
||||
{:ok, follower, followed, _} = CommonAPI.follow(followed, follower)
|
||||
|
||||
assert User.following?(follower, followed)
|
||||
end
|
||||
|
|
@ -1428,24 +1429,24 @@ defmodule Pleroma.Web.CommonAPITest do
|
|||
describe "unfollow/2" do
|
||||
test "also unsubscribes a user" do
|
||||
[follower, followed] = insert_pair(:user)
|
||||
{:ok, follower, followed, _} = CommonAPI.follow(follower, followed)
|
||||
{:ok, follower, followed, _} = CommonAPI.follow(followed, follower)
|
||||
{:ok, _subscription} = User.subscribe(follower, followed)
|
||||
|
||||
assert User.subscribed_to?(follower, followed)
|
||||
|
||||
{:ok, follower} = CommonAPI.unfollow(follower, followed)
|
||||
{:ok, follower} = CommonAPI.unfollow(followed, follower)
|
||||
|
||||
refute User.subscribed_to?(follower, followed)
|
||||
end
|
||||
|
||||
test "also unpins a user" do
|
||||
[follower, followed] = insert_pair(:user)
|
||||
{:ok, follower, followed, _} = CommonAPI.follow(follower, followed)
|
||||
{:ok, follower, followed, _} = CommonAPI.follow(followed, follower)
|
||||
{:ok, _endorsement} = User.endorse(follower, followed)
|
||||
|
||||
assert User.endorses?(follower, followed)
|
||||
|
||||
{:ok, follower} = CommonAPI.unfollow(follower, followed)
|
||||
{:ok, follower} = CommonAPI.unfollow(followed, follower)
|
||||
|
||||
refute User.endorses?(follower, followed)
|
||||
end
|
||||
|
|
@ -1455,10 +1456,10 @@ defmodule Pleroma.Web.CommonAPITest do
|
|||
followed = insert(:user, is_locked: true)
|
||||
|
||||
assert {:ok, follower, followed, %{id: activity_id, data: %{"state" => "pending"}}} =
|
||||
CommonAPI.follow(follower, followed)
|
||||
CommonAPI.follow(followed, follower)
|
||||
|
||||
assert User.get_follow_state(follower, followed) == :follow_pending
|
||||
assert {:ok, follower} = CommonAPI.unfollow(follower, followed)
|
||||
assert {:ok, follower} = CommonAPI.unfollow(followed, follower)
|
||||
assert User.get_follow_state(follower, followed) == nil
|
||||
|
||||
assert %{id: ^activity_id, data: %{"state" => "cancelled"}} =
|
||||
|
|
@ -1477,10 +1478,10 @@ defmodule Pleroma.Web.CommonAPITest do
|
|||
followed = insert(:user, is_locked: true, local: false)
|
||||
|
||||
assert {:ok, follower, followed, %{id: activity_id, data: %{"state" => "pending"}}} =
|
||||
CommonAPI.follow(follower, followed)
|
||||
CommonAPI.follow(followed, follower)
|
||||
|
||||
assert User.get_follow_state(follower, followed) == :follow_pending
|
||||
assert {:ok, follower} = CommonAPI.unfollow(follower, followed)
|
||||
assert {:ok, follower} = CommonAPI.unfollow(followed, follower)
|
||||
assert User.get_follow_state(follower, followed) == nil
|
||||
|
||||
assert %{id: ^activity_id, data: %{"state" => "cancelled"}} =
|
||||
|
|
@ -1501,9 +1502,9 @@ defmodule Pleroma.Web.CommonAPITest do
|
|||
follower = insert(:user)
|
||||
follower_two = insert(:user)
|
||||
|
||||
{:ok, _, _, follow_activity} = CommonAPI.follow(follower, user)
|
||||
{:ok, _, _, follow_activity_two} = CommonAPI.follow(follower, user)
|
||||
{:ok, _, _, follow_activity_three} = CommonAPI.follow(follower_two, user)
|
||||
{:ok, _, _, follow_activity} = CommonAPI.follow(user, follower)
|
||||
{:ok, _, _, follow_activity_two} = CommonAPI.follow(user, follower)
|
||||
{:ok, _, _, follow_activity_three} = CommonAPI.follow(user, follower_two)
|
||||
|
||||
assert follow_activity.data["state"] == "pending"
|
||||
assert follow_activity_two.data["state"] == "pending"
|
||||
|
|
@ -1521,9 +1522,9 @@ defmodule Pleroma.Web.CommonAPITest do
|
|||
follower = insert(:user)
|
||||
follower_two = insert(:user)
|
||||
|
||||
{:ok, _, _, follow_activity} = CommonAPI.follow(follower, user)
|
||||
{:ok, _, _, follow_activity_two} = CommonAPI.follow(follower, user)
|
||||
{:ok, _, _, follow_activity_three} = CommonAPI.follow(follower_two, user)
|
||||
{:ok, _, _, follow_activity} = CommonAPI.follow(user, follower)
|
||||
{:ok, _, _, follow_activity_two} = CommonAPI.follow(user, follower)
|
||||
{:ok, _, _, follow_activity_three} = CommonAPI.follow(user, follower_two)
|
||||
|
||||
assert follow_activity.data["state"] == "pending"
|
||||
assert follow_activity_two.data["state"] == "pending"
|
||||
|
|
@ -1558,9 +1559,9 @@ defmodule Pleroma.Web.CommonAPITest do
|
|||
|
||||
object = Object.normalize(activity, fetch: false)
|
||||
|
||||
{:ok, _, object} = CommonAPI.vote(other_user, object, [0])
|
||||
{:ok, _, object} = CommonAPI.vote(object, other_user, [0])
|
||||
|
||||
assert {:error, "Already voted"} == CommonAPI.vote(other_user, object, [1])
|
||||
assert {:error, "Already voted"} == CommonAPI.vote(object, other_user, [1])
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -1694,7 +1695,7 @@ defmodule Pleroma.Web.CommonAPITest do
|
|||
|
||||
with_mock Pleroma.Web.Federator, publish: fn _ -> :ok end do
|
||||
assert {:ok, %Activity{data: %{"type" => "Like"}} = activity} =
|
||||
CommonAPI.favorite(user, activity.id)
|
||||
CommonAPI.favorite(activity.id, user)
|
||||
|
||||
assert Visibility.local_public?(activity)
|
||||
refute called(Pleroma.Web.Federator.publish(activity))
|
||||
|
|
@ -1707,7 +1708,7 @@ defmodule Pleroma.Web.CommonAPITest do
|
|||
|
||||
{:ok, activity} = CommonAPI.post(other_user, %{status: "cofe", visibility: "local"})
|
||||
|
||||
{:ok, %Activity{}} = CommonAPI.favorite(user, activity.id)
|
||||
{:ok, %Activity{}} = CommonAPI.favorite(activity.id, user)
|
||||
|
||||
with_mock Pleroma.Web.Federator, publish: fn _ -> :ok end do
|
||||
assert {:ok, activity} = CommonAPI.unfavorite(activity.id, user)
|
||||
|
|
@ -1752,7 +1753,7 @@ defmodule Pleroma.Web.CommonAPITest do
|
|||
user = insert(:user)
|
||||
{:ok, activity} = CommonAPI.post(user, %{status: "foo1", spoiler_text: "title 1"})
|
||||
|
||||
{:ok, updated} = CommonAPI.update(user, activity, %{status: "updated 2"})
|
||||
{:ok, updated} = CommonAPI.update(activity, user, %{status: "updated 2"})
|
||||
|
||||
updated_object = Object.normalize(updated)
|
||||
assert updated_object.data["content"] == "updated 2"
|
||||
|
|
@ -1766,7 +1767,7 @@ defmodule Pleroma.Web.CommonAPITest do
|
|||
{:ok, activity} =
|
||||
CommonAPI.post(user, %{status: "foo1", spoiler_text: "title 1", visibility: "private"})
|
||||
|
||||
{:ok, updated} = CommonAPI.update(user, activity, %{status: "updated 2"})
|
||||
{:ok, updated} = CommonAPI.update(activity, user, %{status: "updated 2"})
|
||||
|
||||
updated_object = Object.normalize(updated)
|
||||
assert updated_object.data["content"] == "updated 2"
|
||||
|
|
@ -1783,7 +1784,7 @@ defmodule Pleroma.Web.CommonAPITest do
|
|||
{:ok, activity} =
|
||||
CommonAPI.post(user, %{status: "foo1", spoiler_text: "title 1 :#{emoji1}:"})
|
||||
|
||||
{:ok, updated} = CommonAPI.update(user, activity, %{status: "updated 2 :#{emoji2}:"})
|
||||
{:ok, updated} = CommonAPI.update(activity, user, %{status: "updated 2 :#{emoji2}:"})
|
||||
|
||||
updated_object = Object.normalize(updated)
|
||||
assert updated_object.data["content"] == "updated 2 :#{emoji2}:"
|
||||
|
|
@ -1802,7 +1803,7 @@ defmodule Pleroma.Web.CommonAPITest do
|
|||
|
||||
with_mock Pleroma.Web.Federator,
|
||||
publish: fn _p -> nil end do
|
||||
{:ok, updated} = CommonAPI.update(user, activity, %{status: "updated 2 :#{emoji2}:"})
|
||||
{:ok, updated} = CommonAPI.update(activity, user, %{status: "updated 2 :#{emoji2}:"})
|
||||
|
||||
assert updated.data["object"]["content"] == "updated 2 :#{emoji2}:"
|
||||
assert %{^emoji2 => _} = updated.data["object"]["emoji"]
|
||||
|
|
@ -1846,7 +1847,7 @@ defmodule Pleroma.Web.CommonAPITest do
|
|||
assert reply.object.data["emoji"]["remoteemoji"] == remote_emoji_uri
|
||||
|
||||
{:ok, edit} =
|
||||
CommonAPI.update(user, reply, %{status: "reply mew mew", spoiler_text: ":remoteemoji:"})
|
||||
CommonAPI.update(reply, user, %{status: "reply mew mew", spoiler_text: ":remoteemoji:"})
|
||||
|
||||
edited_note = Pleroma.Object.normalize(edit)
|
||||
|
||||
|
|
@ -1862,7 +1863,7 @@ defmodule Pleroma.Web.CommonAPITest do
|
|||
{:ok, activity} = CommonAPI.post(user, %{status: "foo1", spoiler_text: "updated 1"})
|
||||
assert Object.normalize(activity).data["summary"] == "mewmew 1"
|
||||
|
||||
{:ok, updated} = CommonAPI.update(user, activity, %{status: "updated 2"})
|
||||
{:ok, updated} = CommonAPI.update(activity, user, %{status: "updated 2"})
|
||||
|
||||
updated_object = Object.normalize(updated)
|
||||
assert updated_object.data["content"] == "mewmew 2"
|
||||
|
|
@ -1913,11 +1914,224 @@ defmodule Pleroma.Web.CommonAPITest do
|
|||
end
|
||||
|
||||
test "it does not boost if group is blocking poster", %{poster: poster, group: group} do
|
||||
{:ok, _} = CommonAPI.block(group, poster)
|
||||
{:ok, _} = CommonAPI.block(poster, group)
|
||||
{:ok, post} = CommonAPI.post(poster, %{status: "hey @#{group.nickname}"})
|
||||
|
||||
announces = get_announces_of_object(post.object)
|
||||
assert [] = announces
|
||||
end
|
||||
end
|
||||
|
||||
describe "Oban jobs are cancelled" do
|
||||
setup do
|
||||
clear_config([:instance, :federating], true)
|
||||
|
||||
local_user = insert(:user)
|
||||
|
||||
remote_one =
|
||||
insert(:user, %{
|
||||
local: false,
|
||||
nickname: "nick1@domain.com",
|
||||
ap_id: "https://domain.com/users/nick1",
|
||||
inbox: "https://domain.com/users/nick1/inbox",
|
||||
shared_inbox: "https://domain.com/inbox"
|
||||
})
|
||||
|
||||
remote_two =
|
||||
insert(:user, %{
|
||||
local: false,
|
||||
nickname: "nick2@example.com",
|
||||
ap_id: "https://example.com/users/nick2",
|
||||
inbox: "https://example.com/users/nick2/inbox",
|
||||
shared_inbox: "https://example.com/inbox"
|
||||
})
|
||||
|
||||
%{local_user: local_user, remote_one: remote_one, remote_two: remote_two}
|
||||
end
|
||||
|
||||
test "when deleting posts", %{
|
||||
local_user: local_user,
|
||||
remote_one: remote_one,
|
||||
remote_two: remote_two
|
||||
} do
|
||||
{:ok, _, _} = Pleroma.User.follow(remote_one, local_user)
|
||||
{:ok, _, _} = Pleroma.User.follow(remote_two, local_user)
|
||||
|
||||
{:ok, %{id: activity_id} = _activity} =
|
||||
CommonAPI.post(local_user, %{status: "Happy Friday everyone!"})
|
||||
|
||||
# Generate the publish_one jobs
|
||||
ObanHelpers.perform_all()
|
||||
|
||||
publish_one_jobs =
|
||||
all_enqueued()
|
||||
|> Enum.filter(fn job ->
|
||||
match?(
|
||||
%{
|
||||
state: "available",
|
||||
queue: "federator_outgoing",
|
||||
worker: "Pleroma.Workers.PublisherWorker",
|
||||
args: %{"op" => "publish_one", "params" => %{"activity_id" => ^activity_id}}
|
||||
},
|
||||
job
|
||||
)
|
||||
end)
|
||||
|
||||
assert length(publish_one_jobs) == 2
|
||||
|
||||
# The delete should have triggered cancelling the publish_one jobs
|
||||
assert {:ok, _delete} = CommonAPI.delete(activity_id, local_user)
|
||||
|
||||
# all_enqueued/1 will not return cancelled jobs
|
||||
cancelled_jobs =
|
||||
Oban.Job
|
||||
|> where([j], j.worker == "Pleroma.Workers.PublisherWorker")
|
||||
|> where([j], j.state == "cancelled")
|
||||
|> where([j], j.args["op"] == "publish_one")
|
||||
|> where([j], j.args["params"]["activity_id"] == ^activity_id)
|
||||
|> Pleroma.Repo.all()
|
||||
|
||||
assert length(cancelled_jobs) == 2
|
||||
end
|
||||
|
||||
test "when unfavoriting posts", %{
|
||||
local_user: local_user,
|
||||
remote_one: remote_user
|
||||
} do
|
||||
{:ok, activity} =
|
||||
CommonAPI.post(remote_user, %{status: "I like turtles!"})
|
||||
|
||||
{:ok, %{id: favorite_id} = _favorite} =
|
||||
CommonAPI.favorite(activity.id, local_user)
|
||||
|
||||
# Generate the publish_one jobs
|
||||
ObanHelpers.perform_all()
|
||||
|
||||
publish_one_jobs =
|
||||
all_enqueued()
|
||||
|> Enum.filter(fn job ->
|
||||
match?(
|
||||
%{
|
||||
state: "available",
|
||||
queue: "federator_outgoing",
|
||||
worker: "Pleroma.Workers.PublisherWorker",
|
||||
args: %{"op" => "publish_one", "params" => %{"activity_id" => ^favorite_id}}
|
||||
},
|
||||
job
|
||||
)
|
||||
end)
|
||||
|
||||
assert length(publish_one_jobs) == 1
|
||||
|
||||
# The unfavorite should have triggered cancelling the publish_one jobs
|
||||
assert {:ok, _unfavorite} = CommonAPI.unfavorite(activity.id, local_user)
|
||||
|
||||
# all_enqueued/1 will not return cancelled jobs
|
||||
cancelled_jobs =
|
||||
Oban.Job
|
||||
|> where([j], j.worker == "Pleroma.Workers.PublisherWorker")
|
||||
|> where([j], j.state == "cancelled")
|
||||
|> where([j], j.args["op"] == "publish_one")
|
||||
|> where([j], j.args["params"]["activity_id"] == ^favorite_id)
|
||||
|> Pleroma.Repo.all()
|
||||
|
||||
assert length(cancelled_jobs) == 1
|
||||
end
|
||||
|
||||
test "when unboosting posts", %{
|
||||
local_user: local_user,
|
||||
remote_one: remote_one,
|
||||
remote_two: remote_two
|
||||
} do
|
||||
{:ok, _, _} = Pleroma.User.follow(remote_one, local_user)
|
||||
{:ok, _, _} = Pleroma.User.follow(remote_two, local_user)
|
||||
|
||||
{:ok, activity} =
|
||||
CommonAPI.post(remote_one, %{status: "This is an unpleasant post"})
|
||||
|
||||
{:ok, %{id: repeat_id} = _repeat} =
|
||||
CommonAPI.repeat(activity.id, local_user)
|
||||
|
||||
# Generate the publish_one jobs
|
||||
ObanHelpers.perform_all()
|
||||
|
||||
publish_one_jobs =
|
||||
all_enqueued()
|
||||
|> Enum.filter(fn job ->
|
||||
match?(
|
||||
%{
|
||||
state: "available",
|
||||
queue: "federator_outgoing",
|
||||
worker: "Pleroma.Workers.PublisherWorker",
|
||||
args: %{"op" => "publish_one", "params" => %{"activity_id" => ^repeat_id}}
|
||||
},
|
||||
job
|
||||
)
|
||||
end)
|
||||
|
||||
assert length(publish_one_jobs) == 2
|
||||
|
||||
# The unrepeat should have triggered cancelling the publish_one jobs
|
||||
assert {:ok, _unfavorite} = CommonAPI.unrepeat(activity.id, local_user)
|
||||
|
||||
# all_enqueued/1 will not return cancelled jobs
|
||||
cancelled_jobs =
|
||||
Oban.Job
|
||||
|> where([j], j.worker == "Pleroma.Workers.PublisherWorker")
|
||||
|> where([j], j.state == "cancelled")
|
||||
|> where([j], j.args["op"] == "publish_one")
|
||||
|> where([j], j.args["params"]["activity_id"] == ^repeat_id)
|
||||
|> Pleroma.Repo.all()
|
||||
|
||||
assert length(cancelled_jobs) == 2
|
||||
end
|
||||
|
||||
test "when unreacting to posts", %{
|
||||
local_user: local_user,
|
||||
remote_one: remote_one,
|
||||
remote_two: remote_two
|
||||
} do
|
||||
{:ok, _, _} = Pleroma.User.follow(remote_one, local_user)
|
||||
{:ok, _, _} = Pleroma.User.follow(remote_two, local_user)
|
||||
|
||||
{:ok, %{id: activity_id}} =
|
||||
CommonAPI.post(remote_one, %{status: "Gang gang!!!!"})
|
||||
|
||||
{:ok, %{id: react_id} = _react} =
|
||||
CommonAPI.react_with_emoji(activity_id, local_user, "👍")
|
||||
|
||||
# Generate the publish_one jobs
|
||||
ObanHelpers.perform_all()
|
||||
|
||||
publish_one_jobs =
|
||||
all_enqueued()
|
||||
|> Enum.filter(fn job ->
|
||||
match?(
|
||||
%{
|
||||
state: "available",
|
||||
queue: "federator_outgoing",
|
||||
worker: "Pleroma.Workers.PublisherWorker",
|
||||
args: %{"op" => "publish_one", "params" => %{"activity_id" => ^react_id}}
|
||||
},
|
||||
job
|
||||
)
|
||||
end)
|
||||
|
||||
assert length(publish_one_jobs) == 2
|
||||
|
||||
# The unreact should have triggered cancelling the publish_one jobs
|
||||
assert {:ok, _unreact} = CommonAPI.unreact_with_emoji(activity_id, local_user, "👍")
|
||||
|
||||
# all_enqueued/1 will not return cancelled jobs
|
||||
cancelled_jobs =
|
||||
Oban.Job
|
||||
|> where([j], j.worker == "Pleroma.Workers.PublisherWorker")
|
||||
|> where([j], j.state == "cancelled")
|
||||
|> where([j], j.args["op"] == "publish_one")
|
||||
|> where([j], j.args["params"]["activity_id"] == ^react_id)
|
||||
|> Pleroma.Repo.all()
|
||||
|
||||
assert length(cancelled_jobs) == 2
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -55,11 +55,11 @@ defmodule Pleroma.Web.Feed.TagControllerTest do
|
|||
|
||||
xml = parse(response)
|
||||
|
||||
assert xpath(xml, ~x"//feed/title/text()") == '#pleromaart'
|
||||
assert xpath(xml, ~x"//feed/title/text()") == ~c"#pleromaart"
|
||||
|
||||
assert xpath(xml, ~x"//feed/entry/title/text()"l) == [
|
||||
'42 This is :moominmamm...',
|
||||
'yeah #PleromaArt'
|
||||
~c"42 This is :moominmamm...",
|
||||
~c"yeah #PleromaArt"
|
||||
]
|
||||
|
||||
assert xpath(xml, ~x"//feed/entry/author/name/text()"ls) == [user.nickname, user.nickname]
|
||||
|
|
@ -73,10 +73,10 @@ defmodule Pleroma.Web.Feed.TagControllerTest do
|
|||
resp = response(conn, 200)
|
||||
xml = parse(resp)
|
||||
|
||||
assert xpath(xml, ~x"//feed/title/text()") == '#pleromaart'
|
||||
assert xpath(xml, ~x"//feed/title/text()") == ~c"#pleromaart"
|
||||
|
||||
assert xpath(xml, ~x"//feed/entry/title/text()"l) == [
|
||||
'yeah #PleromaArt'
|
||||
~c"yeah #PleromaArt"
|
||||
]
|
||||
end
|
||||
|
||||
|
|
@ -120,20 +120,20 @@ defmodule Pleroma.Web.Feed.TagControllerTest do
|
|||
|> response(200)
|
||||
|
||||
xml = parse(response)
|
||||
assert xpath(xml, ~x"//channel/title/text()") == '#pleromaart'
|
||||
assert xpath(xml, ~x"//channel/title/text()") == ~c"#pleromaart"
|
||||
|
||||
assert xpath(xml, ~x"//channel/description/text()"s) ==
|
||||
"These are public toots tagged with #pleromaart. You can interact with them if you have an account anywhere in the fediverse."
|
||||
|
||||
assert xpath(xml, ~x"//channel/link/text()") ==
|
||||
'#{Pleroma.Web.Endpoint.url()}/tags/pleromaart.rss'
|
||||
~c"#{Pleroma.Web.Endpoint.url()}/tags/pleromaart.rss"
|
||||
|
||||
assert xpath(xml, ~x"//channel/webfeeds:logo/text()") ==
|
||||
'#{Pleroma.Web.Endpoint.url()}/static/logo.svg'
|
||||
~c"#{Pleroma.Web.Endpoint.url()}/static/logo.svg"
|
||||
|
||||
assert xpath(xml, ~x"//channel/item/title/text()"l) == [
|
||||
'42 This is :moominmamm...',
|
||||
'yeah #PleromaArt'
|
||||
~c"42 This is :moominmamm...",
|
||||
~c"yeah #PleromaArt"
|
||||
]
|
||||
|
||||
assert xpath(xml, ~x"//channel/item/pubDate/text()"sl) == [
|
||||
|
|
@ -160,7 +160,7 @@ defmodule Pleroma.Web.Feed.TagControllerTest do
|
|||
|> response(200)
|
||||
|
||||
xml = parse(response)
|
||||
assert xpath(xml, ~x"//channel/title/text()") == '#pleromaart'
|
||||
assert xpath(xml, ~x"//channel/title/text()") == ~c"#pleromaart"
|
||||
|
||||
assert xpath(xml, ~x"//channel/description/text()"s) ==
|
||||
"These are public toots tagged with #pleromaart. You can interact with them if you have an account anywhere in the fediverse."
|
||||
|
|
@ -174,10 +174,10 @@ defmodule Pleroma.Web.Feed.TagControllerTest do
|
|||
resp = response(conn, 200)
|
||||
xml = parse(resp)
|
||||
|
||||
assert xpath(xml, ~x"//channel/title/text()") == '#pleromaart'
|
||||
assert xpath(xml, ~x"//channel/title/text()") == ~c"#pleromaart"
|
||||
|
||||
assert xpath(xml, ~x"//channel/item/title/text()"l) == [
|
||||
'yeah #PleromaArt'
|
||||
~c"yeah #PleromaArt"
|
||||
]
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -88,7 +88,7 @@ defmodule Pleroma.Web.Feed.UserControllerTest do
|
|||
|> SweetXml.parse()
|
||||
|> SweetXml.xpath(~x"//entry/title/text()"l)
|
||||
|
||||
assert activity_titles == ['Won\'t, didn\'...', '2hu', '2hu & as']
|
||||
assert activity_titles == [~c"Won't, didn'...", ~c"2hu", ~c"2hu & as"]
|
||||
assert resp =~ FeedView.escape(object.data["content"])
|
||||
assert resp =~ FeedView.escape(object.data["summary"])
|
||||
assert resp =~ FeedView.escape(object.data["context"])
|
||||
|
|
@ -104,7 +104,7 @@ defmodule Pleroma.Web.Feed.UserControllerTest do
|
|||
|> SweetXml.parse()
|
||||
|> SweetXml.xpath(~x"//entry/title/text()"l)
|
||||
|
||||
assert activity_titles == ['2hu & as']
|
||||
assert activity_titles == [~c"2hu & as"]
|
||||
end
|
||||
|
||||
test "gets a rss feed", %{conn: conn, user: user, object: object, max_id: max_id} do
|
||||
|
|
@ -119,7 +119,7 @@ defmodule Pleroma.Web.Feed.UserControllerTest do
|
|||
|> SweetXml.parse()
|
||||
|> SweetXml.xpath(~x"//item/title/text()"l)
|
||||
|
||||
assert activity_titles == ['Won\'t, didn\'...', '2hu', '2hu & as']
|
||||
assert activity_titles == [~c"Won't, didn'...", ~c"2hu", ~c"2hu & as"]
|
||||
assert resp =~ FeedView.escape(object.data["content"])
|
||||
assert resp =~ FeedView.escape(object.data["summary"])
|
||||
assert resp =~ FeedView.escape(object.data["context"])
|
||||
|
|
@ -135,7 +135,7 @@ defmodule Pleroma.Web.Feed.UserControllerTest do
|
|||
|> SweetXml.parse()
|
||||
|> SweetXml.xpath(~x"//item/title/text()"l)
|
||||
|
||||
assert activity_titles == ['2hu & as']
|
||||
assert activity_titles == [~c"2hu & as"]
|
||||
end
|
||||
|
||||
test "returns 404 for a missing feed", %{conn: conn} do
|
||||
|
|
@ -167,7 +167,7 @@ defmodule Pleroma.Web.Feed.UserControllerTest do
|
|||
|> SweetXml.xpath(~x"//entry/title/text()"l)
|
||||
|> Enum.sort()
|
||||
|
||||
assert activity_titles == ['public', 'unlisted']
|
||||
assert activity_titles == [~c"public", ~c"unlisted"]
|
||||
end
|
||||
|
||||
test "returns 404 when the user is remote", %{conn: conn} do
|
||||
|
|
@ -208,7 +208,7 @@ defmodule Pleroma.Web.Feed.UserControllerTest do
|
|||
|> SweetXml.parse()
|
||||
|> SweetXml.xpath(~x"//entry/title/text()"l)
|
||||
|
||||
assert activity_titles == ['Won\'t, didn\'...', '2hu', '2hu & as']
|
||||
assert activity_titles == [~c"Won't, didn'...", ~c"2hu", ~c"2hu & as"]
|
||||
assert resp =~ FeedView.escape(object.data["content"])
|
||||
assert resp =~ FeedView.escape(object.data["summary"])
|
||||
assert resp =~ FeedView.escape(object.data["context"])
|
||||
|
|
|
|||
|
|
@ -1120,7 +1120,7 @@ defmodule Pleroma.Web.MastodonAPI.AccountControllerTest do
|
|||
|> json_response_and_validate_schema(200)
|
||||
|
||||
# Follow the user, then the pinned status can be seen
|
||||
CommonAPI.follow(reader, user)
|
||||
CommonAPI.follow(user, reader)
|
||||
ObanHelpers.perform_all()
|
||||
|
||||
assert [%{"id" => ^activity_id, "pinned" => true}] =
|
||||
|
|
@ -2118,7 +2118,7 @@ defmodule Pleroma.Web.MastodonAPI.AccountControllerTest do
|
|||
test "pin account", %{user: user, conn: conn} do
|
||||
%{id: id1} = other_user1 = insert(:user)
|
||||
|
||||
CommonAPI.follow(user, other_user1)
|
||||
CommonAPI.follow(other_user1, user)
|
||||
|
||||
assert %{"id" => ^id1, "endorsed" => true} =
|
||||
conn
|
||||
|
|
@ -2136,7 +2136,7 @@ defmodule Pleroma.Web.MastodonAPI.AccountControllerTest do
|
|||
test "unpin account", %{user: user, conn: conn} do
|
||||
%{id: id1} = other_user1 = insert(:user)
|
||||
|
||||
CommonAPI.follow(user, other_user1)
|
||||
CommonAPI.follow(other_user1, user)
|
||||
User.endorse(user, other_user1)
|
||||
|
||||
assert %{"id" => ^id1, "endorsed" => false} =
|
||||
|
|
@ -2156,8 +2156,8 @@ defmodule Pleroma.Web.MastodonAPI.AccountControllerTest do
|
|||
%{id: id1} = other_user1 = insert(:user)
|
||||
%{id: id2} = other_user2 = insert(:user)
|
||||
|
||||
CommonAPI.follow(user, other_user1)
|
||||
CommonAPI.follow(user, other_user2)
|
||||
CommonAPI.follow(other_user1, user)
|
||||
CommonAPI.follow(other_user2, user)
|
||||
|
||||
conn
|
||||
|> put_req_header("content-type", "application/json")
|
||||
|
|
@ -2227,7 +2227,7 @@ defmodule Pleroma.Web.MastodonAPI.AccountControllerTest do
|
|||
test "removing user from followers", %{conn: conn, user: user} do
|
||||
%{id: other_user_id} = other_user = insert(:user)
|
||||
|
||||
CommonAPI.follow(other_user, user)
|
||||
CommonAPI.follow(user, other_user)
|
||||
|
||||
assert %{"id" => ^other_user_id, "followed_by" => false} =
|
||||
conn
|
||||
|
|
@ -2240,7 +2240,7 @@ defmodule Pleroma.Web.MastodonAPI.AccountControllerTest do
|
|||
test "removing remote user from followers", %{conn: conn, user: user} do
|
||||
%{id: other_user_id} = other_user = insert(:user, local: false)
|
||||
|
||||
CommonAPI.follow(other_user, user)
|
||||
CommonAPI.follow(user, other_user)
|
||||
|
||||
assert User.following?(other_user, user)
|
||||
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ defmodule Pleroma.Web.MastodonAPI.FollowRequestControllerTest do
|
|||
test "/api/v1/follow_requests works", %{user: user, conn: conn} do
|
||||
other_user = insert(:user)
|
||||
|
||||
{:ok, _, _, _activity} = CommonAPI.follow(other_user, user)
|
||||
{:ok, _, _, _activity} = CommonAPI.follow(user, other_user)
|
||||
{:ok, other_user, user} = User.follow(other_user, user, :follow_pending)
|
||||
|
||||
assert User.following?(other_user, user) == false
|
||||
|
|
@ -34,7 +34,7 @@ defmodule Pleroma.Web.MastodonAPI.FollowRequestControllerTest do
|
|||
test "/api/v1/follow_requests/:id/authorize works", %{user: user, conn: conn} do
|
||||
other_user = insert(:user)
|
||||
|
||||
{:ok, _, _, _activity} = CommonAPI.follow(other_user, user)
|
||||
{:ok, _, _, _activity} = CommonAPI.follow(user, other_user)
|
||||
{:ok, other_user, user} = User.follow(other_user, user, :follow_pending)
|
||||
|
||||
user = User.get_cached_by_id(user.id)
|
||||
|
|
@ -56,7 +56,7 @@ defmodule Pleroma.Web.MastodonAPI.FollowRequestControllerTest do
|
|||
test "/api/v1/follow_requests/:id/reject works", %{user: user, conn: conn} do
|
||||
other_user = insert(:user)
|
||||
|
||||
{:ok, _, _, _activity} = CommonAPI.follow(other_user, user)
|
||||
{:ok, _, _, _activity} = CommonAPI.follow(user, other_user)
|
||||
|
||||
user = User.get_cached_by_id(user.id)
|
||||
|
||||
|
|
|
|||
|
|
@ -76,6 +76,7 @@ defmodule Pleroma.Web.MastodonAPI.MediaControllerTest do
|
|||
end
|
||||
|
||||
test "/api/v2/media, upload_limit", %{conn: conn, user: user} do
|
||||
clear_config([Pleroma.Upload, :uploader], Pleroma.Uploaders.Local)
|
||||
desc = "Description of the binary"
|
||||
|
||||
upload_limit = Config.get([:instance, :upload_limit]) * 8 + 8
|
||||
|
|
|
|||
|
|
@ -148,7 +148,7 @@ defmodule Pleroma.Web.MastodonAPI.NotificationControllerTest do
|
|||
%{user: user, conn: conn} = oauth_access(["read:notifications"])
|
||||
blocker = insert(:user)
|
||||
|
||||
{:ok, _} = CommonAPI.block(blocker, user)
|
||||
{:ok, _} = CommonAPI.block(user, blocker)
|
||||
{:ok, activity} = CommonAPI.post(blocker, %{status: "hi @#{user.nickname}"})
|
||||
|
||||
{:ok, [_notification]} = Notification.create_notifications(activity)
|
||||
|
|
@ -326,10 +326,10 @@ defmodule Pleroma.Web.MastodonAPI.NotificationControllerTest do
|
|||
|
||||
{:ok, private_activity} = CommonAPI.post(other_user, %{status: ".", visibility: "private"})
|
||||
|
||||
{:ok, _} = CommonAPI.favorite(user, public_activity.id)
|
||||
{:ok, _} = CommonAPI.favorite(user, direct_activity.id)
|
||||
{:ok, _} = CommonAPI.favorite(user, unlisted_activity.id)
|
||||
{:ok, _} = CommonAPI.favorite(user, private_activity.id)
|
||||
{:ok, _} = CommonAPI.favorite(public_activity.id, user)
|
||||
{:ok, _} = CommonAPI.favorite(direct_activity.id, user)
|
||||
{:ok, _} = CommonAPI.favorite(unlisted_activity.id, user)
|
||||
{:ok, _} = CommonAPI.favorite(private_activity.id, user)
|
||||
|
||||
activity_ids =
|
||||
conn
|
||||
|
|
@ -414,7 +414,7 @@ defmodule Pleroma.Web.MastodonAPI.NotificationControllerTest do
|
|||
in_reply_to_status_id: activity.id
|
||||
})
|
||||
|
||||
{:ok, _favorite} = CommonAPI.favorite(user, reply.id)
|
||||
{:ok, _favorite} = CommonAPI.favorite(reply.id, user)
|
||||
|
||||
activity_ids =
|
||||
conn
|
||||
|
|
@ -432,9 +432,9 @@ defmodule Pleroma.Web.MastodonAPI.NotificationControllerTest do
|
|||
|
||||
{:ok, mention_activity} = CommonAPI.post(other_user, %{status: "hey @#{user.nickname}"})
|
||||
{:ok, create_activity} = CommonAPI.post(user, %{status: "hey"})
|
||||
{:ok, favorite_activity} = CommonAPI.favorite(other_user, create_activity.id)
|
||||
{:ok, favorite_activity} = CommonAPI.favorite(create_activity.id, other_user)
|
||||
{:ok, reblog_activity} = CommonAPI.repeat(create_activity.id, other_user)
|
||||
{:ok, _, _, follow_activity} = CommonAPI.follow(other_user, user)
|
||||
{:ok, _, _, follow_activity} = CommonAPI.follow(user, other_user)
|
||||
|
||||
mention_notification_id = get_notification_id_by_activity(mention_activity)
|
||||
favorite_notification_id = get_notification_id_by_activity(favorite_activity)
|
||||
|
|
@ -470,9 +470,9 @@ defmodule Pleroma.Web.MastodonAPI.NotificationControllerTest do
|
|||
|
||||
{:ok, mention_activity} = CommonAPI.post(other_user, %{status: "hey @#{user.nickname}"})
|
||||
{:ok, create_activity} = CommonAPI.post(user, %{status: "hey"})
|
||||
{:ok, favorite_activity} = CommonAPI.favorite(other_user, create_activity.id)
|
||||
{:ok, favorite_activity} = CommonAPI.favorite(create_activity.id, other_user)
|
||||
{:ok, reblog_activity} = CommonAPI.repeat(create_activity.id, other_user)
|
||||
{:ok, _, _, follow_activity} = CommonAPI.follow(other_user, user)
|
||||
{:ok, _, _, follow_activity} = CommonAPI.follow(user, other_user)
|
||||
|
||||
mention_notification_id = get_notification_id_by_activity(mention_activity)
|
||||
favorite_notification_id = get_notification_id_by_activity(favorite_activity)
|
||||
|
|
@ -517,9 +517,9 @@ defmodule Pleroma.Web.MastodonAPI.NotificationControllerTest do
|
|||
|
||||
{:ok, _activity} = CommonAPI.post(other_user, %{status: "hey @#{user.nickname}"})
|
||||
{:ok, create_activity} = CommonAPI.post(user, %{status: "hey"})
|
||||
{:ok, _activity} = CommonAPI.favorite(other_user, create_activity.id)
|
||||
{:ok, _activity} = CommonAPI.favorite(create_activity.id, other_user)
|
||||
{:ok, _activity} = CommonAPI.repeat(create_activity.id, other_user)
|
||||
{:ok, _, _, follow_activity} = CommonAPI.follow(other_user, user)
|
||||
{:ok, _, _, follow_activity} = CommonAPI.follow(user, other_user)
|
||||
|
||||
follow_notification_id = get_notification_id_by_activity(follow_activity)
|
||||
|
||||
|
|
@ -578,7 +578,7 @@ defmodule Pleroma.Web.MastodonAPI.NotificationControllerTest do
|
|||
%{user: user, conn: conn} = oauth_access(["read:notifications"])
|
||||
user2 = insert(:user)
|
||||
|
||||
{:ok, _, _, _} = CommonAPI.follow(user, user2)
|
||||
{:ok, _, _, _} = CommonAPI.follow(user2, user)
|
||||
{:ok, _} = CommonAPI.post(user2, %{status: "hey @#{user.nickname}"})
|
||||
|
||||
ret_conn = get(conn, "/api/v1/notifications")
|
||||
|
|
@ -596,7 +596,7 @@ defmodule Pleroma.Web.MastodonAPI.NotificationControllerTest do
|
|||
%{user: user, conn: conn} = oauth_access(["read:notifications"])
|
||||
user2 = insert(:user)
|
||||
|
||||
{:ok, _, _, _} = CommonAPI.follow(user, user2)
|
||||
{:ok, _, _, _} = CommonAPI.follow(user2, user)
|
||||
{:ok, _} = CommonAPI.post(user2, %{status: "hey @#{user.nickname}"})
|
||||
|
||||
ret_conn = get(conn, "/api/v1/notifications")
|
||||
|
|
@ -614,7 +614,7 @@ defmodule Pleroma.Web.MastodonAPI.NotificationControllerTest do
|
|||
%{user: user, conn: conn} = oauth_access(["read:notifications"])
|
||||
user2 = insert(:user)
|
||||
|
||||
{:ok, _, _, _} = CommonAPI.follow(user, user2)
|
||||
{:ok, _, _, _} = CommonAPI.follow(user2, user)
|
||||
{:ok, _} = CommonAPI.post(user2, %{status: "hey @#{user.nickname}"})
|
||||
|
||||
ret_conn = get(conn, "/api/v1/notifications")
|
||||
|
|
|
|||
|
|
@ -130,7 +130,6 @@ defmodule Pleroma.Web.MastodonAPI.SearchControllerTest do
|
|||
assert [] = results["statuses"]
|
||||
end
|
||||
|
||||
@tag capture_log: true
|
||||
test "constructs hashtags from search query", %{conn: conn} do
|
||||
results =
|
||||
conn
|
||||
|
|
|
|||
|
|
@ -1356,7 +1356,7 @@ defmodule Pleroma.Web.MastodonAPI.StatusControllerTest do
|
|||
user1 = insert(:user)
|
||||
user2 = insert(:user)
|
||||
user3 = insert(:user)
|
||||
{:ok, _} = CommonAPI.favorite(user2, activity.id)
|
||||
{:ok, _} = CommonAPI.favorite(activity.id, user2)
|
||||
{:ok, _bookmark} = Pleroma.Bookmark.create(user2.id, activity.id)
|
||||
{:ok, reblog_activity1} = CommonAPI.repeat(activity.id, user1)
|
||||
{:ok, _} = CommonAPI.repeat(activity.id, user2)
|
||||
|
|
@ -1483,7 +1483,7 @@ defmodule Pleroma.Web.MastodonAPI.StatusControllerTest do
|
|||
test "unfavorites a status and returns it", %{user: user, conn: conn} do
|
||||
activity = insert(:note_activity)
|
||||
|
||||
{:ok, _} = CommonAPI.favorite(user, activity.id)
|
||||
{:ok, _} = CommonAPI.favorite(activity.id, user)
|
||||
|
||||
conn =
|
||||
conn
|
||||
|
|
@ -1771,7 +1771,7 @@ defmodule Pleroma.Web.MastodonAPI.StatusControllerTest do
|
|||
end
|
||||
|
||||
test "cannot mute already muted conversation", %{conn: conn, user: user, activity: activity} do
|
||||
{:ok, _} = CommonAPI.add_mute(user, activity)
|
||||
{:ok, _} = CommonAPI.add_mute(activity, user)
|
||||
|
||||
conn =
|
||||
conn
|
||||
|
|
@ -1784,7 +1784,7 @@ defmodule Pleroma.Web.MastodonAPI.StatusControllerTest do
|
|||
end
|
||||
|
||||
test "unmute conversation", %{conn: conn, user: user, activity: activity} do
|
||||
{:ok, _} = CommonAPI.add_mute(user, activity)
|
||||
{:ok, _} = CommonAPI.add_mute(activity, user)
|
||||
|
||||
id_str = to_string(activity.id)
|
||||
|
||||
|
|
@ -1859,7 +1859,7 @@ defmodule Pleroma.Web.MastodonAPI.StatusControllerTest do
|
|||
|
||||
test "returns users who have favorited the status", %{conn: conn, activity: activity} do
|
||||
other_user = insert(:user)
|
||||
{:ok, _} = CommonAPI.favorite(other_user, activity.id)
|
||||
{:ok, _} = CommonAPI.favorite(activity.id, other_user)
|
||||
|
||||
response =
|
||||
conn
|
||||
|
|
@ -1890,7 +1890,7 @@ defmodule Pleroma.Web.MastodonAPI.StatusControllerTest do
|
|||
other_user = insert(:user)
|
||||
{:ok, _user_relationship} = User.block(user, other_user)
|
||||
|
||||
{:ok, _} = CommonAPI.favorite(other_user, activity.id)
|
||||
{:ok, _} = CommonAPI.favorite(activity.id, other_user)
|
||||
|
||||
response =
|
||||
conn
|
||||
|
|
@ -1902,7 +1902,7 @@ defmodule Pleroma.Web.MastodonAPI.StatusControllerTest do
|
|||
|
||||
test "does not fail on an unauthenticated request", %{activity: activity} do
|
||||
other_user = insert(:user)
|
||||
{:ok, _} = CommonAPI.favorite(other_user, activity.id)
|
||||
{:ok, _} = CommonAPI.favorite(activity.id, other_user)
|
||||
|
||||
response =
|
||||
build_conn()
|
||||
|
|
@ -1922,7 +1922,7 @@ defmodule Pleroma.Web.MastodonAPI.StatusControllerTest do
|
|||
visibility: "direct"
|
||||
})
|
||||
|
||||
{:ok, _} = CommonAPI.favorite(other_user, activity.id)
|
||||
{:ok, _} = CommonAPI.favorite(activity.id, other_user)
|
||||
|
||||
favourited_by_url = "/api/v1/statuses/#{activity.id}/favourited_by"
|
||||
|
||||
|
|
@ -1953,7 +1953,7 @@ defmodule Pleroma.Web.MastodonAPI.StatusControllerTest do
|
|||
clear_config([:instance, :show_reactions], false)
|
||||
|
||||
other_user = insert(:user)
|
||||
{:ok, _} = CommonAPI.favorite(other_user, activity.id)
|
||||
{:ok, _} = CommonAPI.favorite(activity.id, other_user)
|
||||
|
||||
response =
|
||||
conn
|
||||
|
|
@ -2096,9 +2096,9 @@ defmodule Pleroma.Web.MastodonAPI.StatusControllerTest do
|
|||
{:ok, second_post} = CommonAPI.post(other_user, %{status: "bla"})
|
||||
{:ok, third_post} = CommonAPI.post(other_user, %{status: "bla"})
|
||||
|
||||
{:ok, _first_favorite} = CommonAPI.favorite(user, third_post.id)
|
||||
{:ok, _second_favorite} = CommonAPI.favorite(user, first_post.id)
|
||||
{:ok, third_favorite} = CommonAPI.favorite(user, second_post.id)
|
||||
{:ok, _first_favorite} = CommonAPI.favorite(third_post.id, user)
|
||||
{:ok, _second_favorite} = CommonAPI.favorite(first_post.id, user)
|
||||
{:ok, third_favorite} = CommonAPI.favorite(second_post.id, user)
|
||||
|
||||
result =
|
||||
conn
|
||||
|
|
@ -2134,7 +2134,7 @@ defmodule Pleroma.Web.MastodonAPI.StatusControllerTest do
|
|||
{:ok, _} = CommonAPI.post(other_user, %{status: "bla"})
|
||||
{:ok, activity} = CommonAPI.post(other_user, %{status: "trees are happy"})
|
||||
|
||||
{:ok, last_like} = CommonAPI.favorite(user, activity.id)
|
||||
{:ok, last_like} = CommonAPI.favorite(activity.id, user)
|
||||
|
||||
first_conn = get(conn, "/api/v1/favourites")
|
||||
|
||||
|
|
@ -2150,7 +2150,7 @@ defmodule Pleroma.Web.MastodonAPI.StatusControllerTest do
|
|||
status: "Trees Are Never Sad Look At Them Every Once In Awhile They're Quite Beautiful."
|
||||
})
|
||||
|
||||
{:ok, _} = CommonAPI.favorite(user, second_activity.id)
|
||||
{:ok, _} = CommonAPI.favorite(second_activity.id, user)
|
||||
|
||||
second_conn = get(conn, "/api/v1/favourites?since_id=#{last_like.id}")
|
||||
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@ defmodule Pleroma.Web.MastodonAPI.SuggestionControllerTest do
|
|||
|
||||
test "returns v2 suggestions excluding blocked accounts", %{conn: conn, user: blocker} do
|
||||
blocked = insert(:user, is_suggested: true)
|
||||
{:ok, _} = CommonAPI.block(blocker, blocked)
|
||||
{:ok, _} = CommonAPI.block(blocked, blocker)
|
||||
|
||||
res =
|
||||
conn
|
||||
|
|
@ -59,7 +59,7 @@ defmodule Pleroma.Web.MastodonAPI.SuggestionControllerTest do
|
|||
|
||||
test "returns v2 suggestions excluding followed accounts", %{conn: conn, user: follower} do
|
||||
followed = insert(:user, is_suggested: true)
|
||||
{:ok, _, _, _} = CommonAPI.follow(follower, followed)
|
||||
{:ok, _, _, _} = CommonAPI.follow(followed, follower)
|
||||
|
||||
res =
|
||||
conn
|
||||
|
|
|
|||
|
|
@ -152,7 +152,6 @@ defmodule Pleroma.Web.MastodonAPI.TimelineControllerTest do
|
|||
end
|
||||
|
||||
describe "public" do
|
||||
@tag capture_log: true
|
||||
test "the public timeline", %{conn: conn} do
|
||||
user = insert(:user)
|
||||
|
||||
|
|
@ -791,7 +790,6 @@ defmodule Pleroma.Web.MastodonAPI.TimelineControllerTest do
|
|||
describe "hashtag" do
|
||||
setup do: oauth_access(["n/a"])
|
||||
|
||||
@tag capture_log: true
|
||||
test "hashtag timeline", %{conn: conn} do
|
||||
following = insert(:user)
|
||||
|
||||
|
|
|
|||
|
|
@ -436,7 +436,7 @@ defmodule Pleroma.Web.MastodonAPI.AccountViewTest do
|
|||
{:ok, other_user, user} = User.follow(other_user, user)
|
||||
{:ok, _subscription} = User.subscribe(user, other_user)
|
||||
{:ok, _user_relationships} = User.mute(user, other_user, %{notifications: true})
|
||||
{:ok, _reblog_mute} = CommonAPI.hide_reblogs(user, other_user)
|
||||
{:ok, _reblog_mute} = CommonAPI.hide_reblogs(other_user, user)
|
||||
|
||||
expected =
|
||||
Map.merge(
|
||||
|
|
@ -493,7 +493,7 @@ defmodule Pleroma.Web.MastodonAPI.AccountViewTest do
|
|||
user = insert(:user)
|
||||
other_user = insert(:user, is_locked: true)
|
||||
|
||||
{:ok, user, other_user, _} = CommonAPI.follow(user, other_user)
|
||||
{:ok, user, other_user, _} = CommonAPI.follow(other_user, user)
|
||||
user = User.get_cached_by_id(user.id)
|
||||
other_user = User.get_cached_by_id(other_user.id)
|
||||
|
||||
|
|
@ -547,8 +547,8 @@ defmodule Pleroma.Web.MastodonAPI.AccountViewTest do
|
|||
})
|
||||
|
||||
other_user = insert(:user)
|
||||
{:ok, user, other_user, _activity} = CommonAPI.follow(user, other_user)
|
||||
{:ok, _other_user, user, _activity} = CommonAPI.follow(other_user, user)
|
||||
{:ok, user, other_user, _activity} = CommonAPI.follow(other_user, user)
|
||||
{:ok, _other_user, user, _activity} = CommonAPI.follow(user, other_user)
|
||||
|
||||
assert %{
|
||||
followers_count: 0,
|
||||
|
|
@ -560,8 +560,8 @@ defmodule Pleroma.Web.MastodonAPI.AccountViewTest do
|
|||
test "shows when follows/followers are hidden" do
|
||||
user = insert(:user, hide_followers: true, hide_follows: true)
|
||||
other_user = insert(:user)
|
||||
{:ok, user, other_user, _activity} = CommonAPI.follow(user, other_user)
|
||||
{:ok, _other_user, user, _activity} = CommonAPI.follow(other_user, user)
|
||||
{:ok, user, other_user, _activity} = CommonAPI.follow(other_user, user)
|
||||
{:ok, _other_user, user, _activity} = CommonAPI.follow(user, other_user)
|
||||
|
||||
assert %{
|
||||
followers_count: 1,
|
||||
|
|
@ -573,11 +573,11 @@ defmodule Pleroma.Web.MastodonAPI.AccountViewTest do
|
|||
test "shows actual follower/following count to the account owner" do
|
||||
user = insert(:user, hide_followers: true, hide_follows: true)
|
||||
other_user = insert(:user)
|
||||
{:ok, user, other_user, _activity} = CommonAPI.follow(user, other_user)
|
||||
{:ok, user, other_user, _activity} = CommonAPI.follow(other_user, user)
|
||||
|
||||
assert User.following?(user, other_user)
|
||||
assert Pleroma.FollowingRelationship.follower_count(other_user) == 1
|
||||
{:ok, _other_user, user, _activity} = CommonAPI.follow(other_user, user)
|
||||
{:ok, _other_user, user, _activity} = CommonAPI.follow(user, other_user)
|
||||
|
||||
assert %{
|
||||
followers_count: 1,
|
||||
|
|
@ -684,7 +684,7 @@ defmodule Pleroma.Web.MastodonAPI.AccountViewTest do
|
|||
AccountView.render("show.json", %{user: user, for: user})
|
||||
|
||||
other_user = insert(:user)
|
||||
{:ok, _other_user, user, _activity} = CommonAPI.follow(other_user, user)
|
||||
{:ok, _other_user, user, _activity} = CommonAPI.follow(user, other_user)
|
||||
|
||||
assert %{follow_requests_count: 0} =
|
||||
AccountView.render("show.json", %{user: user, for: user})
|
||||
|
|
@ -696,7 +696,7 @@ defmodule Pleroma.Web.MastodonAPI.AccountViewTest do
|
|||
assert %{locked: true} = AccountView.render("show.json", %{user: user, for: user})
|
||||
|
||||
other_user = insert(:user)
|
||||
{:ok, _other_user, user, _activity} = CommonAPI.follow(other_user, user)
|
||||
{:ok, _other_user, user, _activity} = CommonAPI.follow(user, other_user)
|
||||
|
||||
assert %{locked: true, follow_requests_count: 1} =
|
||||
AccountView.render("show.json", %{user: user, for: user})
|
||||
|
|
@ -708,7 +708,7 @@ defmodule Pleroma.Web.MastodonAPI.AccountViewTest do
|
|||
assert %{locked: true} = AccountView.render("show.json", %{user: user, for: user})
|
||||
|
||||
other_user = insert(:user)
|
||||
{:ok, other_user, user, _activity} = CommonAPI.follow(other_user, user)
|
||||
{:ok, other_user, user, _activity} = CommonAPI.follow(user, other_user)
|
||||
|
||||
assert %{locked: true, follow_requests_count: 1} =
|
||||
AccountView.render("show.json", %{user: user, for: user})
|
||||
|
|
@ -725,7 +725,7 @@ defmodule Pleroma.Web.MastodonAPI.AccountViewTest do
|
|||
assert %{locked: true} = AccountView.render("show.json", %{user: user, for: user})
|
||||
|
||||
other_user = insert(:user)
|
||||
{:ok, other_user, user, _activity} = CommonAPI.follow(other_user, user)
|
||||
{:ok, other_user, user, _activity} = CommonAPI.follow(user, other_user)
|
||||
|
||||
assert %{locked: true, follow_requests_count: 1} =
|
||||
AccountView.render("show.json", %{user: user, for: user})
|
||||
|
|
@ -742,7 +742,7 @@ defmodule Pleroma.Web.MastodonAPI.AccountViewTest do
|
|||
assert %{locked: true} = AccountView.render("show.json", %{user: user, for: user})
|
||||
|
||||
other_user = insert(:user)
|
||||
{:ok, _other_user, user, _activity} = CommonAPI.follow(other_user, user)
|
||||
{:ok, _other_user, user, _activity} = CommonAPI.follow(user, other_user)
|
||||
|
||||
{:ok, user} = User.update_and_set_cache(user, %{is_locked: false})
|
||||
|
||||
|
|
|
|||
|
|
@ -93,7 +93,7 @@ defmodule Pleroma.Web.MastodonAPI.NotificationViewTest do
|
|||
user = insert(:user)
|
||||
another_user = insert(:user)
|
||||
{:ok, create_activity} = CommonAPI.post(user, %{status: "hey"})
|
||||
{:ok, favorite_activity} = CommonAPI.favorite(another_user, create_activity.id)
|
||||
{:ok, favorite_activity} = CommonAPI.favorite(create_activity.id, another_user)
|
||||
{:ok, [notification]} = Notification.create_notifications(favorite_activity)
|
||||
create_activity = Activity.get_by_id(create_activity.id)
|
||||
|
||||
|
|
@ -132,7 +132,7 @@ defmodule Pleroma.Web.MastodonAPI.NotificationViewTest do
|
|||
test "Follow notification" do
|
||||
follower = insert(:user)
|
||||
followed = insert(:user)
|
||||
{:ok, follower, followed, _activity} = CommonAPI.follow(follower, followed)
|
||||
{:ok, follower, followed, _activity} = CommonAPI.follow(followed, follower)
|
||||
notification = Notification |> Repo.one() |> Repo.preload(:activity)
|
||||
|
||||
expected = %{
|
||||
|
|
@ -290,7 +290,7 @@ defmodule Pleroma.Web.MastodonAPI.NotificationViewTest do
|
|||
|
||||
{:ok, activity} = CommonAPI.post(user, %{status: "mew"})
|
||||
{:ok, _} = CommonAPI.repeat(activity.id, repeat_user)
|
||||
{:ok, update} = CommonAPI.update(user, activity, %{status: "mew mew"})
|
||||
{:ok, update} = CommonAPI.update(activity, user, %{status: "mew mew"})
|
||||
|
||||
user = Pleroma.User.get_by_ap_id(user.ap_id)
|
||||
activity = Pleroma.Activity.normalize(activity)
|
||||
|
|
@ -316,7 +316,7 @@ defmodule Pleroma.Web.MastodonAPI.NotificationViewTest do
|
|||
|
||||
{:ok, _} = Pleroma.UserRelationship.create_mute(user, another_user)
|
||||
{:ok, create_activity} = CommonAPI.post(user, %{status: "hey"})
|
||||
{:ok, favorite_activity} = CommonAPI.favorite(another_user, create_activity.id)
|
||||
{:ok, favorite_activity} = CommonAPI.favorite(create_activity.id, another_user)
|
||||
{:ok, [notification]} = Notification.create_notifications(favorite_activity)
|
||||
create_activity = Activity.get_by_id(create_activity.id)
|
||||
|
||||
|
|
|
|||
|
|
@ -74,7 +74,7 @@ defmodule Pleroma.Web.MastodonAPI.PollViewTest do
|
|||
|
||||
object = Object.normalize(activity, fetch: false)
|
||||
|
||||
{:ok, _votes, object} = CommonAPI.vote(voter, object, [0, 1])
|
||||
{:ok, _votes, object} = CommonAPI.vote(object, voter, [0, 1])
|
||||
|
||||
assert match?(
|
||||
%{
|
||||
|
|
@ -119,7 +119,7 @@ defmodule Pleroma.Web.MastodonAPI.PollViewTest do
|
|||
|
||||
object = Object.normalize(activity, fetch: false)
|
||||
|
||||
{:ok, _, object} = CommonAPI.vote(other_user, object, [1, 2])
|
||||
{:ok, _, object} = CommonAPI.vote(object, other_user, [1, 2])
|
||||
|
||||
result = PollView.render("show.json", %{object: object, for: other_user})
|
||||
|
||||
|
|
|
|||
|
|
@ -201,7 +201,6 @@ defmodule Pleroma.Web.MastodonAPI.StatusViewTest do
|
|||
assert_schema(status, "Status", Pleroma.Web.ApiSpec.spec())
|
||||
end
|
||||
|
||||
@tag capture_log: true
|
||||
test "returns a temporary ap_id based user for activities missing db users" do
|
||||
user = insert(:user)
|
||||
|
||||
|
|
@ -389,7 +388,7 @@ defmodule Pleroma.Web.MastodonAPI.StatusViewTest do
|
|||
|
||||
assert status.pleroma.thread_muted == false
|
||||
|
||||
{:ok, activity} = CommonAPI.add_mute(user, activity)
|
||||
{:ok, activity} = CommonAPI.add_mute(activity, user)
|
||||
|
||||
status = StatusView.render("show.json", %{activity: activity, for: user})
|
||||
|
||||
|
|
@ -467,7 +466,9 @@ defmodule Pleroma.Web.MastodonAPI.StatusViewTest do
|
|||
|
||||
# Create a public post quoting the private post
|
||||
quote_private =
|
||||
insert(:note_activity, note: insert(:note, data: %{"quoteUrl" => private_object.data["id"]}))
|
||||
insert(:note_activity,
|
||||
note: insert(:note, data: %{"quoteUrl" => private_object.data["id"]})
|
||||
)
|
||||
|
||||
status = StatusView.render("show.json", %{activity: quote_private})
|
||||
|
||||
|
|
@ -478,7 +479,7 @@ defmodule Pleroma.Web.MastodonAPI.StatusViewTest do
|
|||
|
||||
# After following the user, the quote is rendered
|
||||
follower = insert(:user)
|
||||
CommonAPI.follow(follower, user)
|
||||
CommonAPI.follow(user, follower)
|
||||
|
||||
status = StatusView.render("show.json", %{activity: quote_private, for: follower})
|
||||
assert status.pleroma.quote.id == to_string(private.id)
|
||||
|
|
@ -937,7 +938,7 @@ defmodule Pleroma.Web.MastodonAPI.StatusViewTest do
|
|||
status = StatusView.render("show.json", activity: post)
|
||||
refute status.edited_at
|
||||
|
||||
{:ok, _} = CommonAPI.update(poster, post, %{status: "mew mew"})
|
||||
{:ok, _} = CommonAPI.update(post, poster, %{status: "mew mew"})
|
||||
edited = Pleroma.Activity.normalize(post)
|
||||
|
||||
status = StatusView.render("show.json", activity: edited)
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ defmodule Pleroma.Web.Metadata.UtilsTest do
|
|||
alias Pleroma.Web.Metadata.Utils
|
||||
|
||||
describe "scrub_html_and_truncate/1" do
|
||||
test "it returns content text without encode HTML if summary is nil" do
|
||||
test "it returns content text without HTML if summary is nil" do
|
||||
user = insert(:user)
|
||||
|
||||
note =
|
||||
|
|
@ -17,14 +17,14 @@ defmodule Pleroma.Web.Metadata.UtilsTest do
|
|||
"actor" => user.ap_id,
|
||||
"id" => "https://pleroma.gov/objects/whatever",
|
||||
"summary" => nil,
|
||||
"content" => "Pleroma's really cool!"
|
||||
"content" => "Pleroma's really cool!<br>"
|
||||
}
|
||||
})
|
||||
|
||||
assert Utils.scrub_html_and_truncate(note) == "Pleroma's really cool!"
|
||||
end
|
||||
|
||||
test "it returns context text without encode HTML if summary is empty" do
|
||||
test "it returns content text without HTML if summary is empty" do
|
||||
user = insert(:user)
|
||||
|
||||
note =
|
||||
|
|
@ -33,14 +33,14 @@ defmodule Pleroma.Web.Metadata.UtilsTest do
|
|||
"actor" => user.ap_id,
|
||||
"id" => "https://pleroma.gov/objects/whatever",
|
||||
"summary" => "",
|
||||
"content" => "Pleroma's really cool!"
|
||||
"content" => "Pleroma's really cool!<br>"
|
||||
}
|
||||
})
|
||||
|
||||
assert Utils.scrub_html_and_truncate(note) == "Pleroma's really cool!"
|
||||
end
|
||||
|
||||
test "it returns summary text without encode HTML if summary is filled" do
|
||||
test "it returns summary text without HTML if summary is filled" do
|
||||
user = insert(:user)
|
||||
|
||||
note =
|
||||
|
|
@ -48,7 +48,7 @@ defmodule Pleroma.Web.Metadata.UtilsTest do
|
|||
data: %{
|
||||
"actor" => user.ap_id,
|
||||
"id" => "https://pleroma.gov/objects/whatever",
|
||||
"summary" => "Public service announcement on caffeine consumption",
|
||||
"summary" => "Public service announcement on caffeine consumption<br>",
|
||||
"content" => "cofe"
|
||||
}
|
||||
})
|
||||
|
|
@ -57,6 +57,22 @@ defmodule Pleroma.Web.Metadata.UtilsTest do
|
|||
"Public service announcement on caffeine consumption"
|
||||
end
|
||||
|
||||
test "it returns empty string if summary and content are absent" do
|
||||
user = insert(:user)
|
||||
|
||||
note =
|
||||
insert(:note, %{
|
||||
data: %{
|
||||
"actor" => user.ap_id,
|
||||
"id" => "https://pleroma.gov/objects/whatever",
|
||||
"content" => nil,
|
||||
"summary" => nil
|
||||
}
|
||||
})
|
||||
|
||||
assert Utils.scrub_html_and_truncate(note) == ""
|
||||
end
|
||||
|
||||
test "it does not return old content after editing" do
|
||||
user = insert(:user)
|
||||
|
||||
|
|
@ -65,7 +81,7 @@ defmodule Pleroma.Web.Metadata.UtilsTest do
|
|||
object = Pleroma.Object.normalize(activity)
|
||||
assert Utils.scrub_html_and_truncate(object) == "mew mew #def"
|
||||
|
||||
{:ok, update} = Pleroma.Web.CommonAPI.update(user, activity, %{status: "mew mew #abc"})
|
||||
{:ok, update} = Pleroma.Web.CommonAPI.update(activity, user, %{status: "mew mew #abc"})
|
||||
update = Pleroma.Activity.normalize(update)
|
||||
object = Pleroma.Object.normalize(update)
|
||||
assert Utils.scrub_html_and_truncate(object) == "mew mew #abc"
|
||||
|
|
|
|||
|
|
@ -71,7 +71,7 @@ defmodule Pleroma.Web.OAuth.LDAPAuthorizationTest do
|
|||
equalityMatch: fn _type, _value -> :ok end,
|
||||
wholeSubtree: fn -> :ok end,
|
||||
search: fn _connection, _options ->
|
||||
{:ok, {:eldap_search_result, [{:eldap_entry, '', []}], []}}
|
||||
{:ok, {:eldap_search_result, [{:eldap_entry, ~c"", []}], []}}
|
||||
end,
|
||||
close: fn _connection ->
|
||||
send(self(), :close_connection)
|
||||
|
|
|
|||
|
|
@ -186,7 +186,7 @@ defmodule Pleroma.Web.OStatus.OStatusControllerTest do
|
|||
|
||||
user = insert(:user)
|
||||
|
||||
{:ok, like_activity} = CommonAPI.favorite(user, note_activity.id)
|
||||
{:ok, like_activity} = CommonAPI.favorite(note_activity.id, user)
|
||||
|
||||
assert like_activity.data["type"] == "Like"
|
||||
|
||||
|
|
|
|||
|
|
@ -78,7 +78,7 @@ defmodule Pleroma.Web.PleromaAPI.AccountControllerTest do
|
|||
user: user
|
||||
} do
|
||||
[activity | _] = insert_pair(:note_activity)
|
||||
CommonAPI.favorite(user, activity.id)
|
||||
CommonAPI.favorite(activity.id, user)
|
||||
|
||||
response =
|
||||
conn
|
||||
|
|
@ -95,7 +95,7 @@ defmodule Pleroma.Web.PleromaAPI.AccountControllerTest do
|
|||
user: user
|
||||
} do
|
||||
activity = insert(:note_activity)
|
||||
CommonAPI.favorite(user, activity.id)
|
||||
CommonAPI.favorite(activity.id, user)
|
||||
|
||||
response =
|
||||
build_conn()
|
||||
|
|
@ -115,7 +115,7 @@ defmodule Pleroma.Web.PleromaAPI.AccountControllerTest do
|
|||
visibility: "direct"
|
||||
})
|
||||
|
||||
CommonAPI.favorite(user, direct.id)
|
||||
CommonAPI.favorite(direct.id, user)
|
||||
|
||||
for u <- [user, current_user] do
|
||||
response =
|
||||
|
|
@ -148,7 +148,7 @@ defmodule Pleroma.Web.PleromaAPI.AccountControllerTest do
|
|||
visibility: "direct"
|
||||
})
|
||||
|
||||
CommonAPI.favorite(user, direct.id)
|
||||
CommonAPI.favorite(direct.id, user)
|
||||
|
||||
response =
|
||||
conn
|
||||
|
|
@ -165,7 +165,7 @@ defmodule Pleroma.Web.PleromaAPI.AccountControllerTest do
|
|||
activities = insert_list(10, :note_activity)
|
||||
|
||||
Enum.each(activities, fn activity ->
|
||||
CommonAPI.favorite(user, activity.id)
|
||||
CommonAPI.favorite(activity.id, user)
|
||||
end)
|
||||
|
||||
third_activity = Enum.at(activities, 2)
|
||||
|
|
@ -190,7 +190,7 @@ defmodule Pleroma.Web.PleromaAPI.AccountControllerTest do
|
|||
7
|
||||
|> insert_list(:note_activity)
|
||||
|> Enum.each(fn activity ->
|
||||
CommonAPI.favorite(user, activity.id)
|
||||
CommonAPI.favorite(activity.id, user)
|
||||
end)
|
||||
|
||||
response =
|
||||
|
|
@ -222,7 +222,7 @@ defmodule Pleroma.Web.PleromaAPI.AccountControllerTest do
|
|||
test "returns 403 error when user has hidden own favorites", %{conn: conn} do
|
||||
user = insert(:user, hide_favorites: true)
|
||||
activity = insert(:note_activity)
|
||||
CommonAPI.favorite(user, activity.id)
|
||||
CommonAPI.favorite(activity.id, user)
|
||||
|
||||
conn = get(conn, "/api/v1/pleroma/accounts/#{user.id}/favourites")
|
||||
|
||||
|
|
@ -232,7 +232,7 @@ defmodule Pleroma.Web.PleromaAPI.AccountControllerTest do
|
|||
test "hides favorites for new users by default", %{conn: conn} do
|
||||
user = insert(:user)
|
||||
activity = insert(:note_activity)
|
||||
CommonAPI.favorite(user, activity.id)
|
||||
CommonAPI.favorite(activity.id, user)
|
||||
|
||||
assert user.hide_favorites
|
||||
conn = get(conn, "/api/v1/pleroma/accounts/#{user.id}/favourites")
|
||||
|
|
@ -286,8 +286,8 @@ defmodule Pleroma.Web.PleromaAPI.AccountControllerTest do
|
|||
%{id: id2} = user2 = insert(:user)
|
||||
%{id: id3} = user3 = insert(:user)
|
||||
|
||||
CommonAPI.follow(user1, user2)
|
||||
CommonAPI.follow(user1, user3)
|
||||
CommonAPI.follow(user2, user1)
|
||||
CommonAPI.follow(user3, user1)
|
||||
|
||||
User.endorse(user1, user2)
|
||||
User.endorse(user1, user3)
|
||||
|
|
@ -324,9 +324,9 @@ defmodule Pleroma.Web.PleromaAPI.AccountControllerTest do
|
|||
|
||||
user3 = insert(:user)
|
||||
|
||||
CommonAPI.follow(user, user1)
|
||||
CommonAPI.follow(user, user2)
|
||||
CommonAPI.follow(user, user3)
|
||||
CommonAPI.follow(user1, user)
|
||||
CommonAPI.follow(user2, user)
|
||||
CommonAPI.follow(user3, user)
|
||||
|
||||
[%{"id" => ^id1}] =
|
||||
conn
|
||||
|
|
@ -350,8 +350,8 @@ defmodule Pleroma.Web.PleromaAPI.AccountControllerTest do
|
|||
show_birthday: true
|
||||
})
|
||||
|
||||
CommonAPI.follow(user, user1)
|
||||
CommonAPI.follow(user, user2)
|
||||
CommonAPI.follow(user1, user)
|
||||
CommonAPI.follow(user2, user)
|
||||
|
||||
[%{"id" => ^id2}] =
|
||||
conn
|
||||
|
|
|
|||
|
|
@ -20,9 +20,7 @@ defmodule Pleroma.Web.PleromaAPI.BackupControllerTest do
|
|||
end
|
||||
|
||||
test "GET /api/v1/pleroma/backups", %{user: user, conn: conn} do
|
||||
assert {:ok, %Oban.Job{args: %{"backup_id" => backup_id}}} = Backup.create(user)
|
||||
|
||||
backup = Backup.get(backup_id)
|
||||
assert {:ok, %Backup{} = backup} = Backup.user(user)
|
||||
|
||||
response =
|
||||
conn
|
||||
|
|
|
|||
|
|
@ -159,8 +159,8 @@ defmodule Pleroma.Web.PleromaAPI.EmojiPackControllerTest do
|
|||
|
||||
{:ok, arch} = :zip.unzip(resp, [:memory])
|
||||
|
||||
assert Enum.find(arch, fn {n, _} -> n == 'pack.json' end)
|
||||
assert Enum.find(arch, fn {n, _} -> n == 'blank.png' end)
|
||||
assert Enum.find(arch, fn {n, _} -> n == ~c"pack.json" end)
|
||||
assert Enum.find(arch, fn {n, _} -> n == ~c"blank.png" end)
|
||||
end
|
||||
|
||||
test "non existing pack", %{conn: conn} do
|
||||
|
|
@ -454,7 +454,7 @@ defmodule Pleroma.Web.PleromaAPI.EmojiPackControllerTest do
|
|||
method: :get,
|
||||
url: "https://nonshared-pack"
|
||||
} ->
|
||||
{:ok, {'empty.zip', empty_arch}} = :zip.zip('empty.zip', [], [:memory])
|
||||
{:ok, {~c"empty.zip", empty_arch}} = :zip.zip(~c"empty.zip", [], [:memory])
|
||||
text(empty_arch)
|
||||
end)
|
||||
|
||||
|
|
|
|||
|
|
@ -27,42 +27,11 @@ defmodule Pleroma.Web.PleromaAPI.BackupViewTest do
|
|||
assert result.id == backup.id
|
||||
end
|
||||
|
||||
test "it renders the state and processed_number" do
|
||||
test "it renders the processed state" do
|
||||
user = insert(:user)
|
||||
backup = Backup.new(user)
|
||||
|
||||
result = BackupView.render("show.json", backup: backup)
|
||||
assert result.state == to_string(backup.state)
|
||||
assert result.processed_number == backup.processed_number
|
||||
end
|
||||
|
||||
test "it renders failed state with legacy records" do
|
||||
backup = %Backup{
|
||||
id: 0,
|
||||
content_type: "application/zip",
|
||||
file_name: "dummy",
|
||||
file_size: 1,
|
||||
state: :invalid,
|
||||
processed: true,
|
||||
processed_number: 1,
|
||||
inserted_at: NaiveDateTime.utc_now()
|
||||
}
|
||||
|
||||
result = BackupView.render("show.json", backup: backup)
|
||||
assert result.state == "complete"
|
||||
|
||||
backup = %Backup{
|
||||
id: 0,
|
||||
content_type: "application/zip",
|
||||
file_name: "dummy",
|
||||
file_size: 1,
|
||||
state: :invalid,
|
||||
processed: false,
|
||||
processed_number: 1,
|
||||
inserted_at: NaiveDateTime.utc_now()
|
||||
}
|
||||
|
||||
result = BackupView.render("show.json", backup: backup)
|
||||
assert result.state == "failed"
|
||||
refute result.processed
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ defmodule Pleroma.Web.PleromaAPI.ChatMessageReferenceViewTest do
|
|||
alias Pleroma.Chat
|
||||
alias Pleroma.Chat.MessageReference
|
||||
alias Pleroma.Object
|
||||
alias Pleroma.Tests.ObanHelpers
|
||||
alias Pleroma.UnstubbedConfigMock, as: ConfigMock
|
||||
alias Pleroma.Web.ActivityPub.ActivityPub
|
||||
alias Pleroma.Web.CommonAPI
|
||||
|
|
@ -70,6 +71,8 @@ defmodule Pleroma.Web.PleromaAPI.ChatMessageReferenceViewTest do
|
|||
media_id: upload.id
|
||||
)
|
||||
|
||||
ObanHelpers.perform_all()
|
||||
|
||||
object = Object.normalize(activity, fetch: false)
|
||||
|
||||
cm_ref = MessageReference.for_chat_and_object(chat, object)
|
||||
|
|
|
|||
|
|
@ -62,14 +62,12 @@ defmodule Pleroma.Web.Push.ImplTest do
|
|||
|> Enum.each(fn push -> assert match?(:ok, Impl.deliver(push)) end)
|
||||
end
|
||||
|
||||
@tag capture_log: true
|
||||
test "returns error if notification activity type does not match" do
|
||||
assert capture_log(fn ->
|
||||
assert Impl.build(%{}) == []
|
||||
end) =~ "WebPush: unknown activity type"
|
||||
end
|
||||
|
||||
@tag capture_log: true
|
||||
test "fail message sending" do
|
||||
user = insert(:user)
|
||||
|
||||
|
|
@ -80,7 +78,7 @@ defmodule Pleroma.Web.Push.ImplTest do
|
|||
)
|
||||
|
||||
other_user = insert(:user)
|
||||
{:ok, _, _, activity} = CommonAPI.follow(user, other_user)
|
||||
{:ok, _, _, activity} = CommonAPI.follow(other_user, user)
|
||||
|
||||
notif =
|
||||
insert(:notification,
|
||||
|
|
@ -105,7 +103,7 @@ defmodule Pleroma.Web.Push.ImplTest do
|
|||
)
|
||||
|
||||
other_user = insert(:user)
|
||||
{:ok, _, _, activity} = CommonAPI.follow(user, other_user)
|
||||
{:ok, _, _, activity} = CommonAPI.follow(other_user, user)
|
||||
|
||||
notif =
|
||||
insert(:notification,
|
||||
|
|
@ -156,7 +154,7 @@ defmodule Pleroma.Web.Push.ImplTest do
|
|||
test "renders title and body for follow activity" do
|
||||
user = insert(:user, nickname: "Bob")
|
||||
other_user = insert(:user)
|
||||
{:ok, _, _, activity} = CommonAPI.follow(user, other_user)
|
||||
{:ok, _, _, activity} = CommonAPI.follow(other_user, user)
|
||||
object = Object.normalize(activity, fetch: false)
|
||||
|
||||
assert Impl.format_body(%{activity: activity, type: "follow"}, user, object) ==
|
||||
|
|
@ -194,7 +192,7 @@ defmodule Pleroma.Web.Push.ImplTest do
|
|||
"<span>Lorem ipsum dolor sit amet</span>, consectetur :firefox: adipiscing elit. Fusce sagittis finibus turpis."
|
||||
})
|
||||
|
||||
{:ok, activity} = CommonAPI.favorite(user, activity.id)
|
||||
{:ok, activity} = CommonAPI.favorite(activity.id, user)
|
||||
object = Object.normalize(activity, fetch: false)
|
||||
|
||||
assert Impl.format_body(%{activity: activity, type: "favourite"}, user, object) ==
|
||||
|
|
@ -227,7 +225,7 @@ defmodule Pleroma.Web.Push.ImplTest do
|
|||
|
||||
{:ok, activity} = CommonAPI.post(user, %{status: "lorem ipsum"})
|
||||
|
||||
{:ok, activity} = CommonAPI.update(user, activity, %{status: "edited status"})
|
||||
{:ok, activity} = CommonAPI.update(activity, user, %{status: "edited status"})
|
||||
object = Object.normalize(activity, fetch: false)
|
||||
|
||||
assert Impl.format_body(%{activity: activity, type: "update"}, user, object) ==
|
||||
|
|
@ -353,7 +351,7 @@ defmodule Pleroma.Web.Push.ImplTest do
|
|||
body: "New Mention"
|
||||
}
|
||||
|
||||
{:ok, activity} = CommonAPI.favorite(user, activity.id)
|
||||
{:ok, activity} = CommonAPI.favorite(activity.id, user)
|
||||
|
||||
notif = insert(:notification, user: user2, activity: activity, type: "favourite")
|
||||
|
||||
|
|
@ -369,7 +367,10 @@ defmodule Pleroma.Web.Push.ImplTest do
|
|||
user = insert(:user, nickname: "Bob")
|
||||
|
||||
user2 =
|
||||
insert(:user, nickname: "Rob", notification_settings: %{hide_notification_contents: false})
|
||||
insert(:user,
|
||||
nickname: "Rob",
|
||||
notification_settings: %{hide_notification_contents: false}
|
||||
)
|
||||
|
||||
{:ok, activity} =
|
||||
CommonAPI.post(user, %{
|
||||
|
|
@ -407,7 +408,7 @@ defmodule Pleroma.Web.Push.ImplTest do
|
|||
title: "New Mention"
|
||||
}
|
||||
|
||||
{:ok, activity} = CommonAPI.favorite(user, activity.id)
|
||||
{:ok, activity} = CommonAPI.favorite(activity.id, user)
|
||||
|
||||
notif = insert(:notification, user: user2, activity: activity, type: "favourite")
|
||||
|
||||
|
|
|
|||
26
test/pleroma/web/rich_media/backfill_test.exs
Normal file
26
test/pleroma/web/rich_media/backfill_test.exs
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
# Pleroma: A lightweight social networking server
|
||||
# Copyright © 2017-2022 Pleroma Authors <https://pleroma.social/>
|
||||
# SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
defmodule Pleroma.Web.RichMedia.BackfillTest do
|
||||
use Pleroma.DataCase
|
||||
|
||||
alias Pleroma.Web.RichMedia.Backfill
|
||||
alias Pleroma.Web.RichMedia.Card
|
||||
|
||||
import Mox
|
||||
|
||||
setup_all do: clear_config([:rich_media, :enabled], true)
|
||||
|
||||
test "sets a negative cache entry for an error" do
|
||||
url = "https://bad.example.com/"
|
||||
url_hash = Card.url_to_hash(url)
|
||||
|
||||
Tesla.Mock.mock(fn %{url: ^url} -> :error end)
|
||||
|
||||
Pleroma.CachexMock
|
||||
|> expect(:put, fn :rich_media_cache, ^url_hash, :error, ttl: _ -> {:ok, true} end)
|
||||
|
||||
Backfill.run(%{"url" => url})
|
||||
end
|
||||
end
|
||||
|
|
@ -3,11 +3,14 @@
|
|||
# SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
defmodule Pleroma.Web.RichMedia.CardTest do
|
||||
use Oban.Testing, repo: Pleroma.Repo
|
||||
use Pleroma.DataCase, async: true
|
||||
|
||||
alias Pleroma.Tests.ObanHelpers
|
||||
alias Pleroma.UnstubbedConfigMock, as: ConfigMock
|
||||
alias Pleroma.Web.CommonAPI
|
||||
alias Pleroma.Web.RichMedia.Card
|
||||
alias Pleroma.Workers.RichMediaWorker
|
||||
|
||||
import Mox
|
||||
import Pleroma.Factory
|
||||
|
|
@ -36,6 +39,16 @@ defmodule Pleroma.Web.RichMedia.CardTest do
|
|||
content_type: "text/markdown"
|
||||
})
|
||||
|
||||
Pleroma.Web.ActivityPub.ActivityPubMock
|
||||
|> expect(:stream_out, fn ^activity -> nil end)
|
||||
|
||||
assert_enqueued(
|
||||
worker: RichMediaWorker,
|
||||
args: %{"url" => url, "activity_id" => activity.id}
|
||||
)
|
||||
|
||||
ObanHelpers.perform_all()
|
||||
|
||||
assert %Card{url_hash: ^url_hash, fields: _} = Card.get_by_activity(activity)
|
||||
end
|
||||
|
||||
|
|
@ -50,18 +63,20 @@ defmodule Pleroma.Web.RichMedia.CardTest do
|
|||
|
||||
# Force a backfill
|
||||
Card.get_by_activity(activity)
|
||||
ObanHelpers.perform_all()
|
||||
|
||||
assert match?(
|
||||
%Card{url_hash: ^original_url_hash, fields: _},
|
||||
Card.get_by_activity(activity)
|
||||
)
|
||||
|
||||
{:ok, _} = CommonAPI.update(user, activity, %{status: "I like this site #{updated_url}"})
|
||||
{:ok, _} = CommonAPI.update(activity, user, %{status: "I like this site #{updated_url}"})
|
||||
|
||||
activity = Pleroma.Activity.get_by_id(activity.id)
|
||||
|
||||
# Force a backfill
|
||||
Card.get_by_activity(activity)
|
||||
ObanHelpers.perform_all()
|
||||
|
||||
assert match?(
|
||||
%Card{url_hash: ^updated_url_hash, fields: _},
|
||||
|
|
|
|||
|
|
@ -4,10 +4,11 @@
|
|||
|
||||
defmodule Pleroma.Web.RichMedia.Parser.TTL.AwsSignedUrlTest do
|
||||
use Pleroma.DataCase, async: false
|
||||
use Oban.Testing, repo: Pleroma.Repo
|
||||
use Oban.Testing, repo: Pleroma.Repo, testing: :inline
|
||||
|
||||
import Mox
|
||||
|
||||
alias Pleroma.Tests.ObanHelpers
|
||||
alias Pleroma.UnstubbedConfigMock, as: ConfigMock
|
||||
alias Pleroma.Web.RichMedia.Card
|
||||
alias Pleroma.Web.RichMedia.Parser.TTL.AwsSignedUrl
|
||||
|
|
@ -74,9 +75,19 @@ defmodule Pleroma.Web.RichMedia.Parser.TTL.AwsSignedUrlTest do
|
|||
|
||||
Card.get_or_backfill_by_url(url)
|
||||
|
||||
assert_enqueued(worker: Pleroma.Workers.RichMediaExpirationWorker, args: %{"url" => url})
|
||||
# Find the backfill job
|
||||
expected_job =
|
||||
[
|
||||
worker: "Pleroma.Workers.RichMediaWorker",
|
||||
args: %{"op" => "backfill", "url" => url}
|
||||
]
|
||||
|
||||
[%Oban.Job{scheduled_at: scheduled_at}] = all_enqueued()
|
||||
assert_enqueued(expected_job)
|
||||
|
||||
# Run it manually
|
||||
ObanHelpers.perform_all()
|
||||
|
||||
[%Oban.Job{scheduled_at: scheduled_at} | _] = all_enqueued()
|
||||
|
||||
timestamp_dt = Timex.parse!(timestamp, "{ISO:Basic:Z}")
|
||||
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ defmodule Pleroma.Web.RichMedia.Parser.TTL.OpengraphTest do
|
|||
|
||||
import Mox
|
||||
|
||||
alias Pleroma.Tests.ObanHelpers
|
||||
alias Pleroma.UnstubbedConfigMock, as: ConfigMock
|
||||
alias Pleroma.Web.RichMedia.Card
|
||||
|
||||
|
|
@ -36,6 +37,21 @@ defmodule Pleroma.Web.RichMedia.Parser.TTL.OpengraphTest do
|
|||
|
||||
Card.get_or_backfill_by_url(url)
|
||||
|
||||
assert_enqueued(worker: Pleroma.Workers.RichMediaExpirationWorker, args: %{"url" => url})
|
||||
# Find the backfill job
|
||||
expected_job =
|
||||
[
|
||||
worker: "Pleroma.Workers.RichMediaWorker",
|
||||
args: %{"op" => "backfill", "url" => url}
|
||||
]
|
||||
|
||||
assert_enqueued(expected_job)
|
||||
|
||||
# Run it manually
|
||||
ObanHelpers.perform_all()
|
||||
|
||||
assert_enqueued(
|
||||
worker: Pleroma.Workers.RichMediaWorker,
|
||||
args: %{"op" => "expire", "url" => url}
|
||||
)
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ defmodule Pleroma.Web.RichMedia.ParserTest do
|
|||
end
|
||||
|
||||
test "doesn't just add a title" do
|
||||
assert {:error, {:invalid_metadata, _}} = Parser.parse("https://example.com/non-ogp")
|
||||
assert {:error, :invalid_metadata} = Parser.parse("https://example.com/non-ogp")
|
||||
end
|
||||
|
||||
test "parses ogp" do
|
||||
|
|
@ -96,7 +96,7 @@ defmodule Pleroma.Web.RichMedia.ParserTest do
|
|||
end
|
||||
|
||||
test "returns error if getting page was not successful" do
|
||||
assert {:error, :overload} = Parser.parse("https://example.com/error")
|
||||
assert {:error, :get} = Parser.parse("https://example.com/error")
|
||||
end
|
||||
|
||||
test "does a HEAD request to check if the body is too large" do
|
||||
|
|
@ -104,17 +104,17 @@ defmodule Pleroma.Web.RichMedia.ParserTest do
|
|||
end
|
||||
|
||||
test "does a HEAD request to check if the body is html" do
|
||||
assert {:error, {:content_type, _}} = Parser.parse("https://example.com/pdf-file")
|
||||
assert {:error, :content_type} = Parser.parse("https://example.com/pdf-file")
|
||||
end
|
||||
|
||||
test "refuses to crawl incomplete URLs" do
|
||||
url = "example.com/ogp"
|
||||
assert :error == Parser.parse(url)
|
||||
assert {:error, :validate} == Parser.parse(url)
|
||||
end
|
||||
|
||||
test "refuses to crawl malformed URLs" do
|
||||
url = "example.com[]/ogp"
|
||||
assert :error == Parser.parse(url)
|
||||
assert {:error, :validate} == Parser.parse(url)
|
||||
end
|
||||
|
||||
test "refuses to crawl URLs of private network from posts" do
|
||||
|
|
@ -126,7 +126,7 @@ defmodule Pleroma.Web.RichMedia.ParserTest do
|
|||
"https://pleroma.local/notice/9kCP7V"
|
||||
]
|
||||
|> Enum.each(fn url ->
|
||||
assert :error == Parser.parse(url)
|
||||
assert {:error, :validate} == Parser.parse(url)
|
||||
end)
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -418,7 +418,7 @@ defmodule Pleroma.Web.StreamerTest do
|
|||
Streamer.get_topic_and_add_socket("user:notification", user, oauth_token)
|
||||
|
||||
{:ok, activity} = CommonAPI.post(user, %{status: ":("})
|
||||
{:ok, _} = CommonAPI.favorite(blocked, activity.id)
|
||||
{:ok, _} = CommonAPI.favorite(activity.id, blocked)
|
||||
|
||||
refute_receive _
|
||||
end
|
||||
|
|
@ -430,11 +430,11 @@ defmodule Pleroma.Web.StreamerTest do
|
|||
user2 = insert(:user)
|
||||
|
||||
{:ok, activity} = CommonAPI.post(user, %{status: "super hot take"})
|
||||
{:ok, _} = CommonAPI.add_mute(user, activity)
|
||||
{:ok, _} = CommonAPI.add_mute(activity, user)
|
||||
|
||||
Streamer.get_topic_and_add_socket("user:notification", user, oauth_token)
|
||||
|
||||
{:ok, favorite_activity} = CommonAPI.favorite(user2, activity.id)
|
||||
{:ok, favorite_activity} = CommonAPI.favorite(activity.id, user2)
|
||||
|
||||
refute_receive _
|
||||
assert Streamer.filtered_by_user?(user, favorite_activity)
|
||||
|
|
@ -448,7 +448,7 @@ defmodule Pleroma.Web.StreamerTest do
|
|||
|
||||
{:ok, activity} = CommonAPI.post(user, %{status: "super hot take"})
|
||||
Streamer.get_topic_and_add_socket("user:notification", user, oauth_token)
|
||||
{:ok, favorite_activity} = CommonAPI.favorite(user2, activity.id)
|
||||
{:ok, favorite_activity} = CommonAPI.favorite(activity.id, user2)
|
||||
|
||||
assert_receive {:render_with_user, _, "notification.json", notif, _}
|
||||
assert notif.activity.id == favorite_activity.id
|
||||
|
|
@ -464,7 +464,7 @@ defmodule Pleroma.Web.StreamerTest do
|
|||
{:ok, user} = User.block_domain(user, "hecking-lewd-place.com")
|
||||
{:ok, activity} = CommonAPI.post(user, %{status: "super hot take"})
|
||||
Streamer.get_topic_and_add_socket("user:notification", user, oauth_token)
|
||||
{:ok, favorite_activity} = CommonAPI.favorite(user2, activity.id)
|
||||
{:ok, favorite_activity} = CommonAPI.favorite(activity.id, user2)
|
||||
|
||||
refute_receive _
|
||||
assert Streamer.filtered_by_user?(user, favorite_activity)
|
||||
|
|
@ -477,7 +477,7 @@ defmodule Pleroma.Web.StreamerTest do
|
|||
user2 = insert(:user)
|
||||
|
||||
Streamer.get_topic_and_add_socket("user:notification", user, oauth_token)
|
||||
{:ok, _follower, _followed, follow_activity} = CommonAPI.follow(user2, user)
|
||||
{:ok, _follower, _followed, follow_activity} = CommonAPI.follow(user, user2)
|
||||
|
||||
assert_receive {:render_with_user, _, "notification.json", notif, _}
|
||||
assert notif.activity.id == follow_activity.id
|
||||
|
|
@ -493,7 +493,7 @@ defmodule Pleroma.Web.StreamerTest do
|
|||
other_user_id = other_user.id
|
||||
|
||||
Streamer.get_topic_and_add_socket("user", user, oauth_token)
|
||||
{:ok, _follower, _followed, _follow_activity} = CommonAPI.follow(user, other_user)
|
||||
{:ok, _follower, _followed, _follow_activity} = CommonAPI.follow(other_user, user)
|
||||
|
||||
assert_receive {:text, event}
|
||||
|
||||
|
|
@ -536,12 +536,12 @@ defmodule Pleroma.Web.StreamerTest do
|
|||
|
||||
test "it streams edits in the 'user' stream", %{user: user, token: oauth_token} do
|
||||
sender = insert(:user)
|
||||
{:ok, _, _, _} = CommonAPI.follow(user, sender)
|
||||
{:ok, _, _, _} = CommonAPI.follow(sender, user)
|
||||
|
||||
{:ok, activity} = CommonAPI.post(sender, %{status: "hey"})
|
||||
|
||||
Streamer.get_topic_and_add_socket("user", user, oauth_token)
|
||||
{:ok, edited} = CommonAPI.update(sender, activity, %{status: "mew mew"})
|
||||
{:ok, edited} = CommonAPI.update(activity, sender, %{status: "mew mew"})
|
||||
create = Pleroma.Activity.get_create_by_object_ap_id_with_object(activity.object.data["id"])
|
||||
|
||||
assert_receive {:render_with_user, _, "status_update.json", ^create, _}
|
||||
|
|
@ -552,7 +552,7 @@ defmodule Pleroma.Web.StreamerTest do
|
|||
{:ok, activity} = CommonAPI.post(user, %{status: "hey"})
|
||||
|
||||
Streamer.get_topic_and_add_socket("user", user, oauth_token)
|
||||
{:ok, edited} = CommonAPI.update(user, activity, %{status: "mew mew"})
|
||||
{:ok, edited} = CommonAPI.update(activity, user, %{status: "mew mew"})
|
||||
create = Pleroma.Activity.get_create_by_object_ap_id_with_object(activity.object.data["id"])
|
||||
|
||||
assert_receive {:render_with_user, _, "status_update.json", ^create, _}
|
||||
|
|
@ -608,7 +608,7 @@ defmodule Pleroma.Web.StreamerTest do
|
|||
{:ok, activity} = CommonAPI.post(sender, %{status: "hey"})
|
||||
assert_receive {:text, _}
|
||||
|
||||
{:ok, edited} = CommonAPI.update(sender, activity, %{status: "mew mew"})
|
||||
{:ok, edited} = CommonAPI.update(activity, sender, %{status: "mew mew"})
|
||||
|
||||
edited = Pleroma.Activity.normalize(edited)
|
||||
|
||||
|
|
@ -627,7 +627,7 @@ defmodule Pleroma.Web.StreamerTest do
|
|||
{:ok, activity} = CommonAPI.post(sender, %{status: "hey"})
|
||||
assert_receive {:text, _}
|
||||
|
||||
{:ok, edited} = CommonAPI.update(sender, activity, %{status: "mew mew"})
|
||||
{:ok, edited} = CommonAPI.update(activity, sender, %{status: "mew mew"})
|
||||
|
||||
edited = Pleroma.Activity.normalize(edited)
|
||||
|
||||
|
|
@ -638,7 +638,7 @@ defmodule Pleroma.Web.StreamerTest do
|
|||
assert %{"id" => ^activity_id} = Jason.decode!(payload)
|
||||
refute Streamer.filtered_by_user?(sender, edited)
|
||||
|
||||
{:ok, edited} = CommonAPI.update(sender, activity, %{status: "mew mew 2"})
|
||||
{:ok, edited} = CommonAPI.update(activity, sender, %{status: "mew mew 2"})
|
||||
|
||||
edited = Pleroma.Activity.normalize(edited)
|
||||
|
||||
|
|
@ -826,8 +826,8 @@ defmodule Pleroma.Web.StreamerTest do
|
|||
test "it filters muted reblogs", %{user: user1, token: user1_token} do
|
||||
user2 = insert(:user)
|
||||
user3 = insert(:user)
|
||||
CommonAPI.follow(user1, user2)
|
||||
CommonAPI.hide_reblogs(user1, user2)
|
||||
CommonAPI.follow(user2, user1)
|
||||
CommonAPI.hide_reblogs(user2, user1)
|
||||
|
||||
{:ok, create_activity} = CommonAPI.post(user3, %{status: "I'm kawen"})
|
||||
|
||||
|
|
@ -842,8 +842,8 @@ defmodule Pleroma.Web.StreamerTest do
|
|||
token: user1_token
|
||||
} do
|
||||
user2 = insert(:user)
|
||||
CommonAPI.follow(user1, user2)
|
||||
CommonAPI.hide_reblogs(user1, user2)
|
||||
CommonAPI.follow(user2, user1)
|
||||
CommonAPI.hide_reblogs(user2, user1)
|
||||
|
||||
{:ok, create_activity} = CommonAPI.post(user1, %{status: "I'm kawen"})
|
||||
Streamer.get_topic_and_add_socket("user", user1, user1_token)
|
||||
|
|
@ -858,12 +858,12 @@ defmodule Pleroma.Web.StreamerTest do
|
|||
token: user1_token
|
||||
} do
|
||||
user2 = insert(:user)
|
||||
CommonAPI.follow(user1, user2)
|
||||
CommonAPI.hide_reblogs(user1, user2)
|
||||
CommonAPI.follow(user2, user1)
|
||||
CommonAPI.hide_reblogs(user2, user1)
|
||||
|
||||
{:ok, create_activity} = CommonAPI.post(user1, %{status: "I'm kawen"})
|
||||
Streamer.get_topic_and_add_socket("user", user1, user1_token)
|
||||
{:ok, _favorite_activity} = CommonAPI.favorite(user2, create_activity.id)
|
||||
{:ok, _favorite_activity} = CommonAPI.favorite(create_activity.id, user2)
|
||||
|
||||
assert_receive {:render_with_user, _, "notification.json", notif, _}
|
||||
refute Streamer.filtered_by_user?(user1, notif)
|
||||
|
|
@ -876,9 +876,9 @@ defmodule Pleroma.Web.StreamerTest do
|
|||
%{user: user2, token: user2_token} = oauth_access(["read"])
|
||||
Streamer.get_topic_and_add_socket("user", user2, user2_token)
|
||||
|
||||
{:ok, user2, user, _activity} = CommonAPI.follow(user2, user)
|
||||
{:ok, user2, user, _activity} = CommonAPI.follow(user, user2)
|
||||
{:ok, activity} = CommonAPI.post(user, %{status: "super hot take"})
|
||||
{:ok, _} = CommonAPI.add_mute(user2, activity)
|
||||
{:ok, _} = CommonAPI.add_mute(activity, user2)
|
||||
|
||||
assert_receive {:render_with_user, _, _, ^activity, _}
|
||||
assert Streamer.filtered_by_user?(user2, activity)
|
||||
|
|
@ -1026,8 +1026,8 @@ defmodule Pleroma.Web.StreamerTest do
|
|||
%{user: user2, token: user2_token} = oauth_access(["read"])
|
||||
|
||||
post_user = insert(:user)
|
||||
CommonAPI.follow(user, post_user)
|
||||
CommonAPI.follow(user2, post_user)
|
||||
CommonAPI.follow(post_user, user)
|
||||
CommonAPI.follow(post_user, user2)
|
||||
|
||||
tasks = [
|
||||
Task.async(child_proc.(starter.(user, token), hit)),
|
||||
|
|
@ -1058,7 +1058,7 @@ defmodule Pleroma.Web.StreamerTest do
|
|||
%{user: user, token: token} = oauth_access(["read"])
|
||||
|
||||
post_user = insert(:user)
|
||||
CommonAPI.follow(user, post_user)
|
||||
CommonAPI.follow(post_user, user)
|
||||
|
||||
tasks = [
|
||||
Task.async(child_proc.(starter.(user, token), hit)),
|
||||
|
|
|
|||
|
|
@ -216,7 +216,7 @@ defmodule Pleroma.Web.TwitterAPI.RemoteFollowControllerTest do
|
|||
test "returns success result when user already in followers", %{conn: conn} do
|
||||
user = insert(:user)
|
||||
user2 = insert(:user)
|
||||
{:ok, _, _, _} = CommonAPI.follow(user, user2)
|
||||
{:ok, _, _, _} = CommonAPI.follow(user2, user)
|
||||
|
||||
conn =
|
||||
conn
|
||||
|
|
|
|||
|
|
@ -213,7 +213,6 @@ defmodule Pleroma.Web.WebFingerTest do
|
|||
end
|
||||
end
|
||||
|
||||
@tag capture_log: true
|
||||
test "prevents forgeries" do
|
||||
Tesla.Mock.mock(fn
|
||||
%{url: "https://fba.ryona.agency/.well-known/webfinger?resource=acct:graf@fba.ryona.agency"} ->
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@ defmodule Pleroma.Workers.PurgeExpiredActivityTest do
|
|||
user = Pleroma.User.get_by_ap_id(activity.actor)
|
||||
Pleroma.Repo.delete(user)
|
||||
|
||||
assert {:error, :user_not_found} =
|
||||
assert {:cancel, :user_not_found} =
|
||||
perform_job(Pleroma.Workers.PurgeExpiredActivity, %{activity_id: activity.id})
|
||||
end
|
||||
|
||||
|
|
@ -53,7 +53,7 @@ defmodule Pleroma.Workers.PurgeExpiredActivityTest do
|
|||
expires_at: DateTime.add(DateTime.utc_now(), 3601)
|
||||
})
|
||||
|
||||
assert {:error, :activity_not_found} =
|
||||
assert {:cancel, :activity_not_found} =
|
||||
perform_job(Pleroma.Workers.PurgeExpiredActivity, %{activity_id: "some_if"})
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ defmodule Pleroma.Workers.ReceiverWorkerTest do
|
|||
import Mock
|
||||
import Pleroma.Factory
|
||||
|
||||
alias Pleroma.Web.Federator
|
||||
alias Pleroma.Workers.ReceiverWorker
|
||||
|
||||
test "it does not retry MRF reject" do
|
||||
|
|
@ -16,7 +17,7 @@ defmodule Pleroma.Workers.ReceiverWorkerTest do
|
|||
|
||||
with_mock Pleroma.Web.ActivityPub.Transmogrifier,
|
||||
handle_incoming: fn _ -> {:reject, "MRF"} end do
|
||||
assert {:cancel, "MRF"} =
|
||||
assert {:cancel, {:reject, "MRF"}} =
|
||||
ReceiverWorker.perform(%Oban.Job{
|
||||
args: %{"op" => "incoming_ap_doc", "params" => params}
|
||||
})
|
||||
|
|
@ -49,4 +50,199 @@ defmodule Pleroma.Workers.ReceiverWorkerTest do
|
|||
args: %{"op" => "incoming_ap_doc", "params" => params}
|
||||
})
|
||||
end
|
||||
|
||||
test "it can validate the signature" do
|
||||
Tesla.Mock.mock(fn
|
||||
%{url: "https://mastodon.social/users/bastianallgeier"} ->
|
||||
%Tesla.Env{
|
||||
status: 200,
|
||||
body: File.read!("test/fixtures/bastianallgeier.json"),
|
||||
headers: [{"content-type", "application/activity+json"}]
|
||||
}
|
||||
|
||||
%{url: "https://mastodon.social/users/bastianallgeier/collections/featured"} ->
|
||||
%Tesla.Env{
|
||||
status: 200,
|
||||
headers: [{"content-type", "application/activity+json"}],
|
||||
body:
|
||||
File.read!("test/fixtures/users_mock/masto_featured.json")
|
||||
|> String.replace("{{domain}}", "mastodon.social")
|
||||
|> String.replace("{{nickname}}", "bastianallgeier")
|
||||
}
|
||||
|
||||
%{url: "https://phpc.social/users/denniskoch"} ->
|
||||
%Tesla.Env{
|
||||
status: 200,
|
||||
body: File.read!("test/fixtures/denniskoch.json"),
|
||||
headers: [{"content-type", "application/activity+json"}]
|
||||
}
|
||||
|
||||
%{url: "https://phpc.social/users/denniskoch/collections/featured"} ->
|
||||
%Tesla.Env{
|
||||
status: 200,
|
||||
headers: [{"content-type", "application/activity+json"}],
|
||||
body:
|
||||
File.read!("test/fixtures/users_mock/masto_featured.json")
|
||||
|> String.replace("{{domain}}", "phpc.social")
|
||||
|> String.replace("{{nickname}}", "denniskoch")
|
||||
}
|
||||
|
||||
%{url: "https://mastodon.social/users/bastianallgeier/statuses/112846516276907281"} ->
|
||||
%Tesla.Env{
|
||||
status: 200,
|
||||
headers: [{"content-type", "application/activity+json"}],
|
||||
body: File.read!("test/fixtures/receiver_worker_signature_activity.json")
|
||||
}
|
||||
end)
|
||||
|
||||
params = %{
|
||||
"@context" => [
|
||||
"https://www.w3.org/ns/activitystreams",
|
||||
"https://w3id.org/security/v1",
|
||||
%{
|
||||
"claim" => %{"@id" => "toot:claim", "@type" => "@id"},
|
||||
"memorial" => "toot:memorial",
|
||||
"atomUri" => "ostatus:atomUri",
|
||||
"manuallyApprovesFollowers" => "as:manuallyApprovesFollowers",
|
||||
"blurhash" => "toot:blurhash",
|
||||
"ostatus" => "http://ostatus.org#",
|
||||
"discoverable" => "toot:discoverable",
|
||||
"focalPoint" => %{"@container" => "@list", "@id" => "toot:focalPoint"},
|
||||
"votersCount" => "toot:votersCount",
|
||||
"Hashtag" => "as:Hashtag",
|
||||
"Emoji" => "toot:Emoji",
|
||||
"alsoKnownAs" => %{"@id" => "as:alsoKnownAs", "@type" => "@id"},
|
||||
"sensitive" => "as:sensitive",
|
||||
"movedTo" => %{"@id" => "as:movedTo", "@type" => "@id"},
|
||||
"inReplyToAtomUri" => "ostatus:inReplyToAtomUri",
|
||||
"conversation" => "ostatus:conversation",
|
||||
"Device" => "toot:Device",
|
||||
"schema" => "http://schema.org#",
|
||||
"toot" => "http://joinmastodon.org/ns#",
|
||||
"cipherText" => "toot:cipherText",
|
||||
"suspended" => "toot:suspended",
|
||||
"messageType" => "toot:messageType",
|
||||
"featuredTags" => %{"@id" => "toot:featuredTags", "@type" => "@id"},
|
||||
"Curve25519Key" => "toot:Curve25519Key",
|
||||
"deviceId" => "toot:deviceId",
|
||||
"Ed25519Signature" => "toot:Ed25519Signature",
|
||||
"featured" => %{"@id" => "toot:featured", "@type" => "@id"},
|
||||
"devices" => %{"@id" => "toot:devices", "@type" => "@id"},
|
||||
"value" => "schema:value",
|
||||
"PropertyValue" => "schema:PropertyValue",
|
||||
"messageFranking" => "toot:messageFranking",
|
||||
"publicKeyBase64" => "toot:publicKeyBase64",
|
||||
"identityKey" => %{"@id" => "toot:identityKey", "@type" => "@id"},
|
||||
"Ed25519Key" => "toot:Ed25519Key",
|
||||
"indexable" => "toot:indexable",
|
||||
"EncryptedMessage" => "toot:EncryptedMessage",
|
||||
"fingerprintKey" => %{"@id" => "toot:fingerprintKey", "@type" => "@id"}
|
||||
}
|
||||
],
|
||||
"actor" => "https://phpc.social/users/denniskoch",
|
||||
"cc" => [
|
||||
"https://phpc.social/users/denniskoch/followers",
|
||||
"https://mastodon.social/users/bastianallgeier",
|
||||
"https://chaos.social/users/distantnative",
|
||||
"https://fosstodon.org/users/kev"
|
||||
],
|
||||
"id" => "https://phpc.social/users/denniskoch/statuses/112847382711461301/activity",
|
||||
"object" => %{
|
||||
"atomUri" => "https://phpc.social/users/denniskoch/statuses/112847382711461301",
|
||||
"attachment" => [],
|
||||
"attributedTo" => "https://phpc.social/users/denniskoch",
|
||||
"cc" => [
|
||||
"https://phpc.social/users/denniskoch/followers",
|
||||
"https://mastodon.social/users/bastianallgeier",
|
||||
"https://chaos.social/users/distantnative",
|
||||
"https://fosstodon.org/users/kev"
|
||||
],
|
||||
"content" =>
|
||||
"<p><span class=\"h-card\" translate=\"no\"><a href=\"https://mastodon.social/@bastianallgeier\" class=\"u-url mention\">@<span>bastianallgeier</span></a></span> <span class=\"h-card\" translate=\"no\"><a href=\"https://chaos.social/@distantnative\" class=\"u-url mention\">@<span>distantnative</span></a></span> <span class=\"h-card\" translate=\"no\"><a href=\"https://fosstodon.org/@kev\" class=\"u-url mention\">@<span>kev</span></a></span> Another main argument: Discord is popular. Many people have an account, so you can just join an server quickly. Also you know the app and how to get around.</p>",
|
||||
"contentMap" => %{
|
||||
"en" =>
|
||||
"<p><span class=\"h-card\" translate=\"no\"><a href=\"https://mastodon.social/@bastianallgeier\" class=\"u-url mention\">@<span>bastianallgeier</span></a></span> <span class=\"h-card\" translate=\"no\"><a href=\"https://chaos.social/@distantnative\" class=\"u-url mention\">@<span>distantnative</span></a></span> <span class=\"h-card\" translate=\"no\"><a href=\"https://fosstodon.org/@kev\" class=\"u-url mention\">@<span>kev</span></a></span> Another main argument: Discord is popular. Many people have an account, so you can just join an server quickly. Also you know the app and how to get around.</p>"
|
||||
},
|
||||
"conversation" =>
|
||||
"tag:mastodon.social,2024-07-25:objectId=760068442:objectType=Conversation",
|
||||
"id" => "https://phpc.social/users/denniskoch/statuses/112847382711461301",
|
||||
"inReplyTo" =>
|
||||
"https://mastodon.social/users/bastianallgeier/statuses/112846516276907281",
|
||||
"inReplyToAtomUri" =>
|
||||
"https://mastodon.social/users/bastianallgeier/statuses/112846516276907281",
|
||||
"published" => "2024-07-25T13:33:29Z",
|
||||
"replies" => %{
|
||||
"first" => %{
|
||||
"items" => [],
|
||||
"next" =>
|
||||
"https://phpc.social/users/denniskoch/statuses/112847382711461301/replies?only_other_accounts=true&page=true",
|
||||
"partOf" =>
|
||||
"https://phpc.social/users/denniskoch/statuses/112847382711461301/replies",
|
||||
"type" => "CollectionPage"
|
||||
},
|
||||
"id" => "https://phpc.social/users/denniskoch/statuses/112847382711461301/replies",
|
||||
"type" => "Collection"
|
||||
},
|
||||
"sensitive" => false,
|
||||
"tag" => [
|
||||
%{
|
||||
"href" => "https://mastodon.social/users/bastianallgeier",
|
||||
"name" => "@bastianallgeier@mastodon.social",
|
||||
"type" => "Mention"
|
||||
},
|
||||
%{
|
||||
"href" => "https://chaos.social/users/distantnative",
|
||||
"name" => "@distantnative@chaos.social",
|
||||
"type" => "Mention"
|
||||
},
|
||||
%{
|
||||
"href" => "https://fosstodon.org/users/kev",
|
||||
"name" => "@kev@fosstodon.org",
|
||||
"type" => "Mention"
|
||||
}
|
||||
],
|
||||
"to" => ["https://www.w3.org/ns/activitystreams#Public"],
|
||||
"type" => "Note",
|
||||
"url" => "https://phpc.social/@denniskoch/112847382711461301"
|
||||
},
|
||||
"published" => "2024-07-25T13:33:29Z",
|
||||
"signature" => %{
|
||||
"created" => "2024-07-25T13:33:29Z",
|
||||
"creator" => "https://phpc.social/users/denniskoch#main-key",
|
||||
"signatureValue" =>
|
||||
"slz9BKJzd2n1S44wdXGOU+bV/wsskdgAaUpwxj8R16mYOL8+DTpE6VnfSKoZGsBBJT8uG5gnVfVEz1YsTUYtymeUgLMh7cvd8VnJnZPS+oixbmBRVky/Myf91TEgQQE7G4vDmTdB4ii54hZrHcOOYYf5FKPNRSkMXboKA6LMqNtekhbI+JTUJYIB02WBBK6PUyo15f6B1RJ6HGWVgud9NE0y1EZXfrkqUt682p8/9D49ORf7AwjXUJibKic2RbPvhEBj70qUGfBm4vvgdWhSUn1IG46xh+U0+NrTSUED82j1ZVOeua/2k/igkGs8cSBkY35quXTkPz6gbqCCH66CuA==",
|
||||
"type" => "RsaSignature2017"
|
||||
},
|
||||
"to" => ["https://www.w3.org/ns/activitystreams#Public"],
|
||||
"type" => "Create"
|
||||
}
|
||||
|
||||
req_headers = [
|
||||
["accept-encoding", "gzip"],
|
||||
["content-length", "5184"],
|
||||
["content-type", "application/activity+json"],
|
||||
["date", "Thu, 25 Jul 2024 13:33:31 GMT"],
|
||||
["digest", "SHA-256=ouge/6HP2/QryG6F3JNtZ6vzs/hSwMk67xdxe87eH7A="],
|
||||
["host", "bikeshed.party"],
|
||||
[
|
||||
"signature",
|
||||
"keyId=\"https://mastodon.social/users/bastianallgeier#main-key\",algorithm=\"rsa-sha256\",headers=\"(request-target) host date digest content-type\",signature=\"ymE3vn5Iw50N6ukSp8oIuXJB5SBjGAGjBasdTDvn+ahZIzq2SIJfmVCsIIzyqIROnhWyQoTbavTclVojEqdaeOx+Ejz2wBnRBmhz5oemJLk4RnnCH0lwMWyzeY98YAvxi9Rq57Gojuv/1lBqyGa+rDzynyJpAMyFk17XIZpjMKuTNMCbjMDy76ILHqArykAIL/v1zxkgwxY/+ELzxqMpNqtZ+kQ29znNMUBB3eVZ/mNAHAz6o33Y9VKxM2jw+08vtuIZOusXyiHbRiaj2g5HtN2WBUw1MzzfRfHF2/yy7rcipobeoyk5RvP5SyHV3WrIeZ3iyoNfmv33y8fxllF0EA==\""
|
||||
],
|
||||
[
|
||||
"user-agent",
|
||||
"http.rb/5.2.0 (Mastodon/4.3.0-nightly.2024-07-25; +https://mastodon.social/)"
|
||||
]
|
||||
]
|
||||
|
||||
{:ok, oban_job} =
|
||||
Federator.incoming_ap_doc(%{
|
||||
method: "POST",
|
||||
req_headers: req_headers,
|
||||
request_path: "/inbox",
|
||||
params: params,
|
||||
query_string: ""
|
||||
})
|
||||
|
||||
assert {:ok, %Pleroma.Activity{}} = ReceiverWorker.perform(oban_job)
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -39,19 +39,19 @@ defmodule Pleroma.Workers.RemoteFetcherWorkerTest do
|
|||
end
|
||||
|
||||
test "does not requeue a deleted object" do
|
||||
assert {:discard, _} =
|
||||
assert {:cancel, _} =
|
||||
RemoteFetcherWorker.perform(%Oban.Job{
|
||||
args: %{"op" => "fetch_remote", "id" => @deleted_object_one}
|
||||
})
|
||||
|
||||
assert {:discard, _} =
|
||||
assert {:cancel, _} =
|
||||
RemoteFetcherWorker.perform(%Oban.Job{
|
||||
args: %{"op" => "fetch_remote", "id" => @deleted_object_two}
|
||||
})
|
||||
end
|
||||
|
||||
test "does not requeue an unauthorized object" do
|
||||
assert {:discard, _} =
|
||||
assert {:cancel, _} =
|
||||
RemoteFetcherWorker.perform(%Oban.Job{
|
||||
args: %{"op" => "fetch_remote", "id" => @unauthorized_object}
|
||||
})
|
||||
|
|
@ -60,7 +60,7 @@ defmodule Pleroma.Workers.RemoteFetcherWorkerTest do
|
|||
test "does not requeue an object that exceeded depth" do
|
||||
clear_config([:instance, :federation_incoming_replies_max_depth], 0)
|
||||
|
||||
assert {:discard, _} =
|
||||
assert {:cancel, _} =
|
||||
RemoteFetcherWorker.perform(%Oban.Job{
|
||||
args: %{"op" => "fetch_remote", "id" => @depth_object, "depth" => 1}
|
||||
})
|
||||
|
|
|
|||
|
|
@ -1742,7 +1742,7 @@ defmodule HttpRequestMock do
|
|||
]
|
||||
|
||||
def head(url, _query, _body, _headers) when url in @rich_media_mocks do
|
||||
{:ok, %Tesla.Env{status: 404, body: ""}}
|
||||
{:ok, %Tesla.Env{status: 200, body: ""}}
|
||||
end
|
||||
|
||||
def head("https://example.com/pdf-file", _, _, _) do
|
||||
|
|
|
|||
|
|
@ -32,6 +32,4 @@ Mox.defmock(Pleroma.StubbedHTTPSignaturesMock, for: Pleroma.HTTPSignaturesAPI)
|
|||
|
||||
Mox.defmock(Pleroma.LoggerMock, for: Pleroma.Logging)
|
||||
|
||||
Mox.defmock(Pleroma.User.Backup.ProcessorMock, for: Pleroma.User.Backup.ProcessorAPI)
|
||||
|
||||
Mox.defmock(Pleroma.Uploaders.S3.ExAwsMock, for: Pleroma.Uploaders.S3.ExAwsAPI)
|
||||
|
|
|
|||
|
|
@ -4,9 +4,9 @@
|
|||
|
||||
Code.put_compiler_option(:warnings_as_errors, true)
|
||||
|
||||
ExUnit.configure(max_cases: System.schedulers_online())
|
||||
ExUnit.configure(capture_log: true, max_cases: System.schedulers_online())
|
||||
|
||||
ExUnit.start(exclude: [:federated, :erratic])
|
||||
ExUnit.start(exclude: [:federated])
|
||||
|
||||
if match?({:unix, :darwin}, :os.type()) do
|
||||
excluded = ExUnit.configuration() |> Keyword.get(:exclude, [])
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue