Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Pleroma
pleroma
Commits
dc081595
Commit
dc081595
authored
May 17, 2019
by
kaniini
Browse files
also suppress link previews from posts marked #nsfw
parent
0da1233e
Changes
3
Hide whitespace changes
Inline
Side-by-side
lib/pleroma/web/common_api/common_api.ex
View file @
dc081595
...
...
@@ -157,6 +157,7 @@ def post(user, %{"status" => status} = data) do
{
to
,
cc
}
<-
to_for_user_and_mentions
(
user
,
mentions
,
in_reply_to
,
visibility
),
context
<-
make_context
(
in_reply_to
),
cw
<-
data
[
"spoiler_text"
]
||
""
,
sensitive
<-
data
[
"sensitive"
]
||
Enum
.
member?
(
tags
,
{
"#nsfw"
,
"nsfw"
}),
full_payload
<-
String
.
trim
(
status
<>
cw
),
length
when
length
in
1
..
limit
<-
String
.
length
(
full_payload
),
object
<-
...
...
@@ -169,7 +170,8 @@ def post(user, %{"status" => status} = data) do
in_reply_to
,
tags
,
cw
,
cc
cc
,
sensitive
),
object
<-
Map
.
put
(
...
...
lib/pleroma/web/common_api/utils.ex
View file @
dc081595
...
...
@@ -223,7 +223,8 @@ def make_note_data(
in_reply_to
,
tags
,
cw
\\
nil
,
cc
\\
[]
cc
\\
[],
sensitive
\\
false
)
do
object
=
%{
"type"
=>
"Note"
,
...
...
@@ -231,6 +232,7 @@ def make_note_data(
"cc"
=>
cc
,
"content"
=>
content_html
,
"summary"
=>
cw
,
"sensitive"
=>
sensitive
,
"context"
=>
context
,
"attachment"
=>
attachments
,
"actor"
=>
actor
,
...
...
test/web/rich_media/helpers_test.exs
View file @
dc081595
...
...
@@ -67,7 +67,26 @@ test "refuses to crawl URLs from posts marked sensitive" do
{
:ok
,
activity
}
=
CommonAPI
.
post
(
user
,
%{
"status"
=>
"http://example.com/ogp"
,
"spoiler_text"
=>
"."
"sensitive"
=>
true
})
%
Object
{}
=
object
=
Object
.
normalize
(
activity
)
assert
object
.
data
[
"sensitive"
]
Pleroma
.
Config
.
put
([
:rich_media
,
:enabled
],
true
)
assert
%{}
=
Pleroma
.
Web
.
RichMedia
.
Helpers
.
fetch_data_for_activity
(
activity
)
Pleroma
.
Config
.
put
([
:rich_media
,
:enabled
],
false
)
end
test
"refuses to crawl URLs from posts tagged NSFW"
do
user
=
insert
(
:user
)
{
:ok
,
activity
}
=
CommonAPI
.
post
(
user
,
%{
"status"
=>
"http://example.com/ogp #nsfw"
})
%
Object
{}
=
object
=
Object
.
normalize
(
activity
)
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment