mirror of
https://codeberg.org/rimu/pyfedi
synced 2025-01-23 19:36:56 -08:00
upvotes in low quality communities do not add to reputation
This commit is contained in:
parent
852470b433
commit
44b06cdad0
3 changed files with 39 additions and 12 deletions
|
@ -660,6 +660,8 @@ def upvote_post_reply(comment, user):
|
|||
comment.score += effect
|
||||
vote = PostReplyVote(user_id=user.id, post_reply_id=comment.id,
|
||||
author_id=comment.author.id, effect=effect)
|
||||
if comment.community.low_quality and effect > 0:
|
||||
effect = 0
|
||||
comment.author.reputation += effect
|
||||
db.session.add(vote)
|
||||
else:
|
||||
|
@ -675,6 +677,8 @@ def upvote_post_reply(comment, user):
|
|||
comment.score += effect
|
||||
vote = PostReplyVote(user_id=user.id, post_reply_id=comment.id,
|
||||
author_id=comment.author.id, effect=effect)
|
||||
if comment.community.low_quality and effect > 0:
|
||||
effect = 0
|
||||
comment.author.reputation += effect
|
||||
db.session.add(vote)
|
||||
else:
|
||||
|
@ -690,6 +694,8 @@ def upvote_post(post, user):
|
|||
post.score += effect
|
||||
vote = PostVote(user_id=user.id, post_id=post.id, author_id=post.author.id,
|
||||
effect=effect)
|
||||
if post.community.low_quality and effect > 0:
|
||||
effect = 0
|
||||
post.author.reputation += effect
|
||||
db.session.add(vote)
|
||||
else:
|
||||
|
@ -705,6 +711,8 @@ def upvote_post(post, user):
|
|||
post.score += effect
|
||||
vote = PostVote(user_id=user.id, post_id=post.id, author_id=post.author.id,
|
||||
effect=effect)
|
||||
if post.community.low_quality and effect > 0:
|
||||
effect = 0
|
||||
post.author.reputation += effect
|
||||
db.session.add(vote)
|
||||
|
||||
|
|
|
@ -150,6 +150,7 @@ def post_vote(post_id: int, vote_direction):
|
|||
post = Post.query.get_or_404(post_id)
|
||||
existing_vote = PostVote.query.filter_by(user_id=current_user.id, post_id=post.id).first()
|
||||
if existing_vote:
|
||||
if not post.community.low_quality:
|
||||
post.author.reputation -= existing_vote.effect
|
||||
if existing_vote.effect > 0: # previous vote was up
|
||||
if vote_direction == 'upvote': # new vote is also up, so remove it
|
||||
|
@ -186,12 +187,12 @@ def post_vote(post_id: int, vote_direction):
|
|||
downvoted_class = 'voted_down'
|
||||
vote = PostVote(user_id=current_user.id, post_id=post.id, author_id=post.author.id,
|
||||
effect=effect)
|
||||
# upvotes do not increase reputation in low quality communities
|
||||
if post.community.low_quality and effect > 0:
|
||||
effect = 0
|
||||
post.author.reputation += effect
|
||||
db.session.add(vote)
|
||||
|
||||
if post.community.is_local():
|
||||
...
|
||||
else:
|
||||
action_type = 'Like' if vote_direction == 'upvote' else 'Dislike'
|
||||
action_json = {
|
||||
'actor': current_user.profile_id(),
|
||||
|
@ -200,6 +201,24 @@ def post_vote(post_id: int, vote_direction):
|
|||
'id': f"https://{current_app.config['SERVER_NAME']}/activities/{action_type.lower()}/{gibberish(15)}",
|
||||
'audience': post.community.profile_id()
|
||||
}
|
||||
if post.community.is_local():
|
||||
announce = {
|
||||
"id": f"https://{current_app.config['SERVER_NAME']}/activities/announce/{gibberish(15)}",
|
||||
"type": 'Announce',
|
||||
"to": [
|
||||
"https://www.w3.org/ns/activitystreams#Public"
|
||||
],
|
||||
"actor": post.community.ap_profile_id,
|
||||
"cc": [
|
||||
post.community.ap_followers_url
|
||||
],
|
||||
'@context': default_context(),
|
||||
'object': action_json
|
||||
}
|
||||
for instance in post.community.following_instances():
|
||||
if instance[1] and not current_user.has_blocked_instance(instance[0]):
|
||||
send_to_remote_instance(instance[1], post.community.id, announce)
|
||||
else:
|
||||
success = post_request(post.community.ap_inbox_url, action_json, current_user.private_key,
|
||||
current_user.ap_profile_id + '#main-key')
|
||||
if not success:
|
||||
|
|
|
@ -153,8 +153,8 @@
|
|||
<h2>{{ _('About community') }}</h2>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<p>{{ community.description_html|safe if community.description_html else '' }}</p>
|
||||
<p>{{ community.rules_html|safe if community.rules_html else '' }}</p>
|
||||
<p>{{ post.community.description_html|safe if post.community.description_html else '' }}</p>
|
||||
<p>{{ post.community.rules_html|safe if post.community.rules_html else '' }}</p>
|
||||
{% if len(mods) > 0 and not post.community.private_mods %}
|
||||
<h3>Moderators</h3>
|
||||
<ul class="moderator_list">
|
||||
|
|
Loading…
Add table
Reference in a new issue