feat: Support for adding all fedi software but not claiming
parent
a10524a35d
commit
2f5cdc1cab
|
@ -25,13 +25,14 @@ class Models:
|
|||
'csv': fields.String(description="The suspicious domains as a csv."),
|
||||
})
|
||||
self.response_model_instances = api.model('InstanceDetails', {
|
||||
'id': fields.Integer(description="The instance id"),
|
||||
'domain': fields.String(description="The instance domain"),
|
||||
'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"),
|
||||
'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"),
|
||||
'approvals': fields.Integer(description="The amount of endorsements this instance has given out"),
|
||||
'endorsements': fields.Integer(description="The amount of endorsements this instance has received"),
|
||||
'guarantor': fields.String(description="The domain of the instance which guaranteed this instance."),
|
||||
'guarantor': fields.String(description="The domain of the instance which guaranteed this instance.", example="fediseer.com"),
|
||||
})
|
||||
self.response_model_model_Whitelist_get = api.model('WhitelistedInstances', {
|
||||
'instances': fields.List(fields.Nested(self.response_model_instances)),
|
||||
|
|
|
@ -71,8 +71,6 @@ def ensure_instance_registered(domain):
|
|||
if not nodeinfo:
|
||||
raise e.BadRequest(f"Error encountered while polling domain {domain}. Please check it's running correctly")
|
||||
software = nodeinfo["software"]["name"]
|
||||
if software not in SUPPORTED_SOFTWARE:
|
||||
raise e.BadRequest(f"Fediverse software {software} not supported at this time")
|
||||
if software == "lemmy":
|
||||
requested_lemmy = Lemmy(f"https://{domain}")
|
||||
site = requested_lemmy.site.get()
|
||||
|
|
|
@ -69,6 +69,9 @@ class WhitelistDomain(Resource):
|
|||
if not guarantor_instance:
|
||||
raise e.BadRequest(f"Requested guarantor domain {self.args.guarantor} is not registered with the Fediseer yet!")
|
||||
if self.args.admin not in admin_usernames:
|
||||
if len(admin_usernames) == 0:
|
||||
raise e.Unauthorized(f"We have not implemented admin lookup and messaging for this fediverse software at this point, so this instance cannot be claimed. Please consider sending a PR to add this functionality.")
|
||||
else:
|
||||
raise e.Forbidden(f"Only admins of that {instance.software} are allowed to claim it.")
|
||||
existing_claim = database.find_claim(f"@{self.args.admin}@{domain}")
|
||||
if existing_claim:
|
||||
|
|
|
@ -78,6 +78,7 @@ class Instance(db.Model):
|
|||
ret_dict = {
|
||||
"id": self.id,
|
||||
"domain": self.domain,
|
||||
"software": self.software,
|
||||
"open_registrations": self.open_registrations,
|
||||
"email_verify": self.email_verify,
|
||||
"endorsements": len(self.endorsements),
|
||||
|
|
|
@ -25,7 +25,7 @@ def get_admin_for_software(software: str, domain: str):
|
|||
"mastodon": get_mastodon_admins,
|
||||
}
|
||||
if software not in software_map:
|
||||
return None
|
||||
return []
|
||||
return software_map[software](domain)
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue