Fix more specs.
This commit is contained in:
parent
d3b0167854
commit
4ea2a41014
|
@ -136,7 +136,7 @@ def to_map(%Activity{data: %{"object" => %{"content" => content} = object}} = ac
|
||||||
tags = activity.data["object"]["tag"] || []
|
tags = activity.data["object"]["tag"] || []
|
||||||
possibly_sensitive = activity.data["object"]["sensitive"] || Enum.member?(tags, "nsfw")
|
possibly_sensitive = activity.data["object"]["sensitive"] || Enum.member?(tags, "nsfw")
|
||||||
|
|
||||||
tags = if possibly_sensitive, do: ["nsfw" | tags], else: tags
|
tags = if possibly_sensitive, do: Enum.uniq(["nsfw" | tags]), else: tags
|
||||||
|
|
||||||
summary = activity.data["object"]["summary"]
|
summary = activity.data["object"]["summary"]
|
||||||
content = if !!summary and summary != "" do
|
content = if !!summary and summary != "" do
|
||||||
|
|
|
@ -44,7 +44,7 @@ def fetch_public_and_external_statuses(user, opts \\ %{}) do
|
||||||
def fetch_user_statuses(user, opts \\ %{}) do
|
def fetch_user_statuses(user, opts \\ %{}) do
|
||||||
opts = opts
|
opts = opts
|
||||||
|> Map.put("type", ["Create", "Announce", "Follow"])
|
|> Map.put("type", ["Create", "Announce", "Follow"])
|
||||||
ActivityPub.fetch_activities([], opts)
|
ActivityPub.fetch_public_activities(opts)
|
||||||
|> activities_to_statuses(%{for: user})
|
|> activities_to_statuses(%{for: user})
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -8,9 +8,11 @@ def build(data \\ %{}, opts \\ %{}) do
|
||||||
"id" => Pleroma.Web.ActivityPub.Utils.generate_object_id,
|
"id" => Pleroma.Web.ActivityPub.Utils.generate_object_id,
|
||||||
"actor" => user.ap_id,
|
"actor" => user.ap_id,
|
||||||
"to" => ["https://www.w3.org/ns/activitystreams#Public"],
|
"to" => ["https://www.w3.org/ns/activitystreams#Public"],
|
||||||
|
"type" => "Create",
|
||||||
"object" => %{
|
"object" => %{
|
||||||
"type" => "Note",
|
"type" => "Note",
|
||||||
"content" => "test"
|
"content" => "test",
|
||||||
|
"to" => ["https://www.w3.org/ns/activitystreams#Public"],
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Map.merge(activity, data)
|
Map.merge(activity, data)
|
||||||
|
@ -23,7 +25,7 @@ def insert(data \\ %{}, opts \\ %{}) do
|
||||||
|
|
||||||
def insert_list(times, data \\ %{}, opts \\ %{}) do
|
def insert_list(times, data \\ %{}, opts \\ %{}) do
|
||||||
Enum.map(1..times, fn (n) ->
|
Enum.map(1..times, fn (n) ->
|
||||||
{:ok, activity} = insert(data)
|
{:ok, activity} = insert(data, opts)
|
||||||
activity
|
activity
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
@ -32,7 +34,7 @@ def public_and_non_public do
|
||||||
user = Pleroma.Factory.insert(:user)
|
user = Pleroma.Factory.insert(:user)
|
||||||
|
|
||||||
public = build(%{"id" => 1}, %{user: user})
|
public = build(%{"id" => 1}, %{user: user})
|
||||||
non_public = build(%{"id" => 2, "to" => []}, %{user: user})
|
non_public = build(%{"id" => 2, "to" => [user.follower_address]}, %{user: user})
|
||||||
|
|
||||||
{:ok, public} = ActivityPub.insert(public)
|
{:ok, public} = ActivityPub.insert(public)
|
||||||
{:ok, non_public} = ActivityPub.insert(non_public)
|
{:ok, non_public} = ActivityPub.insert(non_public)
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -75,17 +75,17 @@ test "an activity" do
|
||||||
date = DateTime.from_naive!(~N[2016-05-24 13:26:08.003], "Etc/UTC") |> DateTime.to_iso8601
|
date = DateTime.from_naive!(~N[2016-05-24 13:26:08.003], "Etc/UTC") |> DateTime.to_iso8601
|
||||||
|
|
||||||
{:ok, convo_object} = Object.context_mapping("2hu") |> Repo.insert
|
{:ok, convo_object} = Object.context_mapping("2hu") |> Repo.insert
|
||||||
|
to = [
|
||||||
|
User.ap_followers(user),
|
||||||
|
"https://www.w3.org/ns/activitystreams#Public",
|
||||||
|
mentioned_user.ap_id
|
||||||
|
]
|
||||||
activity = %Activity{
|
activity = %Activity{
|
||||||
id: 1,
|
id: 1,
|
||||||
data: %{
|
data: %{
|
||||||
"type" => "Create",
|
"type" => "Create",
|
||||||
"id" => "id",
|
"id" => "id",
|
||||||
"to" => [
|
"to" => to,
|
||||||
User.ap_followers(user),
|
|
||||||
"https://www.w3.org/ns/activitystreams#Public",
|
|
||||||
mentioned_user.ap_id
|
|
||||||
],
|
|
||||||
"actor" => User.ap_id(user),
|
"actor" => User.ap_id(user),
|
||||||
"object" => %{
|
"object" => %{
|
||||||
"published" => date,
|
"published" => date,
|
||||||
|
@ -108,7 +108,8 @@ test "an activity" do
|
||||||
"published" => date,
|
"published" => date,
|
||||||
"context" => "2hu"
|
"context" => "2hu"
|
||||||
},
|
},
|
||||||
local: false
|
local: false,
|
||||||
|
recipients: to
|
||||||
}
|
}
|
||||||
|
|
||||||
expected_html = "<span>2hu</span><br />alert('YAY')Some <img height='32px' width='32px' alt='2hu' title='2hu' src='corndog.png' /> content mentioning <a href=\"#{mentioned_user.ap_id}\">@shp</a>"
|
expected_html = "<span>2hu</span><br />alert('YAY')Some <img height='32px' width='32px' alt='2hu' title='2hu' src='corndog.png' /> content mentioning <a href=\"#{mentioned_user.ap_id}\">@shp</a>"
|
||||||
|
@ -134,7 +135,7 @@ test "an activity" do
|
||||||
"favorited" => false,
|
"favorited" => false,
|
||||||
"repeated" => false,
|
"repeated" => false,
|
||||||
"external_url" => "some url",
|
"external_url" => "some url",
|
||||||
"tags" => ["content", "mentioning", "nsfw"],
|
"tags" => ["nsfw", "content", "mentioning"],
|
||||||
"activity_type" => "post",
|
"activity_type" => "post",
|
||||||
"possibly_sensitive" => true,
|
"possibly_sensitive" => true,
|
||||||
"uri" => activity.data["object"]["id"]
|
"uri" => activity.data["object"]["id"]
|
||||||
|
|
|
@ -218,6 +218,7 @@ test "without any params", %{conn: conn} do
|
||||||
test "with user_id", %{conn: conn} do
|
test "with user_id", %{conn: conn} do
|
||||||
user = insert(:user)
|
user = insert(:user)
|
||||||
{:ok, activity} = ActivityBuilder.insert(%{"id" => 1}, %{user: user})
|
{:ok, activity} = ActivityBuilder.insert(%{"id" => 1}, %{user: user})
|
||||||
|
|> IO.inspect
|
||||||
|
|
||||||
conn = get(conn, "/api/statuses/user_timeline.json", %{"user_id" => user.id})
|
conn = get(conn, "/api/statuses/user_timeline.json", %{"user_id" => user.id})
|
||||||
response = json_response(conn, 200)
|
response = json_response(conn, 200)
|
||||||
|
@ -376,9 +377,10 @@ test "without valid credentials", %{conn: conn} do
|
||||||
end
|
end
|
||||||
|
|
||||||
test "with credentials", %{conn: conn, user: current_user} do
|
test "with credentials", %{conn: conn, user: current_user} do
|
||||||
|
avatar_image = File.read!("test/fixtures/avatar_data_uri")
|
||||||
conn = conn
|
conn = conn
|
||||||
|> with_credentials(current_user.nickname, "test")
|
|> with_credentials(current_user.nickname, "test")
|
||||||
|> post("/api/qvitter/update_avatar.json", %{img: Pleroma.Web.ActivityPub.ActivityPubTest.data_uri})
|
|> post("/api/qvitter/update_avatar.json", %{img: avatar_image})
|
||||||
|
|
||||||
current_user = Repo.get(User, current_user.id)
|
current_user = Repo.get(User, current_user.id)
|
||||||
assert is_map(current_user.avatar)
|
assert is_map(current_user.avatar)
|
||||||
|
|
|
@ -38,9 +38,9 @@ test "create a status" do
|
||||||
assert get_in(activity.data, ["object", "type"]) == "Note"
|
assert get_in(activity.data, ["object", "type"]) == "Note"
|
||||||
assert get_in(activity.data, ["object", "actor"]) == user.ap_id
|
assert get_in(activity.data, ["object", "actor"]) == user.ap_id
|
||||||
assert get_in(activity.data, ["actor"]) == user.ap_id
|
assert get_in(activity.data, ["actor"]) == user.ap_id
|
||||||
assert Enum.member?(get_in(activity.data, ["to"]), User.ap_followers(user))
|
assert Enum.member?(get_in(activity.data, ["cc"]), User.ap_followers(user))
|
||||||
assert Enum.member?(get_in(activity.data, ["to"]), "https://www.w3.org/ns/activitystreams#Public")
|
assert Enum.member?(get_in(activity.data, ["to"]), "https://www.w3.org/ns/activitystreams#Public")
|
||||||
assert Enum.member?(get_in(activity.data, ["to"]), "shp")
|
assert Enum.member?(get_in(activity.data, ["cc"]), "shp")
|
||||||
assert activity.local == true
|
assert activity.local == true
|
||||||
|
|
||||||
assert %{"moominmamma" => "http://localhost:4001/finmoji/128px/moominmamma-128.png"} = activity.data["object"]["emoji"]
|
assert %{"moominmamma" => "http://localhost:4001/finmoji/128px/moominmamma-128.png"} = activity.data["object"]["emoji"]
|
||||||
|
@ -80,7 +80,6 @@ test "create a status that is a reply" do
|
||||||
assert get_in(reply.data, ["object", "context"]) == get_in(activity.data, ["object", "context"])
|
assert get_in(reply.data, ["object", "context"]) == get_in(activity.data, ["object", "context"])
|
||||||
assert get_in(reply.data, ["object", "inReplyTo"]) == get_in(activity.data, ["object", "id"])
|
assert get_in(reply.data, ["object", "inReplyTo"]) == get_in(activity.data, ["object", "id"])
|
||||||
assert get_in(reply.data, ["object", "inReplyToStatusId"]) == activity.id
|
assert get_in(reply.data, ["object", "inReplyToStatusId"]) == activity.id
|
||||||
assert Enum.member?(get_in(reply.data, ["to"]), user.ap_id)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
test "fetch public statuses, excluding remote ones." do
|
test "fetch public statuses, excluding remote ones." do
|
||||||
|
@ -99,7 +98,7 @@ test "fetch whole known network statuses" do
|
||||||
%{ public: activity, user: user } = ActivityBuilder.public_and_non_public
|
%{ public: activity, user: user } = ActivityBuilder.public_and_non_public
|
||||||
insert(:note_activity, %{local: false})
|
insert(:note_activity, %{local: false})
|
||||||
|
|
||||||
follower = insert(:user, following: [User.ap_followers(user)])
|
follower = insert(:user, following: [user.follower_address])
|
||||||
|
|
||||||
statuses = TwitterAPI.fetch_public_and_external_statuses(follower)
|
statuses = TwitterAPI.fetch_public_and_external_statuses(follower)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue