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
f980f677
Commit
f980f677
authored
Apr 25, 2017
by
lain
Browse files
Wire up mentions.
parent
b438ea24
Changes
2
Hide whitespace changes
Inline
Side-by-side
lib/pleroma/web/ostatus/ostatus.ex
View file @
f980f677
...
...
@@ -31,10 +31,7 @@ def handle_incoming(xml_string) do
end
# TODO
# Parse mention
# wire up replies
# Set correct context
# Set correct statusnet ids.
def
handle_note
(
doc
)
do
content_html
=
string_from_xpath
(
"/entry/content[1]"
,
doc
)
...
...
@@ -52,6 +49,11 @@ def handle_note(doc) do
"https://www.w3.org/ns/activitystreams#Public"
]
mentions
=
:xmerl_xpath
.
string
(
'/entry/link[@rel="mentioned" and @ostatus:object-type="http://activitystrea.ms/schema/1.0/person"]'
,
doc
)
|>
Enum
.
map
(
fn
(
person
)
->
string_from_xpath
(
"@href"
,
person
)
end
)
to
=
to
++
mentions
date
=
string_from_xpath
(
"/entry/published"
,
doc
)
object
=
%{
...
...
@@ -66,19 +68,6 @@ def handle_note(doc) do
ActivityPub
.
create
(
to
,
actor
,
context
,
object
,
%{},
date
)
end
def
find_or_make
(
author
,
doc
)
do
query
=
from
user
in
User
,
where:
user
.
local
==
false
and
fragment
(
"? @> ?"
,
user
.
info
,
^
%{
ostatus_uri:
author
})
user
=
Repo
.
one
(
query
)
if
is_nil
(
user
)
do
make_user
(
doc
)
else
{
:ok
,
user
}
end
end
def
find_or_make_user
(
author_doc
)
do
{
:xmlObj
,
:string
,
uri
}
=
:xmerl_xpath
.
string
(
'string(/author[1]/uri)'
,
author_doc
)
...
...
test/web/ostatus/ostatus_test.exs
View file @
f980f677
...
...
@@ -10,6 +10,7 @@ test "handle incoming notes" do
assert
activity
.
data
[
"object"
][
"type"
]
==
"Note"
assert
activity
.
data
[
"published"
]
==
"2017-04-23T14:51:03+00:00"
assert
activity
.
data
[
"context"
]
==
"tag:gs.example.org:4040,2017-04-23:objectType=thread:nonce=f09e22f58abd5c7b"
assert
"http://pleroma.example.org:4000/users/lain3"
in
activity
.
data
[
"to"
]
end
describe
"new remote user creation"
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