2019-07-09 23:34:21 -06:00
|
|
|
# Pleroma: A lightweight social networking server
|
2023-01-02 13:38:50 -07:00
|
|
|
# Copyright © 2017-2022 Pleroma Authors <https://pleroma.social/>
|
2019-07-09 23:34:21 -06:00
|
|
|
# SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
|
|
|
|
defmodule Pleroma.Emails.AdminEmailTest do
|
2020-12-21 04:21:40 -07:00
|
|
|
use Pleroma.DataCase, async: true
|
2019-07-09 23:34:21 -06:00
|
|
|
import Pleroma.Factory
|
|
|
|
|
|
|
|
alias Pleroma.Emails.AdminEmail
|
|
|
|
alias Pleroma.Web.Router.Helpers
|
|
|
|
|
|
|
|
test "build report email" do
|
|
|
|
config = Pleroma.Config.get(:instance)
|
|
|
|
to_user = insert(:user)
|
|
|
|
reporter = insert(:user)
|
|
|
|
account = insert(:user)
|
|
|
|
|
|
|
|
res =
|
|
|
|
AdminEmail.report(to_user, reporter, account, [%{name: "Test", id: "12"}], "Test comment")
|
|
|
|
|
|
|
|
status_url = Helpers.o_status_url(Pleroma.Web.Endpoint, :notice, "12")
|
2020-11-04 09:12:47 -07:00
|
|
|
reporter_url = reporter.ap_id
|
|
|
|
account_url = account.ap_id
|
2019-07-09 23:34:21 -06:00
|
|
|
|
|
|
|
assert res.to == [{to_user.name, to_user.email}]
|
|
|
|
assert res.from == {config[:name], config[:notify_email]}
|
|
|
|
assert res.subject == "#{config[:name]} Report"
|
|
|
|
|
|
|
|
assert res.html_body ==
|
2021-10-06 00:08:21 -06:00
|
|
|
"<p>Reported by: <a href=\"#{reporter_url}\">#{reporter.nickname}</a></p>\n<p>Reported Account: <a href=\"#{account_url}\">#{account.nickname}</a></p>\n<p>Comment: Test comment\n<p> Statuses:\n <ul>\n <li><a href=\"#{status_url}\">#{status_url}</li>\n </ul>\n</p>\n\n<p>\n<a href=\"http://localhost:4001/pleroma/admin/#/reports/index\">View Reports in AdminFE</a>\n"
|
2019-07-09 23:34:21 -06:00
|
|
|
end
|
2019-08-04 16:24:50 -06:00
|
|
|
|
|
|
|
test "it works when the reporter is a remote user without email" do
|
|
|
|
config = Pleroma.Config.get(:instance)
|
|
|
|
to_user = insert(:user)
|
|
|
|
reporter = insert(:user, email: nil, local: false)
|
|
|
|
account = insert(:user)
|
|
|
|
|
|
|
|
res =
|
|
|
|
AdminEmail.report(to_user, reporter, account, [%{name: "Test", id: "12"}], "Test comment")
|
|
|
|
|
|
|
|
assert res.to == [{to_user.name, to_user.email}]
|
|
|
|
assert res.from == {config[:name], config[:notify_email]}
|
|
|
|
end
|
2020-07-14 19:31:20 -06:00
|
|
|
|
|
|
|
test "new unapproved registration email" do
|
|
|
|
config = Pleroma.Config.get(:instance)
|
|
|
|
to_user = insert(:user)
|
|
|
|
account = insert(:user, registration_reason: "Plz let me in")
|
|
|
|
|
|
|
|
res = AdminEmail.new_unapproved_registration(to_user, account)
|
|
|
|
|
2020-11-04 09:12:47 -07:00
|
|
|
account_url = account.ap_id
|
2020-07-14 19:31:20 -06:00
|
|
|
|
|
|
|
assert res.to == [{to_user.name, to_user.email}]
|
|
|
|
assert res.from == {config[:name], config[:notify_email]}
|
|
|
|
assert res.subject == "New account up for review on #{config[:name]} (@#{account.nickname})"
|
|
|
|
|
|
|
|
assert res.html_body == """
|
|
|
|
<p>New account for review: <a href="#{account_url}">@#{account.nickname}</a></p>
|
|
|
|
<blockquote>Plz let me in</blockquote>
|
2020-10-09 16:08:05 -06:00
|
|
|
<a href="http://localhost:4001/pleroma/admin/#/users/#{account.id}/">Visit AdminFE</a>
|
2020-07-14 19:31:20 -06:00
|
|
|
"""
|
|
|
|
end
|
2019-07-09 23:34:21 -06:00
|
|
|
end
|