kopia lustrzana https://dev.funkwhale.audio/funkwhale/funkwhale
We now persist system accounts to database
rodzic
fba9a5c97e
commit
48df30dbd8
|
@ -49,15 +49,17 @@ class SystemActor(object):
|
|||
additional_attributes = {}
|
||||
|
||||
def get_actor_instance(self):
|
||||
a = models.Actor(
|
||||
**self.get_instance_argument(
|
||||
self.id,
|
||||
name=self.name,
|
||||
summary=self.summary,
|
||||
**self.additional_attributes
|
||||
)
|
||||
args = self.get_instance_argument(
|
||||
self.id,
|
||||
name=self.name,
|
||||
summary=self.summary,
|
||||
**self.additional_attributes
|
||||
)
|
||||
url = args.pop('url')
|
||||
a, created = models.Actor.objects.get_or_create(
|
||||
url=url,
|
||||
defaults=args,
|
||||
)
|
||||
a.pk = self.id
|
||||
return a
|
||||
|
||||
def get_instance_argument(self, id, name, summary, **kwargs):
|
||||
|
|
|
@ -6,6 +6,7 @@ from django.utils import timezone
|
|||
from rest_framework import exceptions
|
||||
|
||||
from funkwhale_api.federation import actors
|
||||
from funkwhale_api.federation import models
|
||||
from funkwhale_api.federation import serializers
|
||||
from funkwhale_api.federation import utils
|
||||
|
||||
|
@ -188,3 +189,11 @@ def test_test_post_outbox_handles_create_note(
|
|||
to=[actor.url],
|
||||
on_behalf_of=actors.SYSTEM_ACTORS['test'].get_actor_instance()
|
||||
)
|
||||
|
||||
|
||||
def test_getting_actor_instance_persists_in_db(db):
|
||||
test = actors.SYSTEM_ACTORS['test'].get_actor_instance()
|
||||
from_db = models.Actor.objects.get(url=test.url)
|
||||
|
||||
for f in test._meta.fields:
|
||||
assert getattr(from_db, f.name) == getattr(test, f.name)
|
||||
|
|
Ładowanie…
Reference in New Issue