Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Mobilizon
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
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
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
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
TeDomum
Mobilizon
Commits
aeaf22a2
Unverified
Commit
aeaf22a2
authored
2 years ago
by
Thomas Citharel
Browse files
Options
Downloads
Patches
Plain Diff
Set correct Content-Type on all AP endpoints
Closes #1210 Signed-off-by:
Thomas Citharel
<
tcit@tcit.fr
>
parent
2e941476
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
lib/web/controllers/activity_pub_controller.ex
+6
-5
6 additions, 5 deletions
lib/web/controllers/activity_pub_controller.ex
lib/web/controllers/page_controller.ex
+12
-0
12 additions, 0 deletions
lib/web/controllers/page_controller.ex
with
18 additions
and
5 deletions
lib/web/controllers/activity_pub_controller.ex
+
6
−
5
View file @
aeaf22a2
...
...
@@ -85,8 +85,9 @@ defmodule Mobilizon.Web.ActivityPubController do
actor
=
Map
.
get
(
conn
.
assigns
,
:actor
)
if
actor_applicant_group_member?
(
group
,
actor
)
do
json
(
conn
,
conn
|>
put_resp_content_type
(
"application/activity+json"
)
|>
json
(
ActorView
.
render
(
"member.json"
,
%{
member:
member
,
actor_applicant:
actor
...
...
@@ -168,7 +169,7 @@ defmodule Mobilizon.Web.ActivityPubController do
def
relay
(
conn
,
_params
)
do
with
{
status
,
%
Actor
{}
=
actor
}
when
status
in
[
:commit
,
:ok
]
<-
Cache
.
get_relay
()
do
conn
|>
put_resp_
header
(
"
content
-
type
"
,
"application/activity+json"
)
|>
put_resp_content
_
type
(
"application/activity+json"
)
|>
json
(
ActorView
.
render
(
"actor.json"
,
%{
actor:
actor
}))
end
end
...
...
@@ -194,7 +195,7 @@ defmodule Mobilizon.Web.ActivityPubController do
page
<-
max
(
page
,
1
),
%
Actor
{}
=
actor
<-
Actors
.
get_local_actor_by_name_with_preload
(
name
)
do
conn
|>
put_resp_
header
(
"
content
-
type
"
,
"application/activity+json"
)
|>
put_resp_content
_
type
(
"application/activity+json"
)
|>
json
(
ActorView
.
render
(
"
#{
collection
}
.json"
,
%{
actor:
actor
,
...
...
@@ -208,7 +209,7 @@ defmodule Mobilizon.Web.ActivityPubController do
defp
actor_collection
(
conn
,
collection
,
%{
"name"
=>
name
})
do
with
%
Actor
{}
=
actor
<-
Actors
.
get_local_actor_by_name_with_preload
(
name
)
do
conn
|>
put_resp_
header
(
"
content
-
type
"
,
"application/activity+json"
)
|>
put_resp_content
_
type
(
"application/activity+json"
)
|>
json
(
ActorView
.
render
(
"
#{
collection
}
.json"
,
%{
actor:
actor
,
...
...
This diff is collapsed.
Click to expand it.
lib/web/controllers/page_controller.ex
+
12
−
0
View file @
aeaf22a2
...
...
@@ -141,11 +141,13 @@ defmodule Mobilizon.Web.PageController do
%
Tombstone
{}
->
conn
|>
put_status
(
:gone
)
|>
maybe_add_content_type_header
()
|>
render
(
object_type
,
object:
object
)
_
->
conn
|>
maybe_add_noindex_header
(
object
)
|>
maybe_add_content_type_header
()
|>
render
(
object_type
,
object:
object
)
end
...
...
@@ -199,4 +201,14 @@ defmodule Mobilizon.Web.PageController do
@spec
is_person?
(
Actor
.
t
())
::
boolean
()
defp
is_person?
(%
Actor
{
type:
:Person
}),
do
:
true
defp
is_person?
(
_
),
do
:
false
defp
maybe_add_content_type_header
(
conn
)
do
case
get_format
(
conn
)
do
"html"
->
conn
"activity-json"
->
put_resp_content_type
(
conn
,
"application/activity+json"
)
end
end
end
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