Merge branch 'develop' into feature/reports-groups-and-multiple-state-update
This commit is contained in:
commit
24eecc3cb4
136 changed files with 864 additions and 320 deletions
|
|
@ -126,9 +126,25 @@ defmodule Pleroma.ActivityTest do
|
|||
}
|
||||
|
||||
{:ok, local_activity} = Pleroma.Web.CommonAPI.post(user, %{"status" => "find me!"})
|
||||
{:ok, japanese_activity} = Pleroma.Web.CommonAPI.post(user, %{"status" => "更新情報"})
|
||||
{:ok, job} = Pleroma.Web.Federator.incoming_ap_doc(params)
|
||||
{:ok, remote_activity} = ObanHelpers.perform(job)
|
||||
%{local_activity: local_activity, remote_activity: remote_activity, user: user}
|
||||
|
||||
%{
|
||||
japanese_activity: japanese_activity,
|
||||
local_activity: local_activity,
|
||||
remote_activity: remote_activity,
|
||||
user: user
|
||||
}
|
||||
end
|
||||
|
||||
test "finds utf8 text in statuses", %{
|
||||
japanese_activity: japanese_activity,
|
||||
user: user
|
||||
} do
|
||||
activities = Activity.search(user, "更新情報")
|
||||
|
||||
assert [^japanese_activity] = activities
|
||||
end
|
||||
|
||||
test "find local and remote statuses for authenticated users", %{
|
||||
|
|
|
|||
4
test/fixtures/tesla_mock/mstdn.jp_host_meta
vendored
Normal file
4
test/fixtures/tesla_mock/mstdn.jp_host_meta
vendored
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<XRD xmlns="http://docs.oasis-open.org/ns/xri/xrd-1.0">
|
||||
<Link rel="lrdd" type="application/xrd+xml" template="https://mstdn.jp/.well-known/webfinger?resource={uri}"/>
|
||||
</XRD>
|
||||
12
test/fixtures/tesla_mock/pekorino@pawoo.net_host_meta.json
vendored
Normal file
12
test/fixtures/tesla_mock/pekorino@pawoo.net_host_meta.json
vendored
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
{
|
||||
"subject":"acct:pekorino@pawoo.net",
|
||||
"aliases":["https://pawoo.net/@pekorino","https://pawoo.net/users/pekorino"],
|
||||
"links":[
|
||||
{"rel":"http://webfinger.net/rel/profile-page","type":"text/html","href":"https://pawoo.net/@pekorino"},
|
||||
{"rel":"http://schemas.google.com/g/2010#updates-from","type":"application/atom+xml","href":"https://pawoo.net/users/pekorino.atom"},
|
||||
{"rel":"self","type":"application/activity+json","href":"https://pawoo.net/users/pekorino"},
|
||||
{"rel":"salmon","href":"https://pawoo.net/api/salmon/128378"},
|
||||
{"rel":"magic-public-key","href":"data:application/magic-public-key,RSA.1x8XXmBqzyb-QRkfUKxKPd7Ac2KbaFhdKy2FkJY64G-ifga-BppzEb62Q5TdkRdVKdHjh5qI7A1Hk3KfnNQcNWqqak-jxII_txC2grbWpp7v-boceD2pnzdVK5l-RR-9wEwxcoCUeRWS1Ak6DStqE5tFQOAK4IIGQB-thSQGlU75KZ-2080fPA3Xc_ycH3_eB4YqawSxXrh6IeScMevN0YHSF84GAcvhXmwLKZRugiF6nYrknbPEe_niIOmN8hhEXLN9_4kDcH83hkVZd5VXssRrxqDhtokx9emvTHkA7sY1AjYeehTPZErlV74GN-kFYLeI6DluXoSI2sX1QcS08w==.AQAB"},
|
||||
{"rel":"http://ostatus.org/schema/1.0/subscribe","template":"https://pawoo.net/authorize_follow?acct={uri}"}
|
||||
]
|
||||
}
|
||||
4
test/fixtures/tesla_mock/sdf.org_host_meta
vendored
Normal file
4
test/fixtures/tesla_mock/sdf.org_host_meta
vendored
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<XRD xmlns="http://docs.oasis-open.org/ns/xri/xrd-1.0">
|
||||
<Link rel="lrdd" type="application/xrd+xml" template="https://mastodon.sdf.org/.well-known/webfinger?resource={uri}"/>
|
||||
</XRD>
|
||||
12
test/fixtures/tesla_mock/snowdusk@sdf.org_host_meta.json
vendored
Normal file
12
test/fixtures/tesla_mock/snowdusk@sdf.org_host_meta.json
vendored
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
{
|
||||
"subject":"acct:snowdusk@mastodon.sdf.org",
|
||||
"aliases":["https://mastodon.sdf.org/@snowdusk","https://mastodon.sdf.org/users/snowdusk"],
|
||||
"links":[
|
||||
{"rel":"http://webfinger.net/rel/profile-page","type":"text/html","href":"https://mastodon.sdf.org/@snowdusk"},
|
||||
{"rel":"http://schemas.google.com/g/2010#updates-from","type":"application/atom+xml","href":"https://mastodon.sdf.org/users/snowdusk.atom"},
|
||||
{"rel":"self","type":"application/activity+json","href":"https://mastodon.sdf.org/users/snowdusk"},
|
||||
{"rel":"salmon","href":"https://mastodon.sdf.org/api/salmon/2"},
|
||||
{"rel":"magic-public-key","href":"data:application/magic-public-key,RSA.k4_Hr0WQUHumAD4uwWIz7OybovIKgIuanbXhX5pl7oGyb2TuifBf3nAqEhD6eLSo6-_6160L4BvPPV_l_6rlZEi6_nbeJUgVkayZgcZN3oou3IErSt8L0IbUdWT5s4fWM2zpkndLCkVbeeNQ3DOBccvJw7iA_QNTao8wr3ILvQaKEDnf-H5QBd9Tj3seyo4-7E0e6wCKOH_uBm8pSRgpdMdl2CehiFzaABBkmCeUKH-buU7iNQGi0fsV5VIHn6zffrv6p0EVNkjTDi1vTmmfrp9W0mcKZJ9DtvdehOKSgh3J7Mem-ILbPy6FSL2Oi6Ekj_Wh4M8Ie-YKuxI3N_0Baw==.AQAB"},
|
||||
{"rel":"http://ostatus.org/schema/1.0/subscribe","template":"https://mastodon.sdf.org/authorize_interaction?uri={uri}"}
|
||||
]
|
||||
}
|
||||
4
test/fixtures/tesla_mock/soykaf.com_host_meta
vendored
Normal file
4
test/fixtures/tesla_mock/soykaf.com_host_meta
vendored
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<XRD xmlns="http://docs.oasis-open.org/ns/xri/xrd-1.0">
|
||||
<Link rel="lrdd" template="https://pleroma.soykaf.com/.well-known/webfinger?resource={uri}" type="application/xrd+xml" />
|
||||
</XRD>
|
||||
31
test/fixtures/tesla_mock/stopwatchingus-heidelberg.de_host_meta
vendored
Normal file
31
test/fixtures/tesla_mock/stopwatchingus-heidelberg.de_host_meta
vendored
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
{
|
||||
"links":[
|
||||
{
|
||||
"rel":"lrdd",
|
||||
"type":"application\/jrd+json",
|
||||
"template":"https:\/\/social.stopwatchingus-heidelberg.de\/.well-known\/webfinger?resource={uri}"
|
||||
},
|
||||
{
|
||||
"rel":"lrdd",
|
||||
"type":"application\/json",
|
||||
"template":"https:\/\/social.stopwatchingus-heidelberg.de\/.well-known\/webfinger?resource={uri}"
|
||||
},
|
||||
{
|
||||
"rel":"lrdd",
|
||||
"type":"application\/xrd+xml",
|
||||
"template":"https:\/\/social.stopwatchingus-heidelberg.de\/.well-known\/webfinger?resource={uri}"
|
||||
},
|
||||
{
|
||||
"rel":"http:\/\/apinamespace.org\/oauth\/access_token",
|
||||
"href":"https:\/\/social.stopwatchingus-heidelberg.de\/api\/oauth\/access_token"
|
||||
},
|
||||
{
|
||||
"rel":"http:\/\/apinamespace.org\/oauth\/request_token",
|
||||
"href":"https:\/\/social.stopwatchingus-heidelberg.de\/api\/oauth\/request_token"
|
||||
},
|
||||
{
|
||||
"rel":"http:\/\/apinamespace.org\/oauth\/authorize",
|
||||
"href":"https:\/\/social.stopwatchingus-heidelberg.de\/api\/oauth\/authorize"
|
||||
}
|
||||
]
|
||||
}
|
||||
4
test/fixtures/tesla_mock/xn--q9jyb4c_host_meta
vendored
Normal file
4
test/fixtures/tesla_mock/xn--q9jyb4c_host_meta
vendored
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<XRD xmlns="http://docs.oasis-open.org/ns/xri/xrd-1.0">
|
||||
<Link rel="lrdd" template="https://zetsubou.xn--q9jyb4c/.well-known/webfinger?resource={uri}" type="application/xrd+xml" />
|
||||
</XRD>
|
||||
|
|
@ -344,6 +344,181 @@ defmodule HttpRequestMock do
|
|||
{:error, :nxdomain}
|
||||
end
|
||||
|
||||
def get("http://osada.macgirvin.com/.well-known/host-meta", _, _, _) do
|
||||
{:ok,
|
||||
%Tesla.Env{
|
||||
status: 404,
|
||||
body: ""
|
||||
}}
|
||||
end
|
||||
|
||||
def get("https://osada.macgirvin.com/.well-known/host-meta", _, _, _) do
|
||||
{:ok,
|
||||
%Tesla.Env{
|
||||
status: 404,
|
||||
body: ""
|
||||
}}
|
||||
end
|
||||
|
||||
def get("http://mastodon.sdf.org/.well-known/host-meta", _, _, _) do
|
||||
{:ok,
|
||||
%Tesla.Env{
|
||||
status: 200,
|
||||
body: File.read!("test/fixtures/tesla_mock/sdf.org_host_meta")
|
||||
}}
|
||||
end
|
||||
|
||||
def get("https://mastodon.sdf.org/.well-known/host-meta", _, _, _) do
|
||||
{:ok,
|
||||
%Tesla.Env{
|
||||
status: 200,
|
||||
body: File.read!("test/fixtures/tesla_mock/sdf.org_host_meta")
|
||||
}}
|
||||
end
|
||||
|
||||
def get(
|
||||
"https://mastodon.sdf.org/.well-known/webfinger?resource=https://mastodon.sdf.org/users/snowdusk",
|
||||
_,
|
||||
_,
|
||||
_
|
||||
) do
|
||||
{:ok,
|
||||
%Tesla.Env{
|
||||
status: 200,
|
||||
body: File.read!("test/fixtures/tesla_mock/snowdusk@sdf.org_host_meta.json")
|
||||
}}
|
||||
end
|
||||
|
||||
def get("http://mstdn.jp/.well-known/host-meta", _, _, _) do
|
||||
{:ok,
|
||||
%Tesla.Env{
|
||||
status: 200,
|
||||
body: File.read!("test/fixtures/tesla_mock/mstdn.jp_host_meta")
|
||||
}}
|
||||
end
|
||||
|
||||
def get("https://mstdn.jp/.well-known/host-meta", _, _, _) do
|
||||
{:ok,
|
||||
%Tesla.Env{
|
||||
status: 200,
|
||||
body: File.read!("test/fixtures/tesla_mock/mstdn.jp_host_meta")
|
||||
}}
|
||||
end
|
||||
|
||||
def get("https://mstdn.jp/.well-known/webfinger?resource=kpherox@mstdn.jp", _, _, _) do
|
||||
{:ok,
|
||||
%Tesla.Env{
|
||||
status: 200,
|
||||
body: File.read!("test/fixtures/tesla_mock/kpherox@mstdn.jp.xml")
|
||||
}}
|
||||
end
|
||||
|
||||
def get("http://mamot.fr/.well-known/host-meta", _, _, _) do
|
||||
{:ok,
|
||||
%Tesla.Env{
|
||||
status: 200,
|
||||
body: File.read!("test/fixtures/tesla_mock/mamot.fr_host_meta")
|
||||
}}
|
||||
end
|
||||
|
||||
def get("https://mamot.fr/.well-known/host-meta", _, _, _) do
|
||||
{:ok,
|
||||
%Tesla.Env{
|
||||
status: 200,
|
||||
body: File.read!("test/fixtures/tesla_mock/mamot.fr_host_meta")
|
||||
}}
|
||||
end
|
||||
|
||||
def get(
|
||||
"https://mamot.fr/.well-known/webfinger?resource=https://mamot.fr/users/Skruyb",
|
||||
_,
|
||||
_,
|
||||
_
|
||||
) do
|
||||
{:ok,
|
||||
%Tesla.Env{
|
||||
status: 200,
|
||||
body: File.read!("test/fixtures/tesla_mock/skruyb@mamot.fr.atom")
|
||||
}}
|
||||
end
|
||||
|
||||
def get("http://pawoo.net/.well-known/host-meta", _, _, _) do
|
||||
{:ok,
|
||||
%Tesla.Env{
|
||||
status: 200,
|
||||
body: File.read!("test/fixtures/tesla_mock/pawoo.net_host_meta")
|
||||
}}
|
||||
end
|
||||
|
||||
def get("https://pawoo.net/.well-known/host-meta", _, _, _) do
|
||||
{:ok,
|
||||
%Tesla.Env{
|
||||
status: 200,
|
||||
body: File.read!("test/fixtures/tesla_mock/pawoo.net_host_meta")
|
||||
}}
|
||||
end
|
||||
|
||||
def get(
|
||||
"https://pawoo.net/.well-known/webfinger?resource=https://pawoo.net/users/pekorino",
|
||||
_,
|
||||
_,
|
||||
_
|
||||
) do
|
||||
{:ok,
|
||||
%Tesla.Env{
|
||||
status: 200,
|
||||
body: File.read!("test/fixtures/tesla_mock/pekorino@pawoo.net_host_meta.json")
|
||||
}}
|
||||
end
|
||||
|
||||
def get("http://zetsubou.xn--q9jyb4c/.well-known/host-meta", _, _, _) do
|
||||
{:ok,
|
||||
%Tesla.Env{
|
||||
status: 200,
|
||||
body: File.read!("test/fixtures/tesla_mock/xn--q9jyb4c_host_meta")
|
||||
}}
|
||||
end
|
||||
|
||||
def get("https://zetsubou.xn--q9jyb4c/.well-known/host-meta", _, _, _) do
|
||||
{:ok,
|
||||
%Tesla.Env{
|
||||
status: 200,
|
||||
body: File.read!("test/fixtures/tesla_mock/xn--q9jyb4c_host_meta")
|
||||
}}
|
||||
end
|
||||
|
||||
def get("http://pleroma.soykaf.com/.well-known/host-meta", _, _, _) do
|
||||
{:ok,
|
||||
%Tesla.Env{
|
||||
status: 200,
|
||||
body: File.read!("test/fixtures/tesla_mock/soykaf.com_host_meta")
|
||||
}}
|
||||
end
|
||||
|
||||
def get("https://pleroma.soykaf.com/.well-known/host-meta", _, _, _) do
|
||||
{:ok,
|
||||
%Tesla.Env{
|
||||
status: 200,
|
||||
body: File.read!("test/fixtures/tesla_mock/soykaf.com_host_meta")
|
||||
}}
|
||||
end
|
||||
|
||||
def get("http://social.stopwatchingus-heidelberg.de/.well-known/host-meta", _, _, _) do
|
||||
{:ok,
|
||||
%Tesla.Env{
|
||||
status: 200,
|
||||
body: File.read!("test/fixtures/tesla_mock/stopwatchingus-heidelberg.de_host_meta")
|
||||
}}
|
||||
end
|
||||
|
||||
def get("https://social.stopwatchingus-heidelberg.de/.well-known/host-meta", _, _, _) do
|
||||
{:ok,
|
||||
%Tesla.Env{
|
||||
status: 200,
|
||||
body: File.read!("test/fixtures/tesla_mock/stopwatchingus-heidelberg.de_host_meta")
|
||||
}}
|
||||
end
|
||||
|
||||
def get(
|
||||
"http://mastodon.example.org/@admin/99541947525187367",
|
||||
_,
|
||||
|
|
|
|||
39
test/tasks/count_statuses_test.exs
Normal file
39
test/tasks/count_statuses_test.exs
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
# Pleroma: A lightweight social networking server
|
||||
# Copyright © 2017-2019 Pleroma Authors <https://pleroma.social/>
|
||||
# SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
defmodule Mix.Tasks.Pleroma.CountStatusesTest do
|
||||
use Pleroma.DataCase
|
||||
|
||||
alias Pleroma.User
|
||||
alias Pleroma.Web.CommonAPI
|
||||
|
||||
import ExUnit.CaptureIO, only: [capture_io: 1]
|
||||
import Pleroma.Factory
|
||||
|
||||
test "counts statuses" do
|
||||
user = insert(:user)
|
||||
{:ok, _} = CommonAPI.post(user, %{"status" => "test"})
|
||||
{:ok, _} = CommonAPI.post(user, %{"status" => "test2"})
|
||||
|
||||
user2 = insert(:user)
|
||||
{:ok, _} = CommonAPI.post(user2, %{"status" => "test3"})
|
||||
|
||||
user = refresh_record(user)
|
||||
user2 = refresh_record(user2)
|
||||
|
||||
assert %{info: %{note_count: 2}} = user
|
||||
assert %{info: %{note_count: 1}} = user2
|
||||
|
||||
{:ok, user} = User.update_info(user, &User.Info.set_note_count(&1, 0))
|
||||
{:ok, user2} = User.update_info(user2, &User.Info.set_note_count(&1, 0))
|
||||
|
||||
assert %{info: %{note_count: 0}} = user
|
||||
assert %{info: %{note_count: 0}} = user2
|
||||
|
||||
assert capture_io(fn -> Mix.Tasks.Pleroma.CountStatuses.run([]) end) == "Done\n"
|
||||
|
||||
assert %{info: %{note_count: 2}} = refresh_record(user)
|
||||
assert %{info: %{note_count: 1}} = refresh_record(user2)
|
||||
end
|
||||
end
|
||||
|
|
@ -40,7 +40,7 @@ defmodule Pleroma.Web.MastodonAPI.SearchControllerTest do
|
|||
test "search", %{conn: conn} do
|
||||
user = insert(:user)
|
||||
user_two = insert(:user, %{nickname: "shp@shitposter.club"})
|
||||
user_three = insert(:user, %{nickname: "shp@heldscal.la", name: "I love 2hu"})
|
||||
user_three = insert(:user, %{nickname: "shp@heldscal.la", name: "I love 2hu 天子"})
|
||||
|
||||
{:ok, activity} = CommonAPI.post(user, %{"status" => "This is about 2hu private"})
|
||||
|
||||
|
|
@ -52,9 +52,9 @@ defmodule Pleroma.Web.MastodonAPI.SearchControllerTest do
|
|||
|
||||
{:ok, _} = CommonAPI.post(user_two, %{"status" => "This isn't"})
|
||||
|
||||
conn = get(conn, "/api/v2/search", %{"q" => "2hu #private"})
|
||||
|
||||
assert results = json_response(conn, 200)
|
||||
results =
|
||||
get(conn, "/api/v2/search", %{"q" => "2hu #private"})
|
||||
|> json_response(200)
|
||||
|
||||
[account | _] = results["accounts"]
|
||||
assert account["id"] == to_string(user_three.id)
|
||||
|
|
@ -65,6 +65,13 @@ defmodule Pleroma.Web.MastodonAPI.SearchControllerTest do
|
|||
|
||||
[status] = results["statuses"]
|
||||
assert status["id"] == to_string(activity.id)
|
||||
|
||||
results =
|
||||
get(conn, "/api/v2/search", %{"q" => "天子"})
|
||||
|> json_response(200)
|
||||
|
||||
[account] == results["accounts"]
|
||||
assert account["id"] == to_string(user_three.id)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ defmodule Pleroma.Web.MastodonAPI.StatusControllerTest do
|
|||
alias Pleroma.Activity
|
||||
alias Pleroma.ActivityExpiration
|
||||
alias Pleroma.Config
|
||||
alias Pleroma.Conversation.Participation
|
||||
alias Pleroma.Object
|
||||
alias Pleroma.Repo
|
||||
alias Pleroma.ScheduledActivity
|
||||
|
|
@ -465,6 +466,24 @@ defmodule Pleroma.Web.MastodonAPI.StatusControllerTest do
|
|||
assert id == to_string(activity.id)
|
||||
end
|
||||
|
||||
test "get a direct status", %{conn: conn} do
|
||||
user = insert(:user)
|
||||
other_user = insert(:user)
|
||||
|
||||
{:ok, activity} =
|
||||
CommonAPI.post(user, %{"status" => "@#{other_user.nickname}", "visibility" => "direct"})
|
||||
|
||||
conn =
|
||||
conn
|
||||
|> assign(:user, user)
|
||||
|> get("/api/v1/statuses/#{activity.id}")
|
||||
|
||||
[participation] = Participation.for_user(user)
|
||||
|
||||
res = json_response(conn, 200)
|
||||
assert res["pleroma"]["direct_conversation_id"] == participation.id
|
||||
end
|
||||
|
||||
test "get statuses by IDs", %{conn: conn} do
|
||||
%{id: id1} = insert(:note_activity)
|
||||
%{id: id2} = insert(:note_activity)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue