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
c2d0cb1a
Commit
c2d0cb1a
authored
Feb 17, 2018
by
lain
Browse files
ActivtyPub Delivery: Use shared inbox if possible.
parent
7b26443a
Changes
1
Hide whitespace changes
Inline
Side-by-side
lib/pleroma/web/activity_pub/activity_pub.ex
View file @
c2d0cb1a
...
...
@@ -256,18 +256,20 @@ def make_user_from_ap_id(ap_id) do
def
publish
(
actor
,
activity
)
do
{
:ok
,
followers
}
=
User
.
get_followers
(
actor
)
remote_users
=
Pleroma
.
Web
.
Salmon
.
remote_users
(
activity
)
++
followers
remote_inboxes
=
Pleroma
.
Web
.
Salmon
.
remote_users
(
activity
)
++
followers
|>
Enum
.
filter
(
fn
(
user
)
->
User
.
ap_enabled?
(
user
)
end
)
|>
Enum
.
map
(
fn
(%{
info:
%{
"source_data"
=>
data
}})
->
(
data
[
"endpoints"
]
&&
data
[
"endpoints"
][
"sharedInbox"
])
||
data
[
"inbox"
]
end
)
|>
Enum
.
uniq
{
:ok
,
data
}
=
Transmogrifier
.
prepare_outgoing
(
activity
.
data
)
Enum
.
each
remote_users
,
fn
(
user
)
->
if
user
.
info
[
"ap_enabled"
]
do
inbox
=
user
.
info
[
"source_data"
][
"inbox"
]
Logger
.
info
(
"Federating
#{
activity
.
data
[
"id"
]
}
to
#{
inbox
}
"
)
host
=
URI
.
parse
(
inbox
)
.
host
signature
=
Pleroma
.
Web
.
HTTPSignatures
.
sign
(
actor
,
%{
host:
host
})
@httpoison
.
post
(
inbox
,
Poison
.
encode!
(
data
),
[{
"Content-Type"
,
"application/activity+json"
},
{
"signature"
,
signature
}])
end
Enum
.
each
remote_inboxes
,
fn
(
inbox
)
->
Logger
.
info
(
"Federating
#{
activity
.
data
[
"id"
]
}
to
#{
inbox
}
"
)
host
=
URI
.
parse
(
inbox
)
.
host
signature
=
Pleroma
.
Web
.
HTTPSignatures
.
sign
(
actor
,
%{
host:
host
})
@httpoison
.
post
(
inbox
,
Poison
.
encode!
(
data
),
[{
"Content-Type"
,
"application/activity+json"
},
{
"signature"
,
signature
}])
end
end
end
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