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
145d6fe6
Commit
145d6fe6
authored
Jan 05, 2019
by
scarlett
Browse files
Merge branch 'emoji-in-summary' into 'develop'
Strip HTML in and allow emoji in summaries. See merge request
!631
parents
ba17518a
57df7d6e
Pipeline
#6027
passed with stages
in 6 minutes and 24 seconds
Changes
4
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
lib/pleroma/web/common_api/common_api.ex
View file @
145d6fe6
...
...
@@ -124,7 +124,7 @@ def post(user, %{"status" => status} = data) do
Map
.
put
(
object
,
"emoji"
,
Formatter
.
get_emoji
(
status
)
(
Formatter
.
get_emoji
(
status
)
++
Formatter
.
get_emoji
(
data
[
"spoiler_text"
]))
|>
Enum
.
reduce
(%{},
fn
{
name
,
file
},
acc
->
Map
.
put
(
acc
,
name
,
"
#{
Pleroma
.
Web
.
Endpoint
.
static_url
()
}#{
file
}
"
)
end
)
...
...
lib/pleroma/web/twitter_api/representers/activity_representer.ex
View file @
145d6fe6
...
...
@@ -207,7 +207,7 @@ def to_map(
"activity_type"
=>
"post"
,
"possibly_sensitive"
=>
possibly_sensitive
,
"visibility"
=>
Pleroma
.
Web
.
MastodonAPI
.
StatusView
.
get_visibility
(
object
),
"summary"
=>
object
[
"summary"
]
"summary"
=>
HTML
.
strip_tags
(
object
[
"summary"
]
)
|>
Formatter
.
emojify
(
object
[
"emoji"
])
}
end
...
...
lib/pleroma/web/twitter_api/views/activity_view.ex
View file @
145d6fe6
...
...
@@ -289,7 +289,7 @@ def render(
"activity_type"
=>
"post"
,
"possibly_sensitive"
=>
possibly_sensitive
,
"visibility"
=>
Pleroma
.
Web
.
MastodonAPI
.
StatusView
.
get_visibility
(
object
),
"summary"
=>
summary
"summary"
=>
HTML
.
strip_tags
(
summary
)
|>
Formatter
.
emojify
(
object
[
"emoji"
])
}
end
...
...
test/web/twitter_api/views/activity_view_test.exs
View file @
145d6fe6
...
...
@@ -41,6 +41,35 @@ test "a create activity with a html status" do
"#Bike log - Commute Tuesday
\n
https://pla.bike/posts/20181211/
\n
#cycling #CHScycling #commute
\n
MVIMG_20181211_054020.jpg"
end
test
"a create activity with a summary containing emoji"
do
{
:ok
,
activity
}
=
CommonAPI
.
post
(
insert
(
:user
),
%{
"spoiler_text"
=>
":woollysocks: meow"
,
"status"
=>
"."
})
result
=
ActivityView
.
render
(
"activity.json"
,
activity:
activity
)
expected
=
"<img height=
\"
32px
\"
width=
\"
32px
\"
alt=
\"
woollysocks
\"
title=
\"
woollysocks
\"
src=
\"
http://localhost:4001/finmoji/128px/woollysocks-128.png
\"
/> meow"
assert
result
[
"summary"
]
==
expected
end
test
"a create activity with a summary containing invalid HTML"
do
{
:ok
,
activity
}
=
CommonAPI
.
post
(
insert
(
:user
),
%{
"spoiler_text"
=>
"<span style=
\"
color: magenta; font-size: 32px;
\"
>meow</span>"
,
"status"
=>
"."
})
result
=
ActivityView
.
render
(
"activity.json"
,
activity:
activity
)
expected
=
"meow"
assert
result
[
"summary"
]
==
expected
end
test
"a create activity with a note"
do
user
=
insert
(
:user
)
other_user
=
insert
(
:user
,
%{
nickname:
"shp"
})
...
...
@@ -73,14 +102,14 @@ test "a create activity with a note" do
"repeat_num"
=>
0
,
"repeated"
=>
false
,
"statusnet_conversation_id"
=>
convo_id
,
"summary"
=>
""
,
"statusnet_html"
=>
"Hey <span><a data-user=
\"
#{
other_user
.
id
}
\"
href=
\"
#{
other_user
.
ap_id
}
\"
>@<span>shp</span></a></span>!"
,
"tags"
=>
[],
"text"
=>
"Hey @shp!"
,
"uri"
=>
activity
.
data
[
"object"
][
"id"
],
"user"
=>
UserView
.
render
(
"show.json"
,
%{
user:
user
}),
"visibility"
=>
"direct"
,
"summary"
=>
nil
"visibility"
=>
"direct"
}
assert
result
==
expected
...
...
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