fix: no pm on private visibility endorsements

pull/36/head
db0 2023-09-25 20:18:41 +02:00
parent 8a893be55b
commit 9f4c10310e
1 changed files with 17 additions and 15 deletions

View File

@ -198,15 +198,16 @@ class Endorsements(Resource):
db.session.commit() db.session.commit()
# if not database.has_recent_endorsement(target_instance.id): # if not database.has_recent_endorsement(target_instance.id):
try: try:
message = f"Your instance has just been [endorsed](https://fediseer.com/faq#what-is-an-endorsement) by {instance.domain}." if instance.visibility_endorsements != enums.ListVisibility.PRIVATE:
if reason is not None: message = f"Your instance has just been [endorsed](https://fediseer.com/faq#what-is-an-endorsement) by {instance.domain}."
message = f"Your instance has just been [endorsed](https://fediseer.com/faq#what-is-an-endorsement) by {instance.domain} with reason: {reason}" if reason is not None:
activitypub_pm.pm_admins( message = f"Your instance has just been [endorsed](https://fediseer.com/faq#what-is-an-endorsement) by {instance.domain} with reason: {reason}"
message=message, activitypub_pm.pm_admins(
domain=target_instance.domain, message=message,
software=target_instance.software, domain=target_instance.domain,
instance=target_instance, software=target_instance.software,
) instance=target_instance,
)
except: except:
pass pass
logger.info(f"{instance.domain} Endorsed {domain}") logger.info(f"{instance.domain} Endorsed {domain}")
@ -306,12 +307,13 @@ class Endorsements(Resource):
db.session.add(new_report) db.session.add(new_report)
db.session.commit() db.session.commit()
try: try:
activitypub_pm.pm_admins( if instance.visibility_endorsements != enums.ListVisibility.PRIVATE:
message=f"Oh no. {instance.domain} has just withdrawn the endorsement of your instance", activitypub_pm.pm_admins(
domain=target_instance.domain, message=f"Oh no. {instance.domain} has just withdrawn the endorsement of your instance",
software=target_instance.software, domain=target_instance.domain,
instance=target_instance, software=target_instance.software,
) instance=target_instance,
)
except: except:
pass pass
logger.info(f"{instance.domain} Withdrew endorsement from {domain}") logger.info(f"{instance.domain} Withdrew endorsement from {domain}")