fix: error on censures

pull/53/head
db0 2023-10-08 12:33:28 +02:00
parent 75f99cba95
commit 92ecc8297b
3 changed files with 5 additions and 2 deletions

View File

@ -210,7 +210,7 @@ class Censures(Resource):
raise e.BadRequest("You can't censure an instance you've endorsed! Please withdraw the endorsement first.") raise e.BadRequest("You can't censure an instance you've endorsed! Please withdraw the endorsement first.")
if database.get_censure(target_instance.id,instance.id): if database.get_censure(target_instance.id,instance.id):
return {"message":'OK'}, 200 return {"message":'OK'}, 200
if database.count_all_censured_instances_by_censuring_id(instance.id) >= instance.max_list_size: if database.count_all_censured_instances_by_censuring_id([instance.id]) >= instance.max_list_size:
raise e.Forbidden("You're reached the maximum amount of instances you can add to your censures. Please contact the admins of fediseer to increase this limit is needed.") raise e.Forbidden("You're reached the maximum amount of instances you can add to your censures. Please contact the admins of fediseer to increase this limit is needed.")
reason = self.args.reason reason = self.args.reason
if reason is not None: if reason is not None:

View File

@ -190,6 +190,8 @@ class Endorsements(Resource):
raise e.BadRequest("You can't endorse an instance you've censured! Please withdraw the censure first.") raise e.BadRequest("You can't endorse an instance you've censured! Please withdraw the censure first.")
if database.get_endorsement(target_instance.id,instance.id): if database.get_endorsement(target_instance.id,instance.id):
return {"message":'OK'}, 200 return {"message":'OK'}, 200
if database.count_all_endorsed_instances_by_approving_id([instance.id]) >= instance.max_list_size:
raise e.Forbidden("You're reached the maximum amount of instances you can add to your endorsements. Please contact the admins of fediseer to increase this limit is needed.")
reason = self.args.reason reason = self.args.reason
if reason is not None: if reason is not None:
reason = sanitize_string(reason) reason = sanitize_string(reason)

View File

@ -198,7 +198,8 @@ class Hesitations(Resource):
raise e.BadRequest("You can't hesitate against an instance you've endorsed! Please withdraw the endorsement first.") raise e.BadRequest("You can't hesitate against an instance you've endorsed! Please withdraw the endorsement first.")
if database.get_hesitation(target_instance.id,instance.id): if database.get_hesitation(target_instance.id,instance.id):
return {"message":'OK'}, 200 return {"message":'OK'}, 200
if database.count_all_dubious_instances_by_hesitant_id([instance.id]) >= instance.max_list_size:
raise e.Forbidden("You're reached the maximum amount of instances you can add to your hesitations. Please contact the admins of fediseer to increase this limit is needed.")
reason = self.args.reason reason = self.args.reason
if reason is not None: if reason is not None:
reason = sanitize_string(reason) reason = sanitize_string(reason)