From c0c489b719067ad047c5eb0e3056c40a4bf22bbe Mon Sep 17 00:00:00 2001 From: Izalia Mae Date: Mon, 15 Nov 2021 04:17:37 -0500 Subject: [PATCH] forgot to add sql/table.py --- izzylib/activitypub.py | 38 ++++++++++++++++++++++++++++ izzylib/http_urllib_client/client.py | 2 +- 2 files changed, 39 insertions(+), 1 deletion(-) diff --git a/izzylib/activitypub.py b/izzylib/activitypub.py index 4a6e918..19e923d 100644 --- a/izzylib/activitypub.py +++ b/izzylib/activitypub.py @@ -358,6 +358,36 @@ class PropertyValue(DotDict): class Nodeinfo(DotDict): + @property + def name(self): + return self.software.name + + + @property + def version(self): + return self.software.version + + + @property + def repo(self): + return self.software.repository + + + @property + def homepage(self): + return self.software.homepage + + + @property + def users(self): + return self.usage.users.total + + + @property + def posts(self): + return self.usage.localPosts + + @classmethod def new_20(cls, name, version, **metadata): return cls.new(name, version, '2.0', **metadata) @@ -427,6 +457,14 @@ class Nodeinfo(DotDict): class WellknownNodeinfo(DotDict): + def url(self, version='2.1'): + assert version in ['2.0', '2.1'] + + for link in self.links: + if link['rel'].endswith(version): + return link['href'] + + @classmethod def new(cls, path, version='2.1'): data = cls(links=[]) diff --git a/izzylib/http_urllib_client/client.py b/izzylib/http_urllib_client/client.py index cd5fc3e..dfb9b80 100644 --- a/izzylib/http_urllib_client/client.py +++ b/izzylib/http_urllib_client/client.py @@ -115,7 +115,7 @@ class HttpUrllibClient: fd.write(byte.getvalue()) - def json(self, *args, headers={}, activity=True, **kwargs): + def json(self, *args, headers={}, activity=False, **kwargs): json_type = 'activity+json' if activity else 'json' headers.update({ 'accept': f'application/{json_type}'