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
jeff
pleroma
Commits
569bad82
Commit
569bad82
authored
6 years ago
by
sxsdv1
Browse files
Options
Downloads
Patches
Plain Diff
Create activity when client posts to outbox
parent
26dc2ddd
No related branches found
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
+29
-6
29 additions, 6 deletions
lib/pleroma/web/activity_pub/activity_pub_controller.ex
test/web/activity_pub/activity_pub_controller_test.exs
+14
-0
14 additions, 0 deletions
test/web/activity_pub/activity_pub_controller_test.exs
with
43 additions
and
6 deletions
lib/pleroma/web/activity_pub/activity_pub_controller.ex
+
29
−
6
View file @
569bad82
...
...
@@ -4,11 +4,12 @@
defmodule
Pleroma
.
Web
.
ActivityPub
.
ActivityPubController
do
use
Pleroma
.
Web
,
:controller
alias
Pleroma
.
{
User
,
Object
}
alias
Pleroma
.
{
Activity
,
User
,
Object
}
alias
Pleroma
.
Web
.
ActivityPub
.
{
ObjectView
,
UserView
}
alias
Pleroma
.
Web
.
ActivityPub
.
ActivityPub
alias
Pleroma
.
Web
.
ActivityPub
.
Relay
alias
Pleroma
.
Web
.
ActivityPub
.
Utils
alias
Pleroma
.
Web
.
ActivityPub
.
Transmogrifier
alias
Pleroma
.
Web
.
Federator
require
Logger
...
...
@@ -166,11 +167,33 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubController do
def
update_outbox
(%{
assigns:
%{
user:
user
}}
=
conn
,
%{
"nickname"
=>
nickname
}
=
params
)
do
if
nickname
==
user
.
nickname
do
Logger
.
info
(
"update outbox
#{
inspect
(
params
)
}
"
)
conn
|>
put_status
(
:created
)
|>
json
(
"ok!"
)
actor
=
user
.
ap_id
()
params
=
params
|>
Map
.
drop
([
"id"
])
|>
Map
.
put
(
"actor"
,
actor
)
|>
Transmogrifier
.
fix_addressing
()
object
=
params
[
"object"
]
|>
Map
.
merge
(
Map
.
take
(
params
,
[
"to"
,
"cc"
]))
|>
Map
.
put
(
"attributedTo"
,
actor
)
|>
Transmogrifier
.
fix_object
()
with
{
:ok
,
%
Activity
{}
=
activity
}
<-
ActivityPub
.
create
(%{
to:
params
[
"to"
],
actor:
user
,
context:
object
[
"context"
],
object:
object
,
additional:
Map
.
take
(
params
,
[
"cc"
])
})
do
conn
|>
put_status
(
:created
)
|>
put_resp_header
(
"location"
,
activity
.
data
[
"id"
])
|>
json
(%{
"id"
=>
activity
.
data
[
"id"
]})
end
else
conn
|>
put_status
(
:forbidden
)
...
...
This diff is collapsed.
Click to expand it.
test/web/activity_pub/activity_pub_controller_test.exs
+
14
−
0
View file @
569bad82
...
...
@@ -178,6 +178,20 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubControllerTest do
assert
json_response
(
conn
,
403
)
end
test
"it inserts an incoming activity into the database"
,
%{
conn:
conn
}
do
data
=
File
.
read!
(
"test/fixtures/activitypub-client-post-activity.json"
)
|>
Poison
.
decode!
()
user
=
insert
(
:user
)
conn
=
conn
|>
assign
(
:user
,
user
)
|>
put_req_header
(
"content-type"
,
"application/activity+json"
)
|>
post
(
"/users/
#{
user
.
nickname
}
/outbox"
,
data
)
result
=
json_response
(
conn
,
201
)
assert
Activity
.
get_by_ap_id
(
result
[
"id"
])
end
end
describe
"/users/:nickname/followers"
do
...
...
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