kopia lustrzana https://gitlab.com/marnanel/chapeau
Trilby keeps track of all the URLs given for a RemotePerson.
rodzic
cad7621bd3
commit
66373041e7
|
@ -348,13 +348,13 @@ def on_person(found, user):
|
|||
('name', 'display_name'),
|
||||
('summary', 'note'),
|
||||
('manuallyApprovesFollowers', 'locked'),
|
||||
#('following', 'following'),
|
||||
#('followers', 'followers'),
|
||||
('inbox', 'inbox'),
|
||||
#('outbox', 'outbox'),
|
||||
#('featured', 'featured'),
|
||||
# ... created_at?
|
||||
# ... bot?
|
||||
('following', 'following_url'),
|
||||
('followers', 'followers_url'),
|
||||
('inbox', 'inbox_url'),
|
||||
('outbox', 'outbox_url'),
|
||||
('featured', 'featured_url'),
|
||||
('created_at', 'created_at'),
|
||||
('bot', 'bot'),
|
||||
('movedTo', 'moved_to'),
|
||||
]:
|
||||
if foundname in found:
|
||||
|
@ -365,7 +365,7 @@ def on_person(found, user):
|
|||
# A shared inbox takes priority over a personal inbox
|
||||
if 'endpoints' in found:
|
||||
if 'sharedInbox' in found['endpoints']:
|
||||
user.inbox = found['endpoints']['sharedInbox']
|
||||
user.inbox_url = found['endpoints']['sharedInbox']
|
||||
|
||||
if 'publicKey' in found:
|
||||
key = found['publicKey']
|
||||
|
|
|
@ -0,0 +1,38 @@
|
|||
# Generated by Django 3.0.9 on 2020-09-15 16:38
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('trilby_api', '0021_auto_20200820_1535'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.RenameField(
|
||||
model_name='remoteperson',
|
||||
old_name='inbox',
|
||||
new_name='inbox_url',
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='remoteperson',
|
||||
name='featured_url',
|
||||
field=models.URLField(blank=True, default=None, max_length=255, null=True),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='remoteperson',
|
||||
name='followers_url',
|
||||
field=models.URLField(blank=True, default=None, max_length=255, null=True),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='remoteperson',
|
||||
name='following_url',
|
||||
field=models.URLField(blank=True, default=None, max_length=255, null=True),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='remoteperson',
|
||||
name='outbox_url',
|
||||
field=models.URLField(blank=True, default=None, max_length=255, null=True),
|
||||
),
|
||||
]
|
|
@ -152,7 +152,35 @@ class RemotePerson(Person):
|
|||
blank = True,
|
||||
)
|
||||
|
||||
inbox = models.URLField(
|
||||
inbox_url = models.URLField(
|
||||
max_length = 255,
|
||||
null = True,
|
||||
blank = True,
|
||||
default = None,
|
||||
)
|
||||
|
||||
outbox_url = models.URLField(
|
||||
max_length = 255,
|
||||
null = True,
|
||||
blank = True,
|
||||
default = None,
|
||||
)
|
||||
|
||||
following_url = models.URLField(
|
||||
max_length = 255,
|
||||
null = True,
|
||||
blank = True,
|
||||
default = None,
|
||||
)
|
||||
|
||||
followers_url = models.URLField(
|
||||
max_length = 255,
|
||||
null = True,
|
||||
blank = True,
|
||||
default = None,
|
||||
)
|
||||
|
||||
featured_url = models.URLField(
|
||||
max_length = 255,
|
||||
null = True,
|
||||
blank = True,
|
||||
|
@ -244,7 +272,7 @@ class RemotePerson(Person):
|
|||
class RemotePersonFollowers(object):
|
||||
def __init__(self, address):
|
||||
logger.debug(
|
||||
"Initialising RemotePerson's followers iterator: %s",
|
||||
"%s RemotePerson: initialising",
|
||||
address,
|
||||
)
|
||||
|
||||
|
@ -255,20 +283,37 @@ class RemotePerson(Person):
|
|||
self.collection = fetch(
|
||||
self.address,
|
||||
Collection,
|
||||
).__iter__()
|
||||
logger.debug(
|
||||
"%s RemotePerson: retrieved collection %s",
|
||||
self.address,
|
||||
self.collection,
|
||||
)
|
||||
|
||||
return self
|
||||
|
||||
def __next__(self):
|
||||
|
||||
logger.debug("%s RemotePerson: finding next follower...",
|
||||
self.address,
|
||||
)
|
||||
|
||||
url = self.collection.__next__()
|
||||
|
||||
logger.debug("Next follower is at %s", url)
|
||||
logger.debug("%s RemotePerson: next follower is at %s",
|
||||
self.address,
|
||||
url,
|
||||
)
|
||||
|
||||
person = fetch(
|
||||
url,
|
||||
Person,
|
||||
)
|
||||
logger.debug(" -- which is %s", person)
|
||||
|
||||
logger.debug("%s RemotePerson: -- which is %s",
|
||||
url,
|
||||
person,
|
||||
)
|
||||
|
||||
return person
|
||||
|
||||
|
|
Ładowanie…
Reference in New Issue