2018-03-28 22:00:47 +00:00
|
|
|
from django.urls import reverse
|
|
|
|
from django.conf import settings
|
|
|
|
|
2018-03-30 16:02:50 +00:00
|
|
|
from dynamic_preferences.registries import global_preferences_registry
|
|
|
|
|
2018-03-28 22:00:47 +00:00
|
|
|
from . import utils
|
|
|
|
|
|
|
|
|
|
|
|
def repr_instance_actor():
|
|
|
|
"""
|
|
|
|
We do not use a serializer here, since it's pretty static
|
|
|
|
"""
|
2018-03-30 16:02:50 +00:00
|
|
|
actor_url = utils.full_url(reverse('federation:instance-actor'))
|
|
|
|
preferences = global_preferences_registry.manager()
|
|
|
|
public_key = preferences['federation__public_key']
|
|
|
|
|
2018-03-28 22:00:47 +00:00
|
|
|
return {
|
|
|
|
'@context': [
|
|
|
|
'https://www.w3.org/ns/activitystreams',
|
|
|
|
'https://w3id.org/security/v1',
|
|
|
|
{},
|
|
|
|
],
|
|
|
|
'id': utils.full_url(reverse('federation:instance-actor')),
|
2018-03-30 16:34:23 +00:00
|
|
|
'type': 'Person',
|
2018-03-28 22:00:47 +00:00
|
|
|
'inbox': utils.full_url(reverse('federation:instance-inbox')),
|
|
|
|
'outbox': utils.full_url(reverse('federation:instance-outbox')),
|
2018-03-30 16:02:50 +00:00
|
|
|
'preferredUsername': 'service',
|
|
|
|
'name': 'Service Bot - {}'.format(settings.FEDERATION_HOSTNAME),
|
|
|
|
'summary': 'Bot account for federating with {}'.format(
|
|
|
|
settings.FEDERATION_HOSTNAME
|
|
|
|
),
|
|
|
|
'publicKey': {
|
|
|
|
'id': '{}#main-key'.format(actor_url),
|
|
|
|
'owner': actor_url,
|
|
|
|
'publicKeyPem': public_key
|
|
|
|
},
|
|
|
|
|
2018-03-28 22:00:47 +00:00
|
|
|
}
|