Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
pleroma
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Alexander Strizhakov
pleroma
Commits
cf9cb953
Commit
cf9cb953
authored
Jul 17, 2019
by
kaniini
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
activitypub: represent internal fetch actor
parent
d930e5d5
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
27 additions
and
5 deletions
+27
-5
lib/pleroma/web/activity_pub/activity_pub_controller.ex
lib/pleroma/web/activity_pub/activity_pub_controller.ex
+6
-0
lib/pleroma/web/activity_pub/views/user_view.ex
lib/pleroma/web/activity_pub/views/user_view.ex
+10
-3
lib/pleroma/web/router.ex
lib/pleroma/web/router.ex
+11
-2
No files found.
lib/pleroma/web/activity_pub/activity_pub_controller.ex
View file @
cf9cb953
...
...
@@ -10,6 +10,7 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubController do
alias
Pleroma
.
Object
.
Fetcher
alias
Pleroma
.
User
alias
Pleroma
.
Web
.
ActivityPub
.
ActivityPub
alias
Pleroma
.
Web
.
ActivityPub
.
InternalFetchActor
alias
Pleroma
.
Web
.
ActivityPub
.
ObjectView
alias
Pleroma
.
Web
.
ActivityPub
.
Relay
alias
Pleroma
.
Web
.
ActivityPub
.
Transmogrifier
...
...
@@ -223,6 +224,11 @@ def relay(conn, _params) do
|>
represent_service_actor
(
conn
)
end
def
internal_fetch
(
conn
,
_params
)
do
InternalFetchActor
.
get_actor
()
|>
represent_service_actor
(
conn
)
end
def
whoami
(%{
assigns:
%{
user:
%
User
{}
=
user
}}
=
conn
,
_params
)
do
conn
|>
put_resp_header
(
"content-type"
,
"application/activity+json"
)
...
...
lib/pleroma/web/activity_pub/views/user_view.ex
View file @
cf9cb953
...
...
@@ -31,8 +31,7 @@ def render("endpoints.json", %{user: %User{local: true} = _user}) do
def
render
(
"endpoints.json"
,
_
),
do
:
%{}
# the instance itself is not a Person, but instead an Application
def
render
(
"user.json"
,
%{
user:
%{
nickname:
nil
}
=
user
})
do
def
render
(
"service.json"
,
%{
user:
user
})
do
{
:ok
,
user
}
=
User
.
ensure_keys_present
(
user
)
{
:ok
,
_
,
public_key
}
=
Keys
.
keys_from_pem
(
user
.
info
.
keys
)
public_key
=
:public_key
.
pem_entry_encode
(
:SubjectPublicKeyInfo
,
public_key
)
...
...
@@ -47,7 +46,8 @@ def render("user.json", %{user: %{nickname: nil} = user}) do
"followers"
=>
"
#{
user
.
ap_id
}
/followers"
,
"inbox"
=>
"
#{
user
.
ap_id
}
/inbox"
,
"name"
=>
"Pleroma"
,
"summary"
=>
"Virtual actor for Pleroma relay"
,
"summary"
=>
"An internal service actor for this Pleroma instance. No user-serviceable parts inside."
,
"url"
=>
user
.
ap_id
,
"manuallyApprovesFollowers"
=>
false
,
"publicKey"
=>
%{
...
...
@@ -60,6 +60,13 @@ def render("user.json", %{user: %{nickname: nil} = user}) do
|>
Map
.
merge
(
Utils
.
make_json_ld_header
())
end
# the instance itself is not a Person, but instead an Application
def
render
(
"user.json"
,
%{
user:
%
User
{
nickname:
nil
}
=
user
}),
do
:
render
(
"service.json"
,
%{
user:
user
})
def
render
(
"user.json"
,
%{
user:
%
User
{
nickname:
"internal."
<>
_
}
=
user
}),
do
:
render
(
"service.json"
,
%{
user:
user
})
def
render
(
"user.json"
,
%{
user:
user
})
do
{
:ok
,
user
}
=
User
.
ensure_keys_present
(
user
)
{
:ok
,
_
,
public_key
}
=
Keys
.
keys_from_pem
(
user
.
info
.
keys
)
...
...
lib/pleroma/web/router.ex
View file @
cf9cb953
...
...
@@ -586,7 +586,7 @@ defmodule Pleroma.Web.Router do
end
end
pipeline
:ap_
relay
do
pipeline
:ap_
service_actor
do
plug
(
:accepts
,
[
"activity+json"
,
"json"
])
end
...
...
@@ -663,8 +663,17 @@ defmodule Pleroma.Web.Router do
end
scope
"/relay"
,
Pleroma
.
Web
.
ActivityPub
do
pipe_through
(
:ap_relay
)
pipe_through
(
:ap_service_actor
)
get
(
"/"
,
ActivityPubController
,
:relay
)
post
(
"/inbox"
,
ActivityPubController
,
:inbox
)
end
scope
"/internal/fetch"
,
Pleroma
.
Web
.
ActivityPub
do
pipe_through
(
:ap_service_actor
)
get
(
"/"
,
ActivityPubController
,
:internal_fetch
)
post
(
"/inbox"
,
ActivityPubController
,
:inbox
)
end
scope
"/"
,
Pleroma
.
Web
.
ActivityPub
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