Add user muted status info to twitterapi.
This commit is contained in:
parent
c1ae495878
commit
9ade1242c2
|
@ -10,6 +10,7 @@ defmodule Pleroma.Web.TwitterAPI.ActivityView do
|
||||||
alias Pleroma.Object
|
alias Pleroma.Object
|
||||||
alias Pleroma.Repo
|
alias Pleroma.Repo
|
||||||
alias Pleroma.User
|
alias Pleroma.User
|
||||||
|
alias Pleroma.Web.CommonAPI
|
||||||
alias Pleroma.Web.CommonAPI.Utils
|
alias Pleroma.Web.CommonAPI.Utils
|
||||||
alias Pleroma.Web.MastodonAPI.StatusView
|
alias Pleroma.Web.MastodonAPI.StatusView
|
||||||
alias Pleroma.Web.TwitterAPI.ActivityView
|
alias Pleroma.Web.TwitterAPI.ActivityView
|
||||||
|
@ -309,7 +310,8 @@ def render(
|
||||||
"visibility" => StatusView.get_visibility(object),
|
"visibility" => StatusView.get_visibility(object),
|
||||||
"summary" => summary,
|
"summary" => summary,
|
||||||
"summary_html" => summary |> Formatter.emojify(object["emoji"]),
|
"summary_html" => summary |> Formatter.emojify(object["emoji"]),
|
||||||
"card" => card
|
"card" => card,
|
||||||
|
"muted" => CommonAPI.thread_muted?(user, activity) || User.mutes?(opts[:for], user)
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -56,6 +56,22 @@ test "tries to get a user by nickname if fetching by ap_id doesn't work" do
|
||||||
assert result["user"]["id"] == user.id
|
assert result["user"]["id"] == user.id
|
||||||
end
|
end
|
||||||
|
|
||||||
|
test "tells if the message is muted for some reason" do
|
||||||
|
user = insert(:user)
|
||||||
|
other_user = insert(:user)
|
||||||
|
|
||||||
|
{:ok, user} = User.mute(user, other_user)
|
||||||
|
|
||||||
|
{:ok, activity} = CommonAPI.post(other_user, %{"status" => "test"})
|
||||||
|
status = ActivityView.render("activity.json", %{activity: activity})
|
||||||
|
|
||||||
|
assert status["muted"] == false
|
||||||
|
|
||||||
|
status = ActivityView.render("activity.json", %{activity: activity, for: user})
|
||||||
|
|
||||||
|
assert status["muted"] == true
|
||||||
|
end
|
||||||
|
|
||||||
test "a create activity with a html status" do
|
test "a create activity with a html status" do
|
||||||
text = """
|
text = """
|
||||||
#Bike log - Commute Tuesday\nhttps://pla.bike/posts/20181211/\n#cycling #CHScycling #commute\nMVIMG_20181211_054020.jpg
|
#Bike log - Commute Tuesday\nhttps://pla.bike/posts/20181211/\n#cycling #CHScycling #commute\nMVIMG_20181211_054020.jpg
|
||||||
|
@ -149,7 +165,8 @@ test "a create activity with a note" do
|
||||||
"uri" => activity.data["object"]["id"],
|
"uri" => activity.data["object"]["id"],
|
||||||
"user" => UserView.render("show.json", %{user: user}),
|
"user" => UserView.render("show.json", %{user: user}),
|
||||||
"visibility" => "direct",
|
"visibility" => "direct",
|
||||||
"card" => nil
|
"card" => nil,
|
||||||
|
"muted" => false
|
||||||
}
|
}
|
||||||
|
|
||||||
assert result == expected
|
assert result == expected
|
||||||
|
|
Loading…
Reference in a new issue