From 4a8a8da74087300a56d4aeb089b4d5dc347cb380 Mon Sep 17 00:00:00 2001 From: Izalia Mae Date: Fri, 18 Nov 2022 16:39:53 -0500 Subject: [PATCH] add software kwarg to RelayDatabase.add_inbox --- relay/database.py | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/relay/database.py b/relay/database.py index 975174d..3a9f5c9 100644 --- a/relay/database.py +++ b/relay/database.py @@ -129,20 +129,25 @@ class RelayDatabase(dict): raise KeyError(domain) - def add_inbox(self, inbox, followid=None, fail=False): + def add_inbox(self, inbox, followid=None, software=None): assert inbox.startswith('https'), 'Inbox must be a url' domain = urlparse(inbox).hostname + instance = self.get_inbox(domain) - if self.get_inbox(domain): - if fail: - raise KeyError(domain) + if instance: + if followid: + instance['followid'] = followid - return False + if software: + instance['software'] = software + + return instance self['relay-list'][domain] = { 'domain': domain, 'inbox': inbox, - 'followid': followid + 'followid': followid, + 'software': software } logging.verbose(f'Added inbox to database: {inbox}')