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
429992fc
Commit
429992fc
authored
Jun 25, 2017
by
lain
Browse files
Save external link for notes.
parent
7dca02f9
Changes
2
Hide whitespace changes
Inline
Side-by-side
lib/pleroma/web/ostatus/handlers/note_handler.ex
View file @
429992fc
...
...
@@ -49,6 +49,11 @@ def make_to_list(actor, mentions) do
]
++
mentions
end
def
add_external_url
(
note
,
entry
)
do
url
=
XML
.
string_from_xpath
(
"//link[@rel='alternate' and @type='text/html']/@href"
,
entry
)
Map
.
put
(
note
,
"external_url"
,
url
)
end
def
handle_note
(
entry
,
doc
\\
nil
)
do
with
id
<-
XML
.
string_from_xpath
(
"//id"
,
entry
),
activity
when
is_nil
(
activity
)
<-
Activity
.
get_create_activity_by_object_ap_id
(
id
),
...
...
@@ -67,6 +72,7 @@ def handle_note(entry, doc \\ nil) do
note
<-
TwitterAPI
.
Utils
.
make_note_data
(
actor
.
ap_id
,
to
,
context
,
content_html
,
attachments
,
inReplyToActivity
,
[]),
note
<-
note
|>
Map
.
put
(
"id"
,
id
)
|>
Map
.
put
(
"tag"
,
tags
),
note
<-
note
|>
Map
.
put
(
"published"
,
date
),
note
<-
add_external_url
(
note
,
entry
),
# TODO: Handle this case in make_note_data
note
<-
(
if
inReplyTo
&&
!inReplyToActivity
,
do
:
note
|>
Map
.
put
(
"inReplyTo"
,
inReplyTo
),
else
:
note
)
do
...
...
test/web/ostatus/ostatus_test.exs
View file @
429992fc
...
...
@@ -45,6 +45,7 @@ test "handle incoming notes with attachments - GS, subscription" do
assert
activity
.
data
[
"object"
][
"type"
]
==
"Note"
assert
activity
.
data
[
"object"
][
"actor"
]
==
"https://social.heldscal.la/user/23211"
assert
activity
.
data
[
"object"
][
"attachment"
]
|>
length
==
2
assert
activity
.
data
[
"object"
][
"external_url"
]
==
"https://social.heldscal.la/notice/2020923"
end
test
"handle incoming notes with tags"
do
...
...
Write
Preview
Markdown
is supported
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