mirror of
https://akkoma.dev/AkkomaGang/akkoma.git
synced 2024-12-22 17:27:18 +00:00
Wire up mentions.
This commit is contained in:
parent
b438ea24ee
commit
f980f6778b
|
@ -31,10 +31,7 @@ defmodule Pleroma.Web.OStatus do
|
||||||
end
|
end
|
||||||
|
|
||||||
# TODO
|
# TODO
|
||||||
# Parse mention
|
|
||||||
# wire up replies
|
# wire up replies
|
||||||
# Set correct context
|
|
||||||
# Set correct statusnet ids.
|
|
||||||
def handle_note(doc) do
|
def handle_note(doc) do
|
||||||
content_html = string_from_xpath("/entry/content[1]", doc)
|
content_html = string_from_xpath("/entry/content[1]", doc)
|
||||||
|
|
||||||
|
@ -52,6 +49,11 @@ defmodule Pleroma.Web.OStatus do
|
||||||
"https://www.w3.org/ns/activitystreams#Public"
|
"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)
|
date = string_from_xpath("/entry/published", doc)
|
||||||
|
|
||||||
object = %{
|
object = %{
|
||||||
|
@ -66,19 +68,6 @@ defmodule Pleroma.Web.OStatus do
|
||||||
ActivityPub.create(to, actor, context, object, %{}, date)
|
ActivityPub.create(to, actor, context, object, %{}, date)
|
||||||
end
|
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
|
def find_or_make_user(author_doc) do
|
||||||
{:xmlObj, :string, uri } = :xmerl_xpath.string('string(/author[1]/uri)', author_doc)
|
{:xmlObj, :string, uri } = :xmerl_xpath.string('string(/author[1]/uri)', author_doc)
|
||||||
|
|
||||||
|
|
|
@ -10,6 +10,7 @@ defmodule Pleroma.Web.OStatusTest do
|
||||||
assert activity.data["object"]["type"] == "Note"
|
assert activity.data["object"]["type"] == "Note"
|
||||||
assert activity.data["published"] == "2017-04-23T14:51:03+00:00"
|
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 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
|
end
|
||||||
|
|
||||||
describe "new remote user creation" do
|
describe "new remote user creation" do
|
||||||
|
|
Loading…
Reference in a new issue