use Pleroma.DataCase
alias Pleroma.Web.OStatus
alias Pleroma.Web.XML
- alias Pleroma.{Object, Repo, User}
+ alias Pleroma.{Object, Repo, User, Activity}
import Pleroma.Factory
test "don't insert create notes twice" do
incoming = File.read!("test/fixtures/incoming_note_activity.xml")
- {:ok, [_activity]} = OStatus.handle_incoming(incoming)
- assert {:ok, [{:error, "duplicate activity"}]} == OStatus.handle_incoming(incoming)
+ {:ok, [activity]} = OStatus.handle_incoming(incoming)
+ assert {:ok, [activity]} == OStatus.handle_incoming(incoming)
end
test "handle incoming note - GS, Salmon" do
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 "https://pleroma.soykaf.com/users/lain" in activity.data["to"]
refute activity.local
+
+ retweeted_activity = Repo.get(Activity, retweeted_activity.id)
assert retweeted_activity.data["type"] == "Create"
assert retweeted_activity.data["actor"] == "https://pleroma.soykaf.com/users/lain"
refute retweeted_activity.local
+ assert retweeted_activity.data["object"]["announcement_count"] == 1
+ 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
end
test "handle incoming retweets - Mastodon, salmon" do
assert activity.data["type"] == "Announce"
assert activity.data["actor"] == "https://mastodon.social/users/lambadalambda"
assert activity.data["object"] == retweeted_activity.data["object"]["id"]
+ assert activity.data["id"] == "tag:mastodon.social,2017-05-03:objectId=4934452:objectType=Status"
+
refute activity.local
assert retweeted_activity.data["type"] == "Create"
assert retweeted_activity.data["actor"] == "https://pleroma.soykaf.com/users/lain"
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 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"]
+ assert activity.data["object"]["id"] == "tag:gs.example.org:4040,2017-04-25:noticeId=55:objectType=note"
end
describe "new remote user creation" do
+ 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
+
test "tries to use the information in poco fields" do
- # TODO make test local
uri = "https://social.heldscal.la/user/23211"
{:ok, user} = OStatus.find_or_make_user(uri)
end
test "find_make_or_update_user takes an author element and returns an updated user" do
- # TODO make test local
uri = "https://social.heldscal.la/user/23211"
{:ok, user} = OStatus.find_or_make_user(uri)