diff --git a/CHANGELOG.md b/CHANGELOG.md index d82a525..f53d08c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ # Changelog +# 0.16.1 + +* Fix bug not returning reasons when seeing which instances censured/endorsed/hesitatated against a specific instance +* Whitelist endpoints now will return the visibility of an instance's lists + # 0.16.0 Allows instances to control the visibility of their endorsements, censures and hesitations by setting their visibility in PATCHing `api/b1/whitelist` diff --git a/fediseer/apis/models/v1.py b/fediseer/apis/models/v1.py index 8b600a0..bb108fd 100644 --- a/fediseer/apis/models/v1.py +++ b/fediseer/apis/models/v1.py @@ -39,8 +39,13 @@ class Models: 'sysadmins': fields.Integer(required=False, default=None, description="The count of system administrators in this instance as reported by its admins."), 'moderators': fields.Integer(required=False, default=None, description="The count of community moderators in this instance as reported by its admins."), }) + self.response_model_instances_visibility = api.inherit('InstanceVisibilityDetails', self.response_model_instances, { + 'visibility_endorsements': fields.String(required=True, enum=[e.name for e in enums.ListVisibility], description="If OPEN, this instance allows anyone to read this instance's endorsements. When set to ENDORSED, only endorsed instances can see their endorsements. If set to PRIVATE allow this instance's own admins can see their endorsements."), + 'visibility_censures': fields.String(required=True, enum=[e.name for e in enums.ListVisibility], description="If OPEN, this instance allows anyone to read this instance's censures. When set to ENDORSED, only endorsed instances can see their censures. If set to PRIVATE allow this instance's own admins can see their censures."), + 'visibility_hesitations': fields.String(required=True, enum=[e.name for e in enums.ListVisibility], description="If OPEN, this instance allows anyone to read this instance's hesitations. When set to ENDORSED, only endorsed instances can see their hesitations. If set to PRIVATE allow this instance's own admins can see their hesitations."), + }) self.response_model_model_Whitelist_get = api.model('WhitelistedInstances', { - 'instances': fields.List(fields.Nested(self.response_model_instances)), + 'instances': fields.List(fields.Nested(self.response_model_instances_visibility)), 'domains': fields.List(fields.String(description="The instance domains as a list.")), 'csv': fields.String(description="The instance domains as a csv."), }) diff --git a/fediseer/apis/v1/whitelist.py b/fediseer/apis/v1/whitelist.py index c8cf29c..b1c4525 100644 --- a/fediseer/apis/v1/whitelist.py +++ b/fediseer/apis/v1/whitelist.py @@ -22,7 +22,7 @@ class Whitelist(Resource): self.args = self.get_parser.parse_args() instance_details = [] for instance in database.get_all_instances(self.args.endorsements,self.args.guarantors): - instance_details.append(instance.get_details()) + instance_details.append(instance.get_details(show_visibilities=True)) if self.args.csv: return {"csv": ",".join([instance["domain"] for instance in instance_details])},200 if self.args.domains: @@ -37,7 +37,7 @@ class WhitelistDomain(Resource): @api.expect(get_parser) @cache.cached(timeout=10, query_string=True) - @api.marshal_with(models.response_model_instances, code=200, description='Instances') + @api.marshal_with(models.response_model_instances_visibility, code=200, description='Instances') def get(self, domain): '''Display info about a specific instance ''' @@ -45,7 +45,7 @@ class WhitelistDomain(Resource): instance, nodeinfo, admin_usernames = ensure_instance_registered(domain) if not instance: raise e.NotFound(f"Something went wrong trying to register this instance.") - return instance.get_details(),200 + return instance.get_details(show_visibilities=True),200 put_parser = reqparse.RequestParser() diff --git a/fediseer/classes/instance.py b/fediseer/classes/instance.py index 8f9a4c3..8442284 100644 --- a/fediseer/classes/instance.py +++ b/fediseer/classes/instance.py @@ -122,7 +122,7 @@ class Instance(db.Model): db.session.add(self) db.session.commit() - def get_details(self): + def get_details(self,show_visibilities=False): ret_dict = { "id": self.id, "domain": self.domain, @@ -136,6 +136,10 @@ class Instance(db.Model): "sysadmins": self.sysadmins, "moderators": self.moderators, } + if show_visibilities: + ret_dict["visibility_endorsements"] = self.visibility_endorsements.name + ret_dict["visibility_censures"] = self.visibility_censures.name + ret_dict["visibility_hesitations"] = self.visibility_hesitations.name return ret_dict diff --git a/fediseer/consts.py b/fediseer/consts.py index c94b398..6ef0b5a 100644 --- a/fediseer/consts.py +++ b/fediseer/consts.py @@ -1,4 +1,4 @@ -FEDISEER_VERSION = "0.16.0" +FEDISEER_VERSION = "0.16.1" SUPPORTED_SOFTWARE = { "lemmy", "mastodon",