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
Container Registry
Model registry
Operate
Environments
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
Zwordi
funkwhale
Commits
cb9309c2
Verified
Commit
cb9309c2
authored
6 years ago
by
Eliot Berriot
Browse files
Options
Downloads
Patches
Plain Diff
Factorized undo follow
parent
d8f86c4f
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/activity.py
+14
-0
14 additions, 0 deletions
api/funkwhale_api/federation/activity.py
api/funkwhale_api/federation/actors.py
+28
-22
28 additions, 22 deletions
api/funkwhale_api/federation/actors.py
with
42 additions
and
22 deletions
api/funkwhale_api/federation/activity.py
+
14
−
0
View file @
cb9309c2
...
...
@@ -101,6 +101,20 @@ def get_follow(follow_id, follower, followed):
}
def
get_undo
(
id
,
actor
,
object
):
return
{
'
@context
'
:
[
'
https://www.w3.org/ns/activitystreams
'
,
'
https://w3id.org/security/v1
'
,
{}
],
'
type
'
:
'
Undo
'
,
'
id
'
:
id
+
'
/undo
'
,
'
actor
'
:
actor
.
url
,
'
object
'
:
object
,
}
def
get_accept_follow
(
accept_id
,
accept_actor
,
follow
,
follow_actor
):
return
{
"
@context
"
:
[
...
...
This diff is collapsed.
Click to expand it.
api/funkwhale_api/federation/actors.py
+
28
−
22
View file @
cb9309c2
...
...
@@ -146,6 +146,23 @@ class SystemActor(object):
system_actor
,
ac
,
sender
)
def
handle_undo_follow
(
self
,
ac
,
sender
):
actor
=
self
.
get_actor_instance
()
models
.
Follow
.
objects
.
filter
(
actor
=
sender
,
target
=
actor
,
).
delete
()
def
handle_undo
(
self
,
ac
,
sender
):
if
ac
[
'
object
'
][
'
type
'
]
!=
'
Follow
'
:
return
if
ac
[
'
object
'
][
'
actor
'
]
!=
sender
.
url
:
# not the same actor, permission issue
return
self
.
handle_undo_follow
(
ac
,
sender
)
class
LibraryActor
(
SystemActor
):
id
=
'
library
'
...
...
@@ -268,39 +285,28 @@ class TestActor(SystemActor):
to
=
[
ac
[
'
actor
'
]],
on_behalf_of
=
test_actor
)
def
handle_undo
(
self
,
ac
,
sender
):
if
ac
[
'
object
'
][
'
type
'
]
!=
'
Follow
'
:
return
if
ac
[
'
object
'
][
'
actor
'
]
!=
sender
.
url
:
# not the same actor, permission issue
return
test_actor
=
self
.
get_actor_instance
()
models
.
Follow
.
objects
.
filter
(
actor
=
sender
,
target
=
test_actor
,
).
delete
()
def
handle_undo_follow
(
self
,
ac
,
sender
):
super
().
handle_undo_follow
(
ac
,
sender
)
actor
=
self
.
get_actor_instance
()
# we also unfollow the sender, if possible
try
:
follow
=
models
.
Follow
.
objects
.
get
(
target
=
sender
,
actor
=
test_
actor
,
actor
=
actor
,
)
except
models
.
Follow
.
DoesNotExist
:
return
undo
=
{
'
@context
'
:
serializers
.
AP_CONTEXT
,
'
type
'
:
'
Undo
'
,
'
id
'
:
follow
.
get_federation_url
()
+
'
/undo
'
,
'
actor
'
:
test_actor
.
url
,
'
object
'
:
serializers
.
FollowSerializer
(
follow
).
data
,
}
undo
=
activity
.
get_undo
(
id
=
follow
.
get_federation_url
(),
actor
=
actor
,
object
=
serializers
.
FollowSerializer
(
follow
).
data
,
)
follow
.
delete
()
activity
.
deliver
(
undo
,
to
=
[
sender
.
url
],
on_behalf_of
=
test_actor
)
on_behalf_of
=
actor
)
SYSTEM_ACTORS
=
{
'
library
'
:
LibraryActor
(),
...
...
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