Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
P
pleroma
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
normandy
pleroma
Commits
2f1f1a4f
Commit
2f1f1a4f
authored
6 years ago
by
kaniini
Browse files
Options
Downloads
Patches
Plain Diff
activitypub: splice users into recipient lists when they receive messages at their personal inbox
closes #343
parent
9e9b1bd5
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
lib/pleroma/web/activity_pub/activity_pub_controller.ex
+10
-1
10 additions, 1 deletion
lib/pleroma/web/activity_pub/activity_pub_controller.ex
lib/pleroma/web/activity_pub/utils.ex
+42
-0
42 additions, 0 deletions
lib/pleroma/web/activity_pub/utils.ex
with
52 additions
and
1 deletion
lib/pleroma/web/activity_pub/activity_pub_controller.ex
+
10
−
1
View file @
2f1f1a4f
...
...
@@ -4,6 +4,7 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubController do
alias
Pleroma
.
Web
.
ActivityPub
.
{
ObjectView
,
UserView
}
alias
Pleroma
.
Web
.
ActivityPub
.
ActivityPub
alias
Pleroma
.
Web
.
ActivityPub
.
Relay
alias
Pleroma
.
Web
.
ActivityPub
.
Utils
alias
Pleroma
.
Web
.
Federator
require
Logger
...
...
@@ -87,7 +88,15 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubController do
outbox
(
conn
,
%{
"nickname"
=>
nickname
,
"max_id"
=>
nil
})
end
# TODO: Ensure that this inbox is a recipient of the message
def
inbox
(%{
assigns:
%{
valid_signature:
true
}}
=
conn
,
%{
"nickname"
=>
nickname
}
=
params
)
do
with
%
User
{}
=
user
<-
User
.
get_cached_by_nickname
(
nickname
),
true
<-
Utils
.
recipient_in_message
(
user
.
ap_id
,
params
),
params
<-
Utils
.
maybe_splice_recipient
(
user
.
ap_id
,
params
)
do
Federator
.
enqueue
(
:incoming_ap_doc
,
params
)
json
(
conn
,
"ok"
)
end
end
def
inbox
(%{
assigns:
%{
valid_signature:
true
}}
=
conn
,
params
)
do
Federator
.
enqueue
(
:incoming_ap_doc
,
params
)
json
(
conn
,
"ok"
)
...
...
This diff is collapsed.
Click to expand it.
lib/pleroma/web/activity_pub/utils.ex
+
42
−
0
View file @
2f1f1a4f
...
...
@@ -19,6 +19,48 @@ defmodule Pleroma.Web.ActivityPub.Utils do
Map
.
put
(
params
,
"actor"
,
get_ap_id
(
params
[
"actor"
]))
end
defp
recipient_in_collection
(
ap_id
,
coll
)
when
is_binary
(
coll
),
do
:
ap_id
==
coll
defp
recipient_in_collection
(
ap_id
,
coll
)
when
is_list
(
coll
),
do
:
ap_id
in
coll
defp
recipient_in_collection
(
_
,
_
),
do
:
false
def
recipient_in_message
(
ap_id
,
params
)
do
cond
do
recipient_in_collection
(
ap_id
,
params
[
"to"
])
->
true
recipient_in_collection
(
ap_id
,
params
[
"cc"
])
->
true
recipient_in_collection
(
ap_id
,
params
[
"bto"
])
->
true
recipient_in_collection
(
ap_id
,
params
[
"bcc"
])
->
true
true
->
false
end
end
defp
extract_list
(
target
)
when
is_binary
(
target
),
do
:
[
target
]
defp
extract_list
(
lst
)
when
is_list
(
lst
),
do
:
lst
defp
extract_list
(
_
),
do
:
[]
def
maybe_splice_recipient
(
ap_id
,
params
)
do
need_splice
=
!recipient_in_collection
(
ap_id
,
params
[
"to"
])
&&
!recipient_in_collection
(
ap_id
,
params
[
"cc"
])
cc_list
=
extract_list
(
params
[
"cc"
])
if
need_splice
do
params
|>
Map
.
put
(
params
,
"cc"
,
[
ap_id
|
cc_list
])
else
params
end
end
def
make_json_ld_header
do
%{
"@context"
=>
[
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment