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
68752b20
Commit
68752b20
authored
Feb 18, 2018
by
lain
Browse files
Switch protocols to AP when post come in through AP.
parent
77c6c424
Changes
2
Hide whitespace changes
Inline
Side-by-side
lib/pleroma/user.ex
View file @
68752b20
...
...
@@ -427,5 +427,5 @@ def insert_or_update_user(data) do
Repo
.
insert
(
cs
,
on_conflict:
:replace_all
,
conflict_target:
:nickname
)
end
def
ap_enabled?
(%
User
{
info:
%{
"ap_enabled"
=>
ap
}}),
do
:
ap
def
ap_enabled?
(%
User
{
info:
info
}),
do
:
info
[
"ap_enabled"
]
end
lib/pleroma/web/activity_pub/activity_pub_controller.ex
View file @
68752b20
...
...
@@ -23,13 +23,23 @@ def object(conn, %{"uuid" => uuid}) do
# TODO: Ensure that this inbox is a recipient of the message
def
inbox
(%{
assigns:
%{
valid_signature:
true
}}
=
conn
,
params
)
do
# File.write("/tmp/incoming.json", Poison.encode!(params))
with
{
:ok
,
activity
}
<-
Transmogrifier
.
handle_incoming
(
params
)
do
with
{
:ok
,
_user
}
<-
ap_enabled_actor
(
params
[
"actor"
]),
{
:ok
,
activity
}
<-
Transmogrifier
.
handle_incoming
(
params
)
do
json
(
conn
,
"ok"
)
else
e
->
IO
.
inspect
(
e
)
end
end
def
ap_enabled_actor
(
id
)
do
user
=
User
.
get_by_ap_id
(
id
)
if
User
.
ap_enabled?
(
user
)
do
{
:ok
,
user
}
else
ActivityPub
.
make_user_from_ap_id
(
id
)
end
end
def
errors
(
conn
,
_e
)
do
conn
|>
put_status
(
500
)
...
...
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