mirror of
https://code.eliotberriot.com/funkwhale/funkwhale.git
synced 2025-10-04 13:29:16 +02:00
Resolve "Have an actor for our users"
This commit is contained in:
parent
c335e4d283
commit
6b16a8b963
17 changed files with 308 additions and 9 deletions
23
api/funkwhale_api/common/scripts/create_actors.py
Normal file
23
api/funkwhale_api/common/scripts/create_actors.py
Normal file
|
@ -0,0 +1,23 @@
|
|||
"""
|
||||
Compute different sizes of image used for Album covers and User avatars
|
||||
"""
|
||||
from django.db.utils import IntegrityError
|
||||
|
||||
from funkwhale_api.users.models import User, create_actor
|
||||
|
||||
|
||||
def main(command, **kwargs):
|
||||
qs = User.objects.filter(actor__isnull=True).order_by("username")
|
||||
total = len(qs)
|
||||
command.stdout.write("{} users found without actors".format(total))
|
||||
for i, user in enumerate(qs):
|
||||
command.stdout.write(
|
||||
"{}/{} creating actor for {}".format(i + 1, total, user.username)
|
||||
)
|
||||
try:
|
||||
user.actor = create_actor(user)
|
||||
except IntegrityError as e:
|
||||
# somehow, an actor with the the url exists in the database
|
||||
command.stderr.write("Error while creating actor: {}".format(str(e)))
|
||||
continue
|
||||
user.save(update_fields=["actor"])
|
Loading…
Add table
Add a link
Reference in a new issue