Can now have multiple system actors

We also handle webfinger/activity serialization properly
This commit is contained in:
Eliot Berriot 2018-03-31 15:47:21 +02:00
parent 6c3b7ce154
commit 0c8faf83c5
No known key found for this signature in database
GPG key ID: DD6965E2476E5C27
13 changed files with 493 additions and 152 deletions

View file

@ -2,7 +2,9 @@ from django import forms
from django.conf import settings
from django.urls import reverse
from . import actors
from . import utils
VALID_RESOURCE_TYPES = ['acct']
@ -30,23 +32,7 @@ def clean_acct(acct_string):
if hostname != settings.FEDERATION_HOSTNAME:
raise forms.ValidationError('Invalid hostname')
if username != 'service':
if username not in actors.SYSTEM_ACTORS:
raise forms.ValidationError('Invalid username')
return username, hostname
def serialize_system_acct():
return {
'subject': 'acct:service@{}'.format(settings.FEDERATION_HOSTNAME),
'aliases': [
utils.full_url(reverse('federation:instance-actor'))
],
'links': [
{
'rel': 'self',
'type': 'application/activity+json',
'href': utils.full_url(reverse('federation:instance-actor')),
}
]
}