Merge remote-tracking branch 'pleroma/develop' into feature/disable-account
This commit is contained in:
commit
e8c2f9a73a
705 changed files with 4242 additions and 66080 deletions
|
|
@ -22,8 +22,9 @@ defmodule Pleroma.Web.TwitterAPI.ControllerTest do
|
|||
alias Pleroma.Web.TwitterAPI.TwitterAPI
|
||||
alias Pleroma.Web.TwitterAPI.UserView
|
||||
|
||||
import Pleroma.Factory
|
||||
import Mock
|
||||
import Pleroma.Factory
|
||||
import Swoosh.TestAssertions
|
||||
|
||||
@banner "data:image/gif;base64,R0lGODlhEAAQAMQAAORHHOVSKudfOulrSOp3WOyDZu6QdvCchPGolfO0o/XBs/fNwfjZ0frl3/zy7////wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAkAABAALAAAAAAQABAAAAVVICSOZGlCQAosJ6mu7fiyZeKqNKToQGDsM8hBADgUXoGAiqhSvp5QAnQKGIgUhwFUYLCVDFCrKUE1lBavAViFIDlTImbKC5Gm2hB0SlBCBMQiB0UjIQA7"
|
||||
|
||||
|
|
@ -1063,8 +1064,14 @@ defmodule Pleroma.Web.TwitterAPI.ControllerTest do
|
|||
test "it sends an email to user", %{user: user} do
|
||||
token_record = Repo.get_by(Pleroma.PasswordResetToken, user_id: user.id)
|
||||
|
||||
Swoosh.TestAssertions.assert_email_sent(
|
||||
Pleroma.UserEmail.password_reset_email(user, token_record.token)
|
||||
email = Pleroma.Emails.UserEmail.password_reset_email(user, token_record.token)
|
||||
notify_email = Pleroma.Config.get([:instance, :notify_email])
|
||||
instance_name = Pleroma.Config.get([:instance, :name])
|
||||
|
||||
assert_email_sent(
|
||||
from: {instance_name, notify_email},
|
||||
to: {user.name, user.email},
|
||||
html_body: email.html_body
|
||||
)
|
||||
end
|
||||
end
|
||||
|
|
@ -1163,7 +1170,15 @@ defmodule Pleroma.Web.TwitterAPI.ControllerTest do
|
|||
|> assign(:user, user)
|
||||
|> post("/api/account/resend_confirmation_email?email=#{user.email}")
|
||||
|
||||
Swoosh.TestAssertions.assert_email_sent(Pleroma.UserEmail.account_confirmation_email(user))
|
||||
email = Pleroma.Emails.UserEmail.account_confirmation_email(user)
|
||||
notify_email = Pleroma.Config.get([:instance, :notify_email])
|
||||
instance_name = Pleroma.Config.get([:instance, :name])
|
||||
|
||||
assert_email_sent(
|
||||
from: {instance_name, notify_email},
|
||||
to: {user.name, user.email},
|
||||
html_body: email.html_body
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -41,18 +41,19 @@ defmodule Pleroma.Web.TwitterAPI.TwitterAPITest do
|
|||
|
||||
input = %{
|
||||
"status" =>
|
||||
"Hello again, @shp.<script></script>\nThis is on another :moominmamma: line. #2hu #epic #phantasmagoric",
|
||||
"Hello again, @shp.<script></script>\nThis is on another :firefox: line. #2hu #epic #phantasmagoric",
|
||||
"media_ids" => [object.id]
|
||||
}
|
||||
|
||||
{:ok, activity = %Activity{}} = TwitterAPI.create_status(user, input)
|
||||
object = Object.normalize(activity.data["object"])
|
||||
|
||||
expected_text =
|
||||
"Hello again, <span class='h-card'><a data-user='#{mentioned_user.id}' class='u-url mention' href='shp'>@<span>shp</span></a></span>.<script></script><br>This is on another :moominmamma: line. <a class='hashtag' data-tag='2hu' href='http://localhost:4001/tag/2hu' rel='tag'>#2hu</a> <a class='hashtag' data-tag='epic' href='http://localhost:4001/tag/epic' rel='tag'>#epic</a> <a class='hashtag' data-tag='phantasmagoric' href='http://localhost:4001/tag/phantasmagoric' rel='tag'>#phantasmagoric</a><br><a href=\"http://example.org/image.jpg\" class='attachment'>image.jpg</a>"
|
||||
"Hello again, <span class='h-card'><a data-user='#{mentioned_user.id}' class='u-url mention' href='shp'>@<span>shp</span></a></span>.<script></script><br>This is on another :firefox: line. <a class='hashtag' data-tag='2hu' href='http://localhost:4001/tag/2hu' rel='tag'>#2hu</a> <a class='hashtag' data-tag='epic' href='http://localhost:4001/tag/epic' rel='tag'>#epic</a> <a class='hashtag' data-tag='phantasmagoric' href='http://localhost:4001/tag/phantasmagoric' rel='tag'>#phantasmagoric</a><br><a href=\"http://example.org/image.jpg\" class='attachment'>image.jpg</a>"
|
||||
|
||||
assert get_in(activity.data, ["object", "content"]) == expected_text
|
||||
assert get_in(activity.data, ["object", "type"]) == "Note"
|
||||
assert get_in(activity.data, ["object", "actor"]) == user.ap_id
|
||||
assert get_in(object.data, ["content"]) == expected_text
|
||||
assert get_in(object.data, ["type"]) == "Note"
|
||||
assert get_in(object.data, ["actor"]) == user.ap_id
|
||||
assert get_in(activity.data, ["actor"]) == user.ap_id
|
||||
assert Enum.member?(get_in(activity.data, ["cc"]), User.ap_followers(user))
|
||||
|
||||
|
|
@ -64,19 +65,18 @@ defmodule Pleroma.Web.TwitterAPI.TwitterAPITest do
|
|||
assert Enum.member?(get_in(activity.data, ["to"]), "shp")
|
||||
assert activity.local == true
|
||||
|
||||
assert %{"moominmamma" => "http://localhost:4001/finmoji/128px/moominmamma-128.png"} =
|
||||
activity.data["object"]["emoji"]
|
||||
assert %{"firefox" => "http://localhost:4001/emoji/Firefox.gif"} = object.data["emoji"]
|
||||
|
||||
# hashtags
|
||||
assert activity.data["object"]["tag"] == ["2hu", "epic", "phantasmagoric"]
|
||||
assert object.data["tag"] == ["2hu", "epic", "phantasmagoric"]
|
||||
|
||||
# Add a context
|
||||
assert is_binary(get_in(activity.data, ["context"]))
|
||||
assert is_binary(get_in(activity.data, ["object", "context"]))
|
||||
assert is_binary(get_in(object.data, ["context"]))
|
||||
|
||||
assert is_list(activity.data["object"]["attachment"])
|
||||
assert is_list(object.data["attachment"])
|
||||
|
||||
assert activity.data["object"] == Object.get_by_ap_id(activity.data["object"]["id"]).data
|
||||
assert activity.data["object"] == object.data["id"]
|
||||
|
||||
user = User.get_by_ap_id(user.ap_id)
|
||||
|
||||
|
|
@ -91,6 +91,7 @@ defmodule Pleroma.Web.TwitterAPI.TwitterAPITest do
|
|||
}
|
||||
|
||||
{:ok, activity = %Activity{}} = TwitterAPI.create_status(user, input)
|
||||
object = Object.normalize(activity.data["object"])
|
||||
|
||||
input = %{
|
||||
"status" => "Here's your (you).",
|
||||
|
|
@ -98,14 +99,14 @@ defmodule Pleroma.Web.TwitterAPI.TwitterAPITest do
|
|||
}
|
||||
|
||||
{:ok, reply = %Activity{}} = TwitterAPI.create_status(user, input)
|
||||
reply_object = Object.normalize(reply.data["object"])
|
||||
|
||||
assert get_in(reply.data, ["context"]) == get_in(activity.data, ["context"])
|
||||
|
||||
assert get_in(reply.data, ["object", "context"]) ==
|
||||
get_in(activity.data, ["object", "context"])
|
||||
assert get_in(reply_object.data, ["context"]) == get_in(object.data, ["context"])
|
||||
|
||||
assert get_in(reply.data, ["object", "inReplyTo"]) == get_in(activity.data, ["object", "id"])
|
||||
assert get_in(reply.data, ["object", "inReplyToStatusId"]) == activity.id
|
||||
assert get_in(reply_object.data, ["inReplyTo"]) == get_in(activity.data, ["object"])
|
||||
assert Activity.get_in_reply_to_activity(reply).id == activity.id
|
||||
end
|
||||
|
||||
test "Follow another user using user_id" do
|
||||
|
|
@ -325,7 +326,16 @@ defmodule Pleroma.Web.TwitterAPI.TwitterAPITest do
|
|||
|
||||
assert user.info.confirmation_pending
|
||||
|
||||
Swoosh.TestAssertions.assert_email_sent(Pleroma.UserEmail.account_confirmation_email(user))
|
||||
email = Pleroma.Emails.UserEmail.account_confirmation_email(user)
|
||||
|
||||
notify_email = Pleroma.Config.get([:instance, :notify_email])
|
||||
instance_name = Pleroma.Config.get([:instance, :name])
|
||||
|
||||
Swoosh.TestAssertions.assert_email_sent(
|
||||
from: {instance_name, notify_email},
|
||||
to: {user.name, user.email},
|
||||
html_body: email.html_body
|
||||
)
|
||||
end
|
||||
|
||||
test "it registers a new user and parses mentions in the bio" do
|
||||
|
|
|
|||
|
|
@ -26,6 +26,21 @@ defmodule Pleroma.Web.TwitterAPI.UtilControllerTest do
|
|||
assert response == "job started"
|
||||
end
|
||||
|
||||
test "it imports new-style mastodon follow lists", %{conn: conn} do
|
||||
user1 = insert(:user)
|
||||
user2 = insert(:user)
|
||||
|
||||
response =
|
||||
conn
|
||||
|> assign(:user, user1)
|
||||
|> post("/api/pleroma/follow_import", %{
|
||||
"list" => "Account address,Show boosts\n#{user2.ap_id},true"
|
||||
})
|
||||
|> json_response(:ok)
|
||||
|
||||
assert response == "job started"
|
||||
end
|
||||
|
||||
test "requires 'follow' permission", %{conn: conn} do
|
||||
token1 = insert(:oauth_token, scopes: ["read", "write"])
|
||||
token2 = insert(:oauth_token, scopes: ["follow"])
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ defmodule Pleroma.Web.TwitterAPI.ActivityViewTest do
|
|||
use Pleroma.DataCase
|
||||
|
||||
alias Pleroma.Activity
|
||||
alias Pleroma.Object
|
||||
alias Pleroma.Repo
|
||||
alias Pleroma.User
|
||||
alias Pleroma.Web.ActivityPub.ActivityPub
|
||||
|
|
@ -90,16 +91,16 @@ defmodule Pleroma.Web.TwitterAPI.ActivityViewTest do
|
|||
test "a create activity with a summary containing emoji" do
|
||||
{:ok, activity} =
|
||||
CommonAPI.post(insert(:user), %{
|
||||
"spoiler_text" => ":woollysocks: meow",
|
||||
"spoiler_text" => ":firefox: meow",
|
||||
"status" => "."
|
||||
})
|
||||
|
||||
result = ActivityView.render("activity.json", activity: activity)
|
||||
|
||||
expected = ":woollysocks: meow"
|
||||
expected = ":firefox: meow"
|
||||
|
||||
expected_html =
|
||||
"<img height=\"32px\" width=\"32px\" alt=\"woollysocks\" title=\"woollysocks\" src=\"http://localhost:4001/finmoji/128px/woollysocks-128.png\" /> meow"
|
||||
"<img height=\"32px\" width=\"32px\" alt=\"firefox\" title=\"firefox\" src=\"http://localhost:4001/emoji/Firefox.gif\" /> meow"
|
||||
|
||||
assert result["summary"] == expected
|
||||
assert result["summary_html"] == expected_html
|
||||
|
|
@ -125,10 +126,11 @@ defmodule Pleroma.Web.TwitterAPI.ActivityViewTest do
|
|||
other_user = insert(:user, %{nickname: "shp"})
|
||||
|
||||
{:ok, activity} = CommonAPI.post(user, %{"status" => "Hey @shp!", "visibility" => "direct"})
|
||||
object = Object.normalize(activity.data["object"])
|
||||
|
||||
result = ActivityView.render("activity.json", activity: activity)
|
||||
|
||||
convo_id = Utils.context_to_conversation_id(activity.data["object"]["context"])
|
||||
convo_id = Utils.context_to_conversation_id(object.data["context"])
|
||||
|
||||
expected = %{
|
||||
"activity_type" => "post",
|
||||
|
|
@ -136,8 +138,8 @@ defmodule Pleroma.Web.TwitterAPI.ActivityViewTest do
|
|||
"attentions" => [
|
||||
UserView.render("show.json", %{user: other_user})
|
||||
],
|
||||
"created_at" => activity.data["object"]["published"] |> Utils.date_to_asctime(),
|
||||
"external_url" => activity.data["object"]["id"],
|
||||
"created_at" => object.data["published"] |> Utils.date_to_asctime(),
|
||||
"external_url" => object.data["id"],
|
||||
"fave_num" => 0,
|
||||
"favorited" => false,
|
||||
"id" => activity.id,
|
||||
|
|
@ -161,7 +163,7 @@ defmodule Pleroma.Web.TwitterAPI.ActivityViewTest do
|
|||
}\">@<span>shp</span></a></span>!",
|
||||
"tags" => [],
|
||||
"text" => "Hey @shp!",
|
||||
"uri" => activity.data["object"]["id"],
|
||||
"uri" => object.data["id"],
|
||||
"user" => UserView.render("show.json", %{user: user}),
|
||||
"visibility" => "direct",
|
||||
"card" => nil,
|
||||
|
|
@ -175,8 +177,9 @@ defmodule Pleroma.Web.TwitterAPI.ActivityViewTest do
|
|||
user = insert(:user)
|
||||
other_user = insert(:user, %{nickname: "shp"})
|
||||
{:ok, activity} = CommonAPI.post(user, %{"status" => "Hey @shp!"})
|
||||
object = Object.normalize(activity.data["object"])
|
||||
|
||||
convo_id = Utils.context_to_conversation_id(activity.data["object"]["context"])
|
||||
convo_id = Utils.context_to_conversation_id(object.data["context"])
|
||||
|
||||
mocks = [
|
||||
{
|
||||
|
|
@ -277,9 +280,9 @@ defmodule Pleroma.Web.TwitterAPI.ActivityViewTest do
|
|||
other_user = insert(:user, %{nickname: "shp"})
|
||||
|
||||
{:ok, activity} = CommonAPI.post(user, %{"status" => "Hey @shp!"})
|
||||
{:ok, announce, _object} = CommonAPI.repeat(activity.id, other_user)
|
||||
{:ok, announce, object} = CommonAPI.repeat(activity.id, other_user)
|
||||
|
||||
convo_id = Utils.context_to_conversation_id(activity.data["object"]["context"])
|
||||
convo_id = Utils.context_to_conversation_id(object.data["context"])
|
||||
|
||||
activity = Activity.get_by_id(activity.id)
|
||||
|
||||
|
|
@ -357,7 +360,7 @@ defmodule Pleroma.Web.TwitterAPI.ActivityViewTest do
|
|||
|
||||
test "a peertube video" do
|
||||
{:ok, object} =
|
||||
ActivityPub.fetch_object_from_id(
|
||||
Pleroma.Object.Fetcher.fetch_object_from_id(
|
||||
"https://peertube.moe/videos/watch/df5f464b-be8d-46fb-ad81-2d4c2d1630e3"
|
||||
)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue