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
9c42453e
Commit
9c42453e
authored
May 03, 2017
by
lain
Browse files
Return note objects as ostatus post activities.
parent
018a1a39
Changes
4
Hide whitespace changes
Inline
Side-by-side
lib/pleroma/web/activity_pub/activity_pub.ex
View file @
9c42453e
...
...
@@ -126,7 +126,7 @@ def generate_context_id do
end
def
generate_object_id
do
generate_id
(
"objects"
)
Pleroma
.
Web
.
Router
.
Helpers
.
o_status_url
(
Pleroma
.
Web
.
Endpoint
,
:object
,
Ecto
.
UUID
.
generate
)
end
def
generate_id
(
type
)
do
...
...
lib/pleroma/web/ostatus/ostatus_controller.ex
View file @
9c42453e
...
...
@@ -41,4 +41,19 @@ def salmon_incoming(conn, params) do
conn
|>
send_resp
(
200
,
""
)
end
def
object
(
conn
,
%{
"uuid"
=>
uuid
})
do
IO
.
inspect
(
uuid
)
id
=
o_status_url
(
conn
,
:object
,
uuid
)
activity
=
Activity
.
get_create_activity_by_object_ap_id
(
id
)
user
=
User
.
get_cached_by_ap_id
(
activity
.
data
[
"actor"
])
response
=
FeedRepresenter
.
to_simple_form
(
user
,
[
activity
],
[
user
])
|>
:xmerl
.
export_simple
(
:xmerl_xml
)
|>
to_string
conn
|>
put_resp_content_type
(
"application/atom+xml"
)
|>
send_resp
(
200
,
response
)
end
end
lib/pleroma/web/router.ex
View file @
9c42453e
...
...
@@ -73,6 +73,8 @@ def user_fetcher(username) do
scope
"/"
,
Pleroma
.
Web
do
pipe_through
:ostatus
get
"/objects/:uuid"
,
OStatus
.
OStatusController
,
:object
get
"/users/:nickname/feed"
,
OStatus
.
OStatusController
,
:feed
get
"/users/:nickname"
,
OStatus
.
OStatusController
,
:feed_redirect
post
"/users/:nickname/salmon"
,
OStatus
.
OStatusController
,
:salmon_incoming
...
...
@@ -96,5 +98,5 @@ def user_fetcher(username) do
defmodule
Fallback
.
RedirectController
do
use
Pleroma
.
Web
,
:controller
def
redirector
(
conn
,
_params
),
do
:
send_file
(
conn
,
200
,
"priv/static/index.html"
)
def
redirector
(
conn
,
_params
),
do
:
(
if
Mix
.
env
!=
:test
,
do
:
send_file
(
conn
,
200
,
"priv/static/index.html"
)
)
end
test/web/ostatus/ostatus_controller_test.exs
View file @
9c42453e
...
...
@@ -12,4 +12,16 @@ test "gets a feed", %{conn: conn} do
assert
response
(
conn
,
200
)
end
test
"gets an object"
,
%{
conn:
conn
}
do
note_activity
=
insert
(
:note_activity
)
[
_
,
uuid
]
=
hd
Regex
.
scan
(
~r/.+\/
([\
w
-
]
+
)
$
/
,
note_activity
.
data
[
"object"
][
"id"
])
url
=
"/objects/
#{
uuid
}
"
|>
IO
.
inspect
conn
=
conn
|>
get
(
url
)
assert
response
(
conn
,
200
)
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