From 4fc9f3a84b097c99ba3bdb9ea2e61ba971af9760 Mon Sep 17 00:00:00 2001 From: db0 Date: Thu, 29 Feb 2024 23:48:32 +0100 Subject: [PATCH] feat: record sw version --- fediseer/apis/models/v1.py | 1 + fediseer/classes/instance.py | 2 ++ fediseer/fediverse.py | 5 +++++ fediseer/register.py | 2 ++ 4 files changed, 10 insertions(+) diff --git a/fediseer/apis/models/v1.py b/fediseer/apis/models/v1.py index a29f434..ca784ab 100644 --- a/fediseer/apis/models/v1.py +++ b/fediseer/apis/models/v1.py @@ -35,6 +35,7 @@ class Models: 'id': fields.Integer(description="The instance id", example=1), 'domain': fields.String(description="The instance domain", example="lemmy.dbzer0.com"), 'software': fields.String(description="The fediverse software running in this instance", example="lemmy"), + 'version': fields.String(description="The fediverse version running in this instance", example="0.19.3"), 'claimed': fields.Integer(description="How many admins from this instance has claimed it."), 'open_registrations': fields.Boolean(description="The instance uptime pct. 100% and thousand of users is unlikely."), 'email_verify': fields.Boolean(description="The amount of local posts in that instance."), diff --git a/fediseer/classes/instance.py b/fediseer/classes/instance.py index a916526..c576b2e 100644 --- a/fediseer/classes/instance.py +++ b/fediseer/classes/instance.py @@ -130,6 +130,7 @@ class Instance(db.Model): approval_required = db.Column(db.Boolean, unique=False, nullable=True, index=True) has_captcha = db.Column(db.Boolean, unique=False, nullable=True, index=True) software = db.Column(db.String(50), unique=False, nullable=False, index=True) + version = db.Column(db.String(255), unique=False, nullable=False, index=True) sysadmins = db.Column(db.Integer, unique=False, nullable=True) moderators = db.Column(db.Integer, unique=False, nullable=True) max_list_size = db.Column(db.Integer, unique=False, nullable=False, default=2000) @@ -170,6 +171,7 @@ class Instance(db.Model): "id": self.id, "domain": self.domain, "software": self.software, + "version": self.version, "claimed": len(self.admins), "open_registrations": self.open_registrations, "email_verify": email_verification, diff --git a/fediseer/fediverse.py b/fediseer/fediverse.py index dd66949..42d46b9 100644 --- a/fediseer/fediverse.py +++ b/fediseer/fediverse.py @@ -12,6 +12,7 @@ class InstanceInfo(): instance_info = None admin_usernames = set() software = None + version = None open_registrations = None approval_required = None email_verify = None @@ -32,6 +33,7 @@ class InstanceInfo(): self.email_verify = True self.has_captcha = True self.software = "lemmy" + self.version = "0.19.3" self.admin_usernames = {"db0"} self.node_info = InstanceInfo.get_nodeinfo("lemmy.dbzer0.com") self.instance_info = {} @@ -42,6 +44,7 @@ class InstanceInfo(): self.email_verify = False self.has_captcha = False self.software = "fediseer" + self.version = FEDISEER_VERSION self.admin_usernames = {"fediseer"} self.node_info = {} self.instance_info = {} @@ -252,10 +255,12 @@ class InstanceInfo(): if not self.node_info: if self._allow_unreachable: self.software = "unknown" + self.version = "unknown" if "*" in self.domain: self.software = "wildcard" else: self.software = self.node_info["software"]["name"].lower() + self.version = self.node_info.get("version","unknown") software_map = { "lemmy": self.get_lemmy_info, "mastodon": self.get_mastodon_info, diff --git a/fediseer/register.py b/fediseer/register.py index 13a0904..7afe131 100644 --- a/fediseer/register.py +++ b/fediseer/register.py @@ -30,6 +30,7 @@ def ensure_instance_registered(domain, allow_unreachable=False, record_unreachab if instance: if ( instance.software != instance_info.software or + instance.version != instance_info.version or instance.open_registrations != instance_info.open_registrations or instance.approval_required != instance_info.approval_required or instance.email_verify != instance_info.email_verify or @@ -40,6 +41,7 @@ def ensure_instance_registered(domain, allow_unreachable=False, record_unreachab # logger.debug(["old", instance.software,instance.open_registrations,instance.approval_required,instance.email_verify,instance.has_captcha]) logger.debug(f"Updated instance info for {domain}") instance.software = instance_info.software + instance.version = instance_info.version instance.open_registrations = instance_info.open_registrations instance.approval_required = instance_info.approval_required instance.email_verify = instance_info.email_verify