1
0
Fork 0

Separates incoming and outgoing api actions

This commit is contained in:
Mouse Reeve 2020-01-28 01:01:33 -08:00
parent ae248f6fdc
commit 17468177dd
8 changed files with 430 additions and 424 deletions

View file

@ -34,9 +34,17 @@ class User(AbstractUser):
@receiver(models.signals.pre_save, sender=User)
def execute_before_save(sender, instance, *args, **kwargs):
''' create shelves for new users '''
# TODO: how are remote users handled? what if they aren't readers?
if not instance.local or instance.id:
# this user already exists, no need to poplate fields
if instance.id:
return
# TODO: how do I know this properly???
if not instance.local:
instance.inbox = instance.actor = 'inbox'
instance.outbox = instance.actor = 'outbox'
return
# populate fields for local users
instance.localname = instance.username
instance.username = '%s@%s' % (instance.username, DOMAIN)
instance.actor = 'https://%s/user/%s' % (DOMAIN, instance.localname)