Skip to content
GitLab
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
06ae56a3
Commit
06ae56a3
authored
Dec 20, 2019
by
feld
Browse files
Posts without media attachments should get the Summary TwitterCard
parent
a54aa5af
Pipeline
#21357
passed with stages
in 8 minutes and 9 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
lib/pleroma/web/metadata/twitter_card.ex
View file @
06ae56a3
...
...
@@ -31,7 +31,7 @@ def build_tags(%{activity_id: id, object: object, user: user}) do
if
attachments
==
[]
or
Metadata
.
activity_nsfw?
(
object
)
do
[
image_tag
(
user
),
{
:meta
,
[
property:
"twitter:card"
,
content:
"summary
_large_image
"
],
[]}
{
:meta
,
[
property:
"twitter:card"
,
content:
"summary"
],
[]}
]
else
attachments
...
...
test/web/metadata/twitter_card_test.exs
View file @
06ae56a3
...
...
@@ -26,7 +26,32 @@ test "it renders twitter card for user info" do
]
end
test
"it does not render attachments if post is nsfw"
do
test
"it uses summary twittercard if post has no attachment"
do
user
=
insert
(
:user
,
name:
"Jimmy Hendriks"
,
bio:
"born 19 March 1994"
)
{
:ok
,
activity
}
=
CommonAPI
.
post
(
user
,
%{
"status"
=>
"HI"
})
note
=
insert
(
:note
,
%{
data:
%{
"actor"
=>
user
.
ap_id
,
"tag"
=>
[],
"id"
=>
"https://pleroma.gov/objects/whatever"
,
"content"
=>
"pleroma in a nutshell"
}
})
result
=
TwitterCard
.
build_tags
(%{
object:
note
,
user:
user
,
activity_id:
activity
.
id
})
assert
[
{
:meta
,
[
property:
"twitter:title"
,
content:
Utils
.
user_name_string
(
user
)],
[]},
{
:meta
,
[
property:
"twitter:description"
,
content:
"“pleroma in a nutshell”"
],
[]},
{
:meta
,
[
property:
"twitter:image"
,
content:
"http://localhost:4001/images/avi.png"
],
[]},
{
:meta
,
[
property:
"twitter:card"
,
content:
"summary"
],
[]}
]
==
result
end
test
"it renders avatar not attachment if post is nsfw and unfurl_nsfw is disabled"
do
Pleroma
.
Config
.
put
([
Pleroma
.
Web
.
Metadata
,
:unfurl_nsfw
],
false
)
user
=
insert
(
:user
,
name:
"Jimmy Hendriks"
,
bio:
"born 19 March 1994"
)
{
:ok
,
activity
}
=
CommonAPI
.
post
(
user
,
%{
"status"
=>
"HI"
})
...
...
@@ -67,7 +92,7 @@ test "it does not render attachments if post is nsfw" do
{
:meta
,
[
property:
"twitter:description"
,
content:
"“pleroma in a nutshell”"
],
[]},
{
:meta
,
[
property:
"twitter:image"
,
content:
"http://localhost:4001/images/avi.png"
],
[]},
{
:meta
,
[
property:
"twitter:card"
,
content:
"summary
_large_image
"
],
[]}
{
:meta
,
[
property:
"twitter:card"
,
content:
"summary"
],
[]}
]
==
result
end
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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