For a.gup.pe groups, send votes to post author instead of to community

This commit is contained in:
freamon 2024-10-10 15:39:36 +01:00
parent 773ba7040c
commit cb28b79108
2 changed files with 6 additions and 2 deletions

View file

@ -85,7 +85,7 @@ class Instance(db.Model):
def votes_are_public(self): def votes_are_public(self):
if self.trusted is True: # only vote privately with untrusted instances if self.trusted is True: # only vote privately with untrusted instances
return False return False
return self.software.lower() == 'lemmy' or self.software.lower() == 'mbin' or self.software.lower() == 'kbin' return self.software.lower() == 'lemmy' or self.software.lower() == 'mbin' or self.software.lower() == 'kbin' or self.software.lower() == 'guppe groups'
def post_count(self): def post_count(self):
return db.session.execute(text('SELECT COUNT(id) as c FROM "post" WHERE instance_id = :instance_id'), return db.session.execute(text('SELECT COUNT(id) as c FROM "post" WHERE instance_id = :instance_id'),

View file

@ -324,7 +324,11 @@ def post_vote(post_id: int, vote_direction):
if instance.inbox and not current_user.has_blocked_instance(instance.id) and not instance_banned(instance.domain): if instance.inbox and not current_user.has_blocked_instance(instance.id) and not instance_banned(instance.domain):
send_to_remote_instance(instance.id, post.community.id, announce) send_to_remote_instance(instance.id, post.community.id, announce)
else: else:
post_request_in_background(post.community.ap_inbox_url, action_json, current_user.private_key, inbox = post.community.ap_inbox_url
if (post.community.ap_domain and post.author.ap_inbox_url and # sanity check these fields aren't null
post.community.ap_domain == 'a.gup.pe' and vote_direction == 'upvote'): # send upvotes to post author's instance instead of a.gup.pe (who reject them)
inbox = post.author.ap_inbox_url
post_request_in_background(inbox, action_json, current_user.private_key,
current_user.public_url(not(post.community.instance.votes_are_public() and current_user.vote_privately())) + '#main-key') current_user.public_url(not(post.community.instance.votes_are_public() and current_user.vote_privately())) + '#main-key')
recently_upvoted = [] recently_upvoted = []