2017-04-24 18:46:34 +02:00
|
|
|
defmodule Pleroma.Web.OStatusTest do
|
|
|
|
use Pleroma.DataCase
|
|
|
|
alias Pleroma.Web.OStatus
|
2017-05-02 17:13:41 +02:00
|
|
|
alias Pleroma.Web.XML
|
2017-05-08 18:19:45 +02:00
|
|
|
alias Pleroma.{Object, Repo, User, Activity}
|
2017-05-05 16:27:03 +02:00
|
|
|
import Pleroma.Factory
|
2018-02-12 10:13:54 +01:00
|
|
|
import ExUnit.CaptureLog
|
2017-04-24 18:46:34 +02:00
|
|
|
|
2017-04-30 12:36:47 +02:00
|
|
|
test "don't insert create notes twice" do
|
|
|
|
incoming = File.read!("test/fixtures/incoming_note_activity.xml")
|
2017-05-08 18:19:45 +02:00
|
|
|
{:ok, [activity]} = OStatus.handle_incoming(incoming)
|
|
|
|
assert {:ok, [activity]} == OStatus.handle_incoming(incoming)
|
2017-04-30 12:36:47 +02:00
|
|
|
end
|
|
|
|
|
2017-04-29 21:13:21 +02:00
|
|
|
test "handle incoming note - GS, Salmon" do
|
2017-04-24 18:46:34 +02:00
|
|
|
incoming = File.read!("test/fixtures/incoming_note_activity.xml")
|
2017-04-29 21:13:21 +02:00
|
|
|
{:ok, [activity]} = OStatus.handle_incoming(incoming)
|
2017-04-24 18:46:34 +02:00
|
|
|
|
2017-07-22 17:42:15 +02:00
|
|
|
user = User.get_by_ap_id(activity.data["actor"])
|
|
|
|
assert user.info["note_count"] == 1
|
2017-04-24 18:46:34 +02:00
|
|
|
assert activity.data["type"] == "Create"
|
|
|
|
assert activity.data["object"]["type"] == "Note"
|
2017-04-30 11:55:19 +02:00
|
|
|
assert activity.data["object"]["id"] == "tag:gs.example.org:4040,2017-04-23:noticeId=29:objectType=note"
|
2017-04-24 18:46:34 +02:00
|
|
|
assert activity.data["published"] == "2017-04-23T14:51:03+00:00"
|
2017-06-08 16:44:12 +02:00
|
|
|
assert activity.data["object"]["published"] == "2017-04-23T14:51:03+00:00"
|
2017-04-25 17:45:34 +02:00
|
|
|
assert activity.data["context"] == "tag:gs.example.org:4040,2017-04-23:objectType=thread:nonce=f09e22f58abd5c7b"
|
2017-04-25 18:03:14 +02:00
|
|
|
assert "http://pleroma.example.org:4000/users/lain3" in activity.data["to"]
|
2017-09-16 16:27:48 +02:00
|
|
|
assert activity.data["object"]["emoji"] == %{ "marko" => "marko.png", "reimu" => "reimu.png" }
|
2017-05-02 10:47:04 +02:00
|
|
|
assert activity.local == false
|
2017-04-24 18:46:34 +02:00
|
|
|
end
|
|
|
|
|
2017-04-29 21:13:21 +02:00
|
|
|
test "handle incoming notes - GS, subscription" do
|
|
|
|
incoming = File.read!("test/fixtures/ostatus_incoming_post.xml")
|
|
|
|
{:ok, [activity]} = OStatus.handle_incoming(incoming)
|
|
|
|
|
|
|
|
assert activity.data["type"] == "Create"
|
|
|
|
assert activity.data["object"]["type"] == "Note"
|
|
|
|
assert activity.data["object"]["actor"] == "https://social.heldscal.la/user/23211"
|
|
|
|
assert activity.data["object"]["content"] == "Will it blend?"
|
2017-05-06 14:23:39 +02:00
|
|
|
user = User.get_cached_by_ap_id(activity.data["actor"])
|
|
|
|
assert User.ap_followers(user) in activity.data["to"]
|
2017-06-30 16:08:59 +02:00
|
|
|
assert "https://www.w3.org/ns/activitystreams#Public" in activity.data["to"]
|
2017-04-29 21:13:21 +02:00
|
|
|
end
|
|
|
|
|
2017-05-03 14:26:49 +02:00
|
|
|
test "handle incoming notes with attachments - GS, subscription" do
|
|
|
|
incoming = File.read!("test/fixtures/incoming_websub_gnusocial_attachments.xml")
|
|
|
|
{:ok, [activity]} = OStatus.handle_incoming(incoming)
|
|
|
|
|
|
|
|
assert activity.data["type"] == "Create"
|
|
|
|
assert activity.data["object"]["type"] == "Note"
|
|
|
|
assert activity.data["object"]["actor"] == "https://social.heldscal.la/user/23211"
|
|
|
|
assert activity.data["object"]["attachment"] |> length == 2
|
2017-06-25 11:57:34 +02:00
|
|
|
assert activity.data["object"]["external_url"] == "https://social.heldscal.la/notice/2020923"
|
2017-06-30 16:08:59 +02:00
|
|
|
assert "https://www.w3.org/ns/activitystreams#Public" in activity.data["to"]
|
2017-05-03 14:26:49 +02:00
|
|
|
end
|
|
|
|
|
2017-05-18 15:58:18 +02:00
|
|
|
test "handle incoming notes with tags" do
|
|
|
|
incoming = File.read!("test/fixtures/ostatus_incoming_post_tag.xml")
|
|
|
|
{:ok, [activity]} = OStatus.handle_incoming(incoming)
|
|
|
|
|
|
|
|
assert activity.data["object"]["tag"] == ["nsfw"]
|
2017-06-30 16:08:59 +02:00
|
|
|
assert "https://www.w3.org/ns/activitystreams#Public" in activity.data["to"]
|
2017-05-18 15:58:18 +02:00
|
|
|
end
|
|
|
|
|
2017-05-02 21:31:01 +02:00
|
|
|
test "handle incoming notes - Mastodon, salmon, reply" do
|
|
|
|
# It uses the context of the replied to object
|
|
|
|
Repo.insert!(%Object{
|
|
|
|
data: %{
|
|
|
|
"id" => "https://pleroma.soykaf.com/objects/c237d966-ac75-4fe3-a87a-d89d71a3a7a4",
|
|
|
|
"context" => "2hu"
|
|
|
|
}})
|
|
|
|
incoming = File.read!("test/fixtures/incoming_reply_mastodon.xml")
|
|
|
|
{:ok, [activity]} = OStatus.handle_incoming(incoming)
|
|
|
|
|
|
|
|
assert activity.data["type"] == "Create"
|
|
|
|
assert activity.data["object"]["type"] == "Note"
|
|
|
|
assert activity.data["object"]["actor"] == "https://mastodon.social/users/lambadalambda"
|
|
|
|
assert activity.data["context"] == "2hu"
|
2017-06-30 16:08:59 +02:00
|
|
|
assert "https://www.w3.org/ns/activitystreams#Public" in activity.data["to"]
|
2017-05-02 21:31:01 +02:00
|
|
|
end
|
|
|
|
|
2017-05-10 18:46:23 +02:00
|
|
|
test "handle incoming notes - Mastodon, with CW" do
|
|
|
|
incoming = File.read!("test/fixtures/mastodon-note-cw.xml")
|
|
|
|
{:ok, [activity]} = OStatus.handle_incoming(incoming)
|
|
|
|
|
|
|
|
assert activity.data["type"] == "Create"
|
|
|
|
assert activity.data["object"]["type"] == "Note"
|
|
|
|
assert activity.data["object"]["actor"] == "https://mastodon.social/users/lambadalambda"
|
2017-10-31 17:30:46 +01:00
|
|
|
assert activity.data["object"]["summary"] == "technologic"
|
2017-06-30 16:08:59 +02:00
|
|
|
assert "https://www.w3.org/ns/activitystreams#Public" in activity.data["to"]
|
2017-05-10 18:46:23 +02:00
|
|
|
end
|
|
|
|
|
2017-05-11 17:59:11 +02:00
|
|
|
test "handle incoming retweets - Mastodon, with CW" do
|
|
|
|
incoming = File.read!("test/fixtures/cw_retweet.xml")
|
2018-02-12 10:13:54 +01:00
|
|
|
{:ok, [[_activity, retweeted_activity]]} = OStatus.handle_incoming(incoming)
|
2017-05-11 17:59:11 +02:00
|
|
|
|
2017-10-31 17:30:46 +01:00
|
|
|
assert retweeted_activity.data["object"]["summary"] == "Hey."
|
2017-05-11 17:59:11 +02:00
|
|
|
end
|
|
|
|
|
2017-04-30 11:39:27 +02:00
|
|
|
test "handle incoming notes - GS, subscription, reply" do
|
|
|
|
incoming = File.read!("test/fixtures/ostatus_incoming_reply.xml")
|
|
|
|
{:ok, [activity]} = OStatus.handle_incoming(incoming)
|
|
|
|
|
|
|
|
assert activity.data["type"] == "Create"
|
|
|
|
assert activity.data["object"]["type"] == "Note"
|
|
|
|
assert activity.data["object"]["actor"] == "https://social.heldscal.la/user/23211"
|
|
|
|
assert activity.data["object"]["content"] == "@<a href=\"https://gs.archae.me/user/4687\" class=\"h-card u-url p-nickname mention\" title=\"shpbot\">shpbot</a> why not indeed."
|
|
|
|
assert activity.data["object"]["inReplyTo"] == "tag:gs.archae.me,2017-04-30:noticeId=778260:objectType=note"
|
2017-06-30 16:08:59 +02:00
|
|
|
assert "https://www.w3.org/ns/activitystreams#Public" in activity.data["to"]
|
2017-04-30 11:39:27 +02:00
|
|
|
end
|
|
|
|
|
2017-05-04 18:42:29 +02:00
|
|
|
test "handle incoming retweets - GS, subscription" do
|
|
|
|
incoming = File.read!("test/fixtures/share-gs.xml")
|
|
|
|
{:ok, [[activity, retweeted_activity]]} = OStatus.handle_incoming(incoming)
|
|
|
|
|
|
|
|
assert activity.data["type"] == "Announce"
|
|
|
|
assert activity.data["actor"] == "https://social.heldscal.la/user/23211"
|
|
|
|
assert activity.data["object"] == retweeted_activity.data["object"]["id"]
|
2017-05-08 18:19:45 +02:00
|
|
|
assert "https://pleroma.soykaf.com/users/lain" in activity.data["to"]
|
2017-05-04 18:42:29 +02:00
|
|
|
refute activity.local
|
2017-05-08 18:19:45 +02:00
|
|
|
|
|
|
|
retweeted_activity = Repo.get(Activity, retweeted_activity.id)
|
2017-05-04 18:42:29 +02:00
|
|
|
assert retweeted_activity.data["type"] == "Create"
|
|
|
|
assert retweeted_activity.data["actor"] == "https://pleroma.soykaf.com/users/lain"
|
|
|
|
refute retweeted_activity.local
|
2017-05-08 18:19:45 +02:00
|
|
|
assert retweeted_activity.data["object"]["announcement_count"] == 1
|
2017-05-10 19:29:25 +02:00
|
|
|
assert String.contains?(retweeted_activity.data["object"]["content"], "mastodon")
|
2017-05-11 17:59:11 +02:00
|
|
|
refute String.contains?(retweeted_activity.data["object"]["content"], "Test account")
|
2017-05-08 18:19:45 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
test "handle incoming retweets - GS, subscription - local message" do
|
|
|
|
incoming = File.read!("test/fixtures/share-gs-local.xml")
|
|
|
|
note_activity = insert(:note_activity)
|
|
|
|
user = User.get_cached_by_ap_id(note_activity.data["actor"])
|
|
|
|
incoming = incoming
|
|
|
|
|> String.replace("LOCAL_ID", note_activity.data["object"]["id"])
|
|
|
|
|> String.replace("LOCAL_USER", user.ap_id)
|
|
|
|
|
|
|
|
{:ok, [[activity, retweeted_activity]]} = OStatus.handle_incoming(incoming)
|
|
|
|
|
|
|
|
assert activity.data["type"] == "Announce"
|
|
|
|
assert activity.data["actor"] == "https://social.heldscal.la/user/23211"
|
|
|
|
assert activity.data["object"] == retweeted_activity.data["object"]["id"]
|
|
|
|
assert user.ap_id in activity.data["to"]
|
|
|
|
refute activity.local
|
|
|
|
|
|
|
|
retweeted_activity = Repo.get(Activity, retweeted_activity.id)
|
|
|
|
assert note_activity.id == retweeted_activity.id
|
|
|
|
assert retweeted_activity.data["type"] == "Create"
|
|
|
|
assert retweeted_activity.data["actor"] == user.ap_id
|
|
|
|
assert retweeted_activity.local
|
|
|
|
assert retweeted_activity.data["object"]["announcement_count"] == 1
|
2017-05-04 18:42:29 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
test "handle incoming retweets - Mastodon, salmon" do
|
|
|
|
incoming = File.read!("test/fixtures/share.xml")
|
|
|
|
{:ok, [[activity, retweeted_activity]]} = OStatus.handle_incoming(incoming)
|
|
|
|
|
|
|
|
assert activity.data["type"] == "Announce"
|
|
|
|
assert activity.data["actor"] == "https://mastodon.social/users/lambadalambda"
|
|
|
|
assert activity.data["object"] == retweeted_activity.data["object"]["id"]
|
2017-05-07 20:05:03 +02:00
|
|
|
assert activity.data["id"] == "tag:mastodon.social,2017-05-03:objectId=4934452:objectType=Status"
|
|
|
|
|
2017-05-04 18:42:29 +02:00
|
|
|
refute activity.local
|
|
|
|
assert retweeted_activity.data["type"] == "Create"
|
|
|
|
assert retweeted_activity.data["actor"] == "https://pleroma.soykaf.com/users/lain"
|
|
|
|
refute retweeted_activity.local
|
2017-05-11 17:59:11 +02:00
|
|
|
refute String.contains?(retweeted_activity.data["object"]["content"], "Test account")
|
2017-05-04 18:42:29 +02:00
|
|
|
end
|
|
|
|
|
2017-05-05 16:07:44 +02:00
|
|
|
test "handle incoming favorites - GS, websub" do
|
2018-02-12 10:13:54 +01:00
|
|
|
capture_log fn ->
|
|
|
|
incoming = File.read!("test/fixtures/favorite.xml")
|
|
|
|
{:ok, [[activity, favorited_activity]]} = OStatus.handle_incoming(incoming)
|
|
|
|
|
|
|
|
assert activity.data["type"] == "Like"
|
|
|
|
assert activity.data["actor"] == "https://social.heldscal.la/user/23211"
|
|
|
|
assert activity.data["object"] == favorited_activity.data["object"]["id"]
|
|
|
|
assert activity.data["id"] == "tag:social.heldscal.la,2017-05-05:fave:23211:comment:2061643:2017-05-05T09:12:50+00:00"
|
|
|
|
|
|
|
|
refute activity.local
|
|
|
|
assert favorited_activity.data["type"] == "Create"
|
|
|
|
assert favorited_activity.data["actor"] == "https://shitposter.club/user/1"
|
|
|
|
assert favorited_activity.data["object"]["id"] == "tag:shitposter.club,2017-05-05:noticeId=2827873:objectType=comment"
|
|
|
|
refute favorited_activity.local
|
|
|
|
end
|
2017-05-05 16:27:03 +02:00
|
|
|
end
|
|
|
|
|
2017-09-04 11:03:51 +02:00
|
|
|
test "handle conversation references" do
|
|
|
|
incoming = File.read!("test/fixtures/mastodon_conversation.xml")
|
|
|
|
{:ok, [activity]} = OStatus.handle_incoming(incoming)
|
|
|
|
|
|
|
|
assert activity.data["context"] == "tag:mastodon.social,2017-08-28:objectId=7876885:objectType=Conversation"
|
|
|
|
end
|
|
|
|
|
2017-05-05 16:27:03 +02:00
|
|
|
test "handle incoming favorites with locally available object - GS, websub" do
|
|
|
|
note_activity = insert(:note_activity)
|
|
|
|
|
|
|
|
incoming = File.read!("test/fixtures/favorite_with_local_note.xml")
|
|
|
|
|> String.replace("localid", note_activity.data["object"]["id"])
|
|
|
|
|
|
|
|
{:ok, [[activity, favorited_activity]]} = OStatus.handle_incoming(incoming)
|
|
|
|
|
|
|
|
assert activity.data["type"] == "Like"
|
|
|
|
assert activity.data["actor"] == "https://social.heldscal.la/user/23211"
|
|
|
|
assert activity.data["object"] == favorited_activity.data["object"]["id"]
|
|
|
|
refute activity.local
|
|
|
|
assert note_activity.id == favorited_activity.id
|
|
|
|
assert favorited_activity.local
|
2017-05-05 16:07:44 +02:00
|
|
|
end
|
|
|
|
|
2017-04-26 10:22:51 +02:00
|
|
|
test "handle incoming replies" do
|
|
|
|
incoming = File.read!("test/fixtures/incoming_note_activity_answer.xml")
|
2017-04-29 21:13:21 +02:00
|
|
|
{:ok, [activity]} = OStatus.handle_incoming(incoming)
|
2017-04-26 10:22:51 +02:00
|
|
|
|
|
|
|
assert activity.data["type"] == "Create"
|
|
|
|
assert activity.data["object"]["type"] == "Note"
|
|
|
|
assert activity.data["object"]["inReplyTo"] == "http://pleroma.example.org:4000/objects/55bce8fc-b423-46b1-af71-3759ab4670bc"
|
|
|
|
assert "http://pleroma.example.org:4000/users/lain5" in activity.data["to"]
|
2017-05-07 20:05:03 +02:00
|
|
|
assert activity.data["object"]["id"] == "tag:gs.example.org:4040,2017-04-25:noticeId=55:objectType=note"
|
2017-06-30 16:08:59 +02:00
|
|
|
assert "https://www.w3.org/ns/activitystreams#Public" in activity.data["to"]
|
2017-04-26 10:22:51 +02:00
|
|
|
end
|
|
|
|
|
2017-05-10 18:46:23 +02:00
|
|
|
test "handle incoming follows" do
|
|
|
|
incoming = File.read!("test/fixtures/follow.xml")
|
|
|
|
{:ok, [activity]} = OStatus.handle_incoming(incoming)
|
|
|
|
assert activity.data["type"] == "Follow"
|
|
|
|
assert activity.data["id"] == "tag:social.heldscal.la,2017-05-07:subscription:23211:person:44803:2017-05-07T09:54:48+00:00"
|
|
|
|
assert activity.data["actor"] == "https://social.heldscal.la/user/23211"
|
|
|
|
assert activity.data["object"] == "https://pawoo.net/users/pekorino"
|
|
|
|
refute activity.local
|
|
|
|
|
2017-05-11 17:59:11 +02:00
|
|
|
follower = User.get_by_ap_id(activity.data["actor"])
|
|
|
|
followed = User.get_by_ap_id(activity.data["object"])
|
2017-05-10 18:46:23 +02:00
|
|
|
|
|
|
|
assert User.following?(follower, followed)
|
|
|
|
end
|
|
|
|
|
2017-04-24 18:46:34 +02:00
|
|
|
describe "new remote user creation" do
|
2017-05-07 12:45:37 +02:00
|
|
|
test "returns local users" do
|
|
|
|
local_user = insert(:user)
|
|
|
|
{:ok, user} = OStatus.find_or_make_user(local_user.ap_id)
|
|
|
|
|
|
|
|
assert user == local_user
|
|
|
|
end
|
|
|
|
|
2017-04-24 18:46:34 +02:00
|
|
|
test "tries to use the information in poco fields" do
|
2017-04-29 19:06:01 +02:00
|
|
|
uri = "https://social.heldscal.la/user/23211"
|
2017-04-24 18:46:34 +02:00
|
|
|
|
2017-04-29 19:06:01 +02:00
|
|
|
{:ok, user} = OStatus.find_or_make_user(uri)
|
2017-04-24 18:46:34 +02:00
|
|
|
|
2017-04-29 19:06:01 +02:00
|
|
|
user = Repo.get(Pleroma.User, user.id)
|
2017-04-24 18:46:34 +02:00
|
|
|
assert user.name == "Constance Variable"
|
2017-04-29 20:08:45 +02:00
|
|
|
assert user.nickname == "lambadalambda@social.heldscal.la"
|
2017-04-24 18:46:34 +02:00
|
|
|
assert user.local == false
|
2017-04-29 19:06:01 +02:00
|
|
|
assert user.info["uri"] == uri
|
|
|
|
assert user.ap_id == uri
|
2017-05-24 17:34:38 +02:00
|
|
|
assert user.bio == "Call me Deacon Blues."
|
2017-04-30 12:53:49 +02:00
|
|
|
assert user.avatar["type"] == "Image"
|
2017-04-24 18:46:34 +02:00
|
|
|
|
2017-04-29 19:06:01 +02:00
|
|
|
{:ok, user_again} = OStatus.find_or_make_user(uri)
|
2017-04-24 18:46:34 +02:00
|
|
|
|
|
|
|
assert user == user_again
|
|
|
|
end
|
2017-05-02 17:13:41 +02:00
|
|
|
|
|
|
|
test "find_make_or_update_user takes an author element and returns an updated user" do
|
|
|
|
uri = "https://social.heldscal.la/user/23211"
|
|
|
|
|
|
|
|
{:ok, user} = OStatus.find_or_make_user(uri)
|
2017-05-24 17:34:38 +02:00
|
|
|
old_name = user.name
|
|
|
|
old_bio = user.bio
|
|
|
|
change = Ecto.Changeset.change(user, %{avatar: nil, bio: nil, old_name: nil})
|
2017-05-02 17:13:41 +02:00
|
|
|
|
|
|
|
{:ok, user} = Repo.update(change)
|
|
|
|
refute user.avatar
|
|
|
|
|
|
|
|
doc = XML.parse_document(File.read!("test/fixtures/23211.atom"))
|
|
|
|
[author] = :xmerl_xpath.string('//author[1]', doc)
|
|
|
|
{:ok, user} = OStatus.find_make_or_update_user(author)
|
|
|
|
assert user.avatar["type"] == "Image"
|
2017-05-24 17:34:38 +02:00
|
|
|
assert user.name == old_name
|
|
|
|
assert user.bio == old_bio
|
2017-05-02 17:13:41 +02:00
|
|
|
|
|
|
|
{:ok, user_again} = OStatus.find_make_or_update_user(author)
|
|
|
|
assert user_again == user
|
|
|
|
end
|
2017-04-24 18:46:34 +02:00
|
|
|
end
|
2017-04-29 17:51:59 +02:00
|
|
|
|
|
|
|
describe "gathering user info from a user id" do
|
|
|
|
test "it returns user info in a hash" do
|
|
|
|
user = "shp@social.heldscal.la"
|
|
|
|
|
|
|
|
# TODO: make test local
|
|
|
|
{:ok, data} = OStatus.gather_user_info(user)
|
|
|
|
|
|
|
|
expected = %{
|
2017-05-03 14:26:49 +02:00
|
|
|
"hub" => "https://social.heldscal.la/main/push/hub",
|
|
|
|
"magic_key" => "RSA.wQ3i9UA0qmAxZ0WTIp4a-waZn_17Ez1pEEmqmqoooRsG1_BvpmOvLN0G2tEcWWxl2KOtdQMCiPptmQObeZeuj48mdsDZ4ArQinexY2hCCTcbV8Xpswpkb8K05RcKipdg07pnI7tAgQ0VWSZDImncL6YUGlG5YN8b5TjGOwk2VG8=.AQAB",
|
|
|
|
"name" => "shp",
|
|
|
|
"nickname" => "shp",
|
|
|
|
"salmon" => "https://social.heldscal.la/main/salmon/user/29191",
|
|
|
|
"subject" => "acct:shp@social.heldscal.la",
|
|
|
|
"topic" => "https://social.heldscal.la/api/statuses/user_timeline/29191.atom",
|
|
|
|
"uri" => "https://social.heldscal.la/user/29191",
|
|
|
|
"host" => "social.heldscal.la",
|
|
|
|
"fqn" => user,
|
2017-05-24 17:34:38 +02:00
|
|
|
"bio" => "cofe",
|
2018-02-01 23:00:48 +01:00
|
|
|
"avatar" => %{"type" => "Image", "url" => [%{"href" => "https://social.heldscal.la/avatar/29191-original-20170421154949.jpeg", "mediaType" => "image/jpeg", "type" => "Link"}]},
|
|
|
|
"subscribe_address" => "https://social.heldscal.la/main/ostatussub?profile={uri}"
|
2017-04-29 17:51:59 +02:00
|
|
|
}
|
|
|
|
assert data == expected
|
|
|
|
end
|
2017-04-29 19:06:01 +02:00
|
|
|
|
|
|
|
test "it works with the uri" do
|
|
|
|
user = "https://social.heldscal.la/user/29191"
|
|
|
|
|
|
|
|
# TODO: make test local
|
|
|
|
{:ok, data} = OStatus.gather_user_info(user)
|
|
|
|
|
|
|
|
expected = %{
|
2017-05-03 14:26:49 +02:00
|
|
|
"hub" => "https://social.heldscal.la/main/push/hub",
|
|
|
|
"magic_key" => "RSA.wQ3i9UA0qmAxZ0WTIp4a-waZn_17Ez1pEEmqmqoooRsG1_BvpmOvLN0G2tEcWWxl2KOtdQMCiPptmQObeZeuj48mdsDZ4ArQinexY2hCCTcbV8Xpswpkb8K05RcKipdg07pnI7tAgQ0VWSZDImncL6YUGlG5YN8b5TjGOwk2VG8=.AQAB",
|
|
|
|
"name" => "shp",
|
|
|
|
"nickname" => "shp",
|
|
|
|
"salmon" => "https://social.heldscal.la/main/salmon/user/29191",
|
|
|
|
"subject" => "https://social.heldscal.la/user/29191",
|
|
|
|
"topic" => "https://social.heldscal.la/api/statuses/user_timeline/29191.atom",
|
|
|
|
"uri" => "https://social.heldscal.la/user/29191",
|
|
|
|
"host" => "social.heldscal.la",
|
|
|
|
"fqn" => user,
|
2017-05-24 17:34:38 +02:00
|
|
|
"bio" => "cofe",
|
2018-02-01 23:00:48 +01:00
|
|
|
"avatar" => %{"type" => "Image", "url" => [%{"href" => "https://social.heldscal.la/avatar/29191-original-20170421154949.jpeg", "mediaType" => "image/jpeg", "type" => "Link"}]},
|
|
|
|
"subscribe_address" => "https://social.heldscal.la/main/ostatussub?profile={uri}"
|
2017-04-29 19:06:01 +02:00
|
|
|
}
|
|
|
|
assert data == expected
|
|
|
|
end
|
2017-04-29 17:51:59 +02:00
|
|
|
end
|
2017-05-05 16:07:44 +02:00
|
|
|
|
|
|
|
describe "fetching a status by it's HTML url" do
|
|
|
|
test "it builds a missing status from an html url" do
|
2018-02-12 10:13:54 +01:00
|
|
|
capture_log fn ->
|
|
|
|
url = "https://shitposter.club/notice/2827873"
|
|
|
|
{:ok, [activity] } = OStatus.fetch_activity_from_url(url)
|
2017-05-05 16:07:44 +02:00
|
|
|
|
2018-02-12 10:13:54 +01:00
|
|
|
assert activity.data["actor"] == "https://shitposter.club/user/1"
|
|
|
|
assert activity.data["object"]["id"] == "tag:shitposter.club,2017-05-05:noticeId=2827873:objectType=comment"
|
|
|
|
end
|
2017-05-10 18:46:23 +02:00
|
|
|
end
|
2017-08-04 16:57:38 +02:00
|
|
|
|
|
|
|
test "it works for atom notes, too" do
|
|
|
|
url = "https://social.sakamoto.gq/objects/0ccc1a2c-66b0-4305-b23a-7f7f2b040056"
|
|
|
|
{:ok, [activity] } = OStatus.fetch_activity_from_url(url)
|
|
|
|
assert activity.data["actor"] == "https://social.sakamoto.gq/users/eal"
|
|
|
|
assert activity.data["object"]["id"] == url
|
|
|
|
end
|
2017-05-05 16:07:44 +02:00
|
|
|
end
|
2017-06-24 13:09:46 +02:00
|
|
|
|
2017-08-24 12:54:01 +02:00
|
|
|
test "it doesn't add nil in the do field" do
|
|
|
|
incoming = File.read!("test/fixtures/nil_mention_entry.xml")
|
|
|
|
{:ok, [activity]} = OStatus.handle_incoming(incoming)
|
|
|
|
|
|
|
|
assert activity.data["to"] == ["http://localhost:4001/users/atarifrosch@social.stopwatchingus-heidelberg.de/followers", "https://www.w3.org/ns/activitystreams#Public"]
|
|
|
|
end
|
2017-04-24 18:46:34 +02:00
|
|
|
end
|