From 94e980d6b4ab91ee37c30b266eb91e748e23861c Mon Sep 17 00:00:00 2001 From: Roger Braun Date: Wed, 24 May 2017 13:53:31 +0200 Subject: Output proper published data in ostatus. --- test/web/ostatus/activity_representer_test.exs | 57 ++++++-------------------- 1 file changed, 12 insertions(+), 45 deletions(-) (limited to 'test/web') diff --git a/test/web/ostatus/activity_representer_test.exs b/test/web/ostatus/activity_representer_test.exs index 0f011f31c..b23334d55 100644 --- a/test/web/ostatus/activity_representer_test.exs +++ b/test/web/ostatus/activity_representer_test.exs @@ -9,10 +9,6 @@ defmodule Pleroma.Web.OStatus.ActivityRepresenterTest do test "a note activity" do note_activity = insert(:note_activity) - updated_at = note_activity.updated_at - |> NaiveDateTime.to_iso8601 - inserted_at = note_activity.inserted_at - |> NaiveDateTime.to_iso8601 user = User.get_cached_by_ap_id(note_activity.data["actor"]) @@ -22,8 +18,8 @@ defmodule Pleroma.Web.OStatus.ActivityRepresenterTest do #{note_activity.data["object"]["id"]} New note by #{user.nickname} #{note_activity.data["object"]["content"]} - #{inserted_at} - #{updated_at} + #{note_activity.data["published"]} + #{note_activity.data["published"]} #{note_activity.data["context"]} @@ -47,11 +43,6 @@ defmodule Pleroma.Web.OStatus.ActivityRepresenterTest do data = %{answer.data | "object" => object} answer = %{answer | data: data} - updated_at = answer.updated_at - |> NaiveDateTime.to_iso8601 - inserted_at = answer.inserted_at - |> NaiveDateTime.to_iso8601 - user = User.get_cached_by_ap_id(answer.data["actor"]) expected = """ @@ -60,8 +51,8 @@ defmodule Pleroma.Web.OStatus.ActivityRepresenterTest do #{answer.data["object"]["id"]} New note by #{user.nickname} #{answer.data["object"]["content"]} - #{inserted_at} - #{updated_at} + #{answer.data["published"]} + #{answer.data["published"]} #{answer.data["context"]} @@ -92,19 +83,14 @@ defmodule Pleroma.Web.OStatus.ActivityRepresenterTest do |> :xmerl.export_simple_content(:xmerl_xml) |> to_string - updated_at = announce.updated_at - |> NaiveDateTime.to_iso8601 - inserted_at = announce.inserted_at - |> NaiveDateTime.to_iso8601 - expected = """ http://activitystrea.ms/schema/1.0/activity http://activitystrea.ms/schema/1.0/share #{announce.data["id"]} #{user.nickname} repeated a notice RT #{note.data["object"]["content"]} - #{inserted_at} - #{updated_at} + #{announce.data["published"]} + #{announce.data["published"]} #{announce.data["context"]} @@ -126,12 +112,6 @@ defmodule Pleroma.Web.OStatus.ActivityRepresenterTest do user = insert(:user) {:ok, like, _note} = ActivityPub.like(user, note) - # TODO: Are these the correct dates? - updated_at = like.updated_at - |> NaiveDateTime.to_iso8601 - inserted_at = like.inserted_at - |> NaiveDateTime.to_iso8601 - tuple = ActivityRepresenter.to_simple_form(like, user) refute is_nil(tuple) @@ -142,8 +122,8 @@ defmodule Pleroma.Web.OStatus.ActivityRepresenterTest do #{like.data["id"]} New favorite by #{user.nickname} #{user.nickname} favorited something - #{inserted_at} - #{updated_at} + #{like.data["published"]} + #{like.data["published"]} http://activitystrea.ms/schema/1.0/note #{note.data["id"]} @@ -168,13 +148,6 @@ defmodule Pleroma.Web.OStatus.ActivityRepresenterTest do "to" => [followed.ap_id] }) - - # TODO: Are these the correct dates? - updated_at = activity.updated_at - |> NaiveDateTime.to_iso8601 - inserted_at = activity.inserted_at - |> NaiveDateTime.to_iso8601 - tuple = ActivityRepresenter.to_simple_form(activity, follower) refute is_nil(tuple) @@ -187,8 +160,8 @@ defmodule Pleroma.Web.OStatus.ActivityRepresenterTest do #{activity.data["id"]} #{follower.nickname} started following #{activity.data["object"]} #{follower.nickname} started following #{activity.data["object"]} - #{inserted_at} - #{updated_at} + #{activity.data["published"]} + #{activity.data["published"]} http://activitystrea.ms/schema/1.0/person #{activity.data["object"]} @@ -207,12 +180,6 @@ defmodule Pleroma.Web.OStatus.ActivityRepresenterTest do {:ok, _activity} = ActivityPub.follow(follower, followed) {:ok, activity} = ActivityPub.unfollow(follower, followed) - # TODO: Are these the correct dates? - updated_at = activity.updated_at - |> NaiveDateTime.to_iso8601 - inserted_at = activity.inserted_at - |> NaiveDateTime.to_iso8601 - tuple = ActivityRepresenter.to_simple_form(activity, follower) refute is_nil(tuple) @@ -225,8 +192,8 @@ defmodule Pleroma.Web.OStatus.ActivityRepresenterTest do #{activity.data["id"]} #{follower.nickname} stopped following #{followed.ap_id} #{follower.nickname} stopped following #{followed.ap_id} - #{inserted_at} - #{updated_at} + #{activity.data["published"]} + #{activity.data["published"]} http://activitystrea.ms/schema/1.0/person #{followed.ap_id} -- cgit v1.2.3 From bdcf42180fa67e43f13584d5e19f26d751199d03 Mon Sep 17 00:00:00 2001 From: Roger Braun Date: Wed, 24 May 2017 17:34:38 +0200 Subject: Save remote user bio and update if we see new data. --- test/web/ostatus/ostatus_test.exs | 9 ++++++++- test/web/websub/websub_test.exs | 1 + 2 files changed, 9 insertions(+), 1 deletion(-) (limited to 'test/web') diff --git a/test/web/ostatus/ostatus_test.exs b/test/web/ostatus/ostatus_test.exs index 6599b00b3..e40fae78c 100644 --- a/test/web/ostatus/ostatus_test.exs +++ b/test/web/ostatus/ostatus_test.exs @@ -233,6 +233,7 @@ defmodule Pleroma.Web.OStatusTest do assert user.local == false assert user.info["uri"] == uri assert user.ap_id == uri + assert user.bio == "Call me Deacon Blues." assert user.avatar["type"] == "Image" {:ok, user_again} = OStatus.find_or_make_user(uri) @@ -244,7 +245,9 @@ defmodule Pleroma.Web.OStatusTest do uri = "https://social.heldscal.la/user/23211" {:ok, user} = OStatus.find_or_make_user(uri) - change = Ecto.Changeset.change(user, %{avatar: nil}) + old_name = user.name + old_bio = user.bio + change = Ecto.Changeset.change(user, %{avatar: nil, bio: nil, old_name: nil}) {:ok, user} = Repo.update(change) refute user.avatar @@ -253,6 +256,8 @@ defmodule Pleroma.Web.OStatusTest do [author] = :xmerl_xpath.string('//author[1]', doc) {:ok, user} = OStatus.find_make_or_update_user(author) assert user.avatar["type"] == "Image" + assert user.name == old_name + assert user.bio == old_bio {:ok, user_again} = OStatus.find_make_or_update_user(author) assert user_again == user @@ -277,6 +282,7 @@ defmodule Pleroma.Web.OStatusTest do "uri" => "https://social.heldscal.la/user/29191", "host" => "social.heldscal.la", "fqn" => user, + "bio" => "cofe", "avatar" => %{"type" => "Image", "url" => [%{"href" => "https://social.heldscal.la/avatar/29191-original-20170421154949.jpeg", "mediaType" => "image/jpeg", "type" => "Link"}]} } assert data == expected @@ -299,6 +305,7 @@ defmodule Pleroma.Web.OStatusTest do "uri" => "https://social.heldscal.la/user/29191", "host" => "social.heldscal.la", "fqn" => user, + "bio" => "cofe", "avatar" => %{"type" => "Image", "url" => [%{"href" => "https://social.heldscal.la/avatar/29191-original-20170421154949.jpeg", "mediaType" => "image/jpeg", "type" => "Link"}]} } assert data == expected diff --git a/test/web/websub/websub_test.exs b/test/web/websub/websub_test.exs index aaed9226e..1ca573d66 100644 --- a/test/web/websub/websub_test.exs +++ b/test/web/websub/websub_test.exs @@ -120,6 +120,7 @@ defmodule Pleroma.Web.WebsubTest do "nickname" => "lambadalambda", "name" => "Critical Value", "host" => "mastodon.social", + "bio" => "a cool dude.", "avatar" => %{"type" => "Image", "url" => [%{"href" => "https://files.mastodon.social/accounts/avatars/000/000/264/original/1429214160519.gif?1492379244", "mediaType" => "image/gif", "type" => "Link"}]} } -- cgit v1.2.3 From c6aa60c829abb7eeff3e0aec0b8b5eb33b8a4947 Mon Sep 17 00:00:00 2001 From: Roger Braun Date: Tue, 30 May 2017 14:26:31 +0200 Subject: Shorten names in links. --- test/web/twitter_api/twitter_api_test.exs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'test/web') diff --git a/test/web/twitter_api/twitter_api_test.exs b/test/web/twitter_api/twitter_api_test.exs index 4df1aba9e..df1022d6b 100644 --- a/test/web/twitter_api/twitter_api_test.exs +++ b/test/web/twitter_api/twitter_api_test.exs @@ -263,7 +263,7 @@ defmodule Pleroma.Web.TwitterAPI.TwitterAPITest do archaeme_remote = insert(:user, %{nickname: "archaeme@archae.me"}) mentions = TwitterAPI.parse_mentions(text) - expected_text = "@gsimg According to @archaeme, that is @daggsy. Also hello @archaeme@archae.me" + expected_text = "@gsimg According to @archaeme, that is @daggsy. Also hello @archaeme" assert Utils.add_user_links(text, mentions) == expected_text end -- cgit v1.2.3