Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F41667414
admin_email_test.exs
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Award Token
Flag For Later
Size
2 KB
Referenced Files
None
Subscribers
None
admin_email_test.exs
View Options
# Pleroma: A lightweight social networking server
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only
defmodule
Pleroma.Emails.AdminEmailTest
do
use
Pleroma.DataCase
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"
)
reporter_url
=
Helpers
.
user_feed_url
(
Pleroma.Web.Endpoint
,
:feed_redirect
,
reporter
.
id
)
account_url
=
Helpers
.
user_feed_url
(
Pleroma.Web.Endpoint
,
:feed_redirect
,
account
.
id
)
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
==
"<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
"
end
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
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
)
account_url
=
Helpers
.
user_feed_url
(
Pleroma.Web.Endpoint
,
:feed_redirect
,
account
.
id
)
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>
<a href="http://localhost:4001/pleroma/admin">Visit AdminFE</a>
"""
end
end
File Metadata
Details
Attached
Mime Type
text/html
Expires
Sun, Feb 15, 5:48 AM (1 d, 4 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1047529
Default Alt Text
admin_email_test.exs (2 KB)
Attached To
Mode
rPUBE pleroma-upstream
Attached
Detach File
Event Timeline
Log In to Comment