Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
funkwhale
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
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
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Martin Giger
funkwhale
Commits
1e583cd5
Verified
Commit
1e583cd5
authored
5 years ago
by
Eliot Berriot
Browse files
Options
Downloads
Patches
Plain Diff
Redirect to HTML version on Actor representations
parent
08f4dd70
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
api/funkwhale_api/federation/views.py
+11
-1
11 additions, 1 deletion
api/funkwhale_api/federation/views.py
api/tests/federation/test_views.py
+40
-0
40 additions, 0 deletions
api/tests/federation/test_views.py
with
51 additions
and
1 deletion
api/funkwhale_api/federation/views.py
+
11
−
1
View file @
1e583cd5
...
...
@@ -61,6 +61,16 @@ class ActorViewSet(FederationMixin, mixins.RetrieveModelMixin, viewsets.GenericV
queryset
=
models
.
Actor
.
objects
.
local
().
select_related
(
"
user
"
)
serializer_class
=
serializers
.
ActorSerializer
def
retrieve
(
self
,
request
,
*
args
,
**
kwargs
):
instance
=
self
.
get_object
()
if
utils
.
should_redirect_ap_to_html
(
request
.
headers
.
get
(
"
accept
"
)):
if
instance
.
get_channel
():
return
redirect_to_html
(
instance
.
channel
.
get_absolute_url
())
return
redirect_to_html
(
instance
.
get_absolute_url
())
serializer
=
self
.
get_serializer
(
instance
)
return
response
.
Response
(
serializer
.
data
)
@action
(
methods
=
[
"
get
"
,
"
post
"
],
detail
=
True
)
def
inbox
(
self
,
request
,
*
args
,
**
kwargs
):
inbox_actor
=
self
.
get_object
()
...
...
@@ -222,7 +232,7 @@ class MusicLibraryViewSet(
def
retrieve
(
self
,
request
,
*
args
,
**
kwargs
):
lb
=
self
.
get_object
()
if
utils
.
should_redirect_ap_to_html
(
request
.
headers
.
get
(
"
accept
"
)):
# XXX: implement this for
actors,
albums, tracks, artists
# XXX: implement this for albums, tracks, artists
return
redirect_to_html
(
lb
.
get_absolute_url
())
conf
=
{
"
id
"
:
lb
.
get_federation_id
(),
...
...
This diff is collapsed.
Click to expand it.
api/tests/federation/test_views.py
+
40
−
0
View file @
1e583cd5
...
...
@@ -387,3 +387,43 @@ def test_music_library_retrieve_redirects_to_html_if_header_set(
)
assert
response
.
status_code
==
302
assert
response
[
"
Location
"
]
==
expected_url
def
test_actor_retrieve_redirects_to_html_if_header_set
(
factories
,
api_client
,
settings
):
actor
=
factories
[
"
federation.Actor
"
](
local
=
True
)
url
=
reverse
(
"
federation:actors-detail
"
,
kwargs
=
{
"
preferred_username
"
:
actor
.
preferred_username
},
)
response
=
api_client
.
get
(
url
,
HTTP_ACCEPT
=
"
text/html
"
)
expected_url
=
utils
.
join_url
(
settings
.
FUNKWHALE_URL
,
utils
.
spa_reverse
(
"
actor_detail
"
,
kwargs
=
{
"
username
"
:
actor
.
preferred_username
}
),
)
assert
response
.
status_code
==
302
assert
response
[
"
Location
"
]
==
expected_url
def
test_channel_actor_retrieve_redirects_to_html_if_header_set
(
factories
,
api_client
,
settings
):
channel
=
factories
[
"
audio.Channel
"
](
local
=
True
)
url
=
reverse
(
"
federation:actors-detail
"
,
kwargs
=
{
"
preferred_username
"
:
channel
.
actor
.
preferred_username
},
)
response
=
api_client
.
get
(
url
,
HTTP_ACCEPT
=
"
text/html
"
)
expected_url
=
utils
.
join_url
(
settings
.
FUNKWHALE_URL
,
utils
.
spa_reverse
(
"
channel_detail
"
,
kwargs
=
{
"
username
"
:
channel
.
actor
.
preferred_username
}
),
)
assert
response
.
status_code
==
302
assert
response
[
"
Location
"
]
==
expected_url
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