Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F33095901
quiet_reply_test.exs
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Award Token
Flag For Later
Size
3 KB
Referenced Files
None
Subscribers
None
quiet_reply_test.exs
View Options
# Pleroma: A lightweight social networking server
# Copyright © 2017-2022 Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only
defmodule
Pleroma.Web.ActivityPub.MRF.QuietReplyTest
do
use
Pleroma.DataCase
import
Pleroma.Factory
require
Pleroma.Constants
alias
Pleroma.Object
alias
Pleroma.Web.ActivityPub.MRF.QuietReply
alias
Pleroma.Web.CommonAPI
test
"replying to public post is forced to be quiet"
do
batman
=
insert
(
:user
,
nickname
:
"batman"
)
robin
=
insert
(
:user
,
nickname
:
"robin"
)
{
:ok
,
post
}
=
CommonAPI
.
post
(
batman
,
%{
status
:
"To the Batmobile!"
})
reply
=
%{
"type"
=>
"Create"
,
"actor"
=>
robin
.
ap_id
,
"to"
=>
[
batman
.
ap_id
,
Pleroma.Constants
.
as_public
()
],
"cc"
=>
[
robin
.
follower_address
],
"object"
=>
%{
"type"
=>
"Note"
,
"actor"
=>
robin
.
ap_id
,
"content"
=>
"@batman Wait up, I forgot my spandex!"
,
"to"
=>
[
batman
.
ap_id
,
Pleroma.Constants
.
as_public
()
],
"cc"
=>
[
robin
.
follower_address
],
"inReplyTo"
=>
Object
.
normalize
(
post
)
.
data
[
"id"
]
}
}
expected_to
=
[
batman
.
ap_id
,
robin
.
follower_address
]
expected_cc
=
[
Pleroma.Constants
.
as_public
()]
assert
{
:ok
,
filtered
}
=
QuietReply
.
filter
(
reply
)
assert
expected_to
==
filtered
[
"to"
]
assert
expected_cc
==
filtered
[
"cc"
]
assert
expected_to
==
filtered
[
"object"
][
"to"
]
assert
expected_cc
==
filtered
[
"object"
][
"cc"
]
end
test
"replying to unlisted post is unmodified"
do
batman
=
insert
(
:user
,
nickname
:
"batman"
)
robin
=
insert
(
:user
,
nickname
:
"robin"
)
{
:ok
,
post
}
=
CommonAPI
.
post
(
batman
,
%{
status
:
"To the Batmobile!"
,
visibility
:
"private"
})
reply
=
%{
"type"
=>
"Create"
,
"actor"
=>
robin
.
ap_id
,
"to"
=>
[
batman
.
ap_id
],
"cc"
=>
[],
"object"
=>
%{
"type"
=>
"Note"
,
"actor"
=>
robin
.
ap_id
,
"content"
=>
"@batman Wait up, I forgot my spandex!"
,
"to"
=>
[
batman
.
ap_id
],
"cc"
=>
[],
"inReplyTo"
=>
Object
.
normalize
(
post
)
.
data
[
"id"
]
}
}
assert
{
:ok
,
filtered
}
=
QuietReply
.
filter
(
reply
)
assert
match?
(
^
filtered
,
reply
)
end
test
"replying direct is unmodified"
do
batman
=
insert
(
:user
,
nickname
:
"batman"
)
robin
=
insert
(
:user
,
nickname
:
"robin"
)
{
:ok
,
post
}
=
CommonAPI
.
post
(
batman
,
%{
status
:
"To the Batmobile!"
})
reply
=
%{
"type"
=>
"Create"
,
"actor"
=>
robin
.
ap_id
,
"to"
=>
[
batman
.
ap_id
],
"cc"
=>
[],
"object"
=>
%{
"type"
=>
"Note"
,
"actor"
=>
robin
.
ap_id
,
"content"
=>
"@batman Wait up, I forgot my spandex!"
,
"to"
=>
[
batman
.
ap_id
],
"cc"
=>
[],
"inReplyTo"
=>
Object
.
normalize
(
post
)
.
data
[
"id"
]
}
}
assert
{
:ok
,
filtered
}
=
QuietReply
.
filter
(
reply
)
assert
match?
(
^
filtered
,
reply
)
end
test
"replying followers-only is unmodified"
do
batman
=
insert
(
:user
,
nickname
:
"batman"
)
robin
=
insert
(
:user
,
nickname
:
"robin"
)
{
:ok
,
post
}
=
CommonAPI
.
post
(
batman
,
%{
status
:
"To the Batmobile!"
})
reply
=
%{
"type"
=>
"Create"
,
"actor"
=>
robin
.
ap_id
,
"to"
=>
[
batman
.
ap_id
,
robin
.
follower_address
],
"cc"
=>
[],
"object"
=>
%{
"type"
=>
"Note"
,
"actor"
=>
robin
.
ap_id
,
"content"
=>
"@batman Wait up, I forgot my spandex!"
,
"to"
=>
[
batman
.
ap_id
,
robin
.
follower_address
],
"cc"
=>
[],
"inReplyTo"
=>
Object
.
normalize
(
post
)
.
data
[
"id"
]
}
}
assert
{
:ok
,
filtered
}
=
QuietReply
.
filter
(
reply
)
assert
match?
(
^
filtered
,
reply
)
end
test
"non-reply posts are unmodified"
do
batman
=
insert
(
:user
,
nickname
:
"batman"
)
{
:ok
,
post
}
=
CommonAPI
.
post
(
batman
,
%{
status
:
"To the Batmobile!"
})
assert
{
:ok
,
filtered
}
=
QuietReply
.
filter
(
post
)
assert
match?
(
^
filtered
,
post
)
end
end
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Tue, Jan 20, 9:58 AM (1 d, 13 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
972912
Default Alt Text
quiet_reply_test.exs (3 KB)
Attached To
Mode
rPUBE pleroma-upstream
Attached
Detach File
Event Timeline
Log In to Comment