From a16b17cc61a57d1adbc6f10f16fc36e8238c6c2a Mon Sep 17 00:00:00 2001 From: lain Date: Mon, 7 Jan 2019 20:59:30 +0100 Subject: [PATCH] Actually put some onformation in the error user, make it actually properly parse in conversations. --- lib/pleroma/web/twitter_api/views/activity_view.ex | 6 ++++-- test/web/twitter_api/views/activity_view_test.exs | 9 ++++++--- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/lib/pleroma/web/twitter_api/views/activity_view.ex b/lib/pleroma/web/twitter_api/views/activity_view.ex index 0bae3d06f..25e1486c1 100644 --- a/lib/pleroma/web/twitter_api/views/activity_view.ex +++ b/lib/pleroma/web/twitter_api/views/activity_view.ex @@ -101,12 +101,14 @@ defmodule Pleroma.Web.TwitterAPI.ActivityView do user true -> - error_user() + error_user(ap_id) end end - defp error_user do + defp error_user(ap_id) do %User{ + name: ap_id, + ap_id: ap_id, info: %User.Info{}, nickname: "erroruser@example.com", inserted_at: NaiveDateTime.utc_now() diff --git a/test/web/twitter_api/views/activity_view_test.exs b/test/web/twitter_api/views/activity_view_test.exs index 7f003c214..bd4878e98 100644 --- a/test/web/twitter_api/views/activity_view_test.exs +++ b/test/web/twitter_api/views/activity_view_test.exs @@ -25,7 +25,7 @@ defmodule Pleroma.Web.TwitterAPI.ActivityViewTest do import Mock - test "returns an error user for activities missing users" do + test "returns a temporary ap_id based user for activities missing db users" do user = insert(:user) {:ok, activity} = CommonAPI.post(user, %{"status" => "Hey @shp!", "visibility" => "direct"}) @@ -33,8 +33,11 @@ defmodule Pleroma.Web.TwitterAPI.ActivityViewTest do Repo.delete(user) Cachex.clear(:user_cache) - result = ActivityView.render("activity.json", activity: activity) - assert result + %{"user" => tw_user} = ActivityView.render("activity.json", activity: activity) + + assert tw_user["screen_name"] == "erroruser@example.com" + assert tw_user["name"] == user.ap_id + assert tw_user["statusnet_profile_url"] == user.ap_id end test "tries to get a user by nickname if fetching by ap_id doesn't work" do