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
|
comment.score += effect
|
||||||
vote = PostReplyVote(user_id=user.id, post_reply_id=comment.id,
|
vote = PostReplyVote(user_id=user.id, post_reply_id=comment.id,
|
||||||
author_id=comment.author.id, effect=effect)
|
author_id=comment.author.id, effect=effect)
|
||||||
|
if comment.community.low_quality and effect > 0:
|
||||||
|
effect = 0
|
||||||
comment.author.reputation += effect
|
comment.author.reputation += effect
|
||||||
db.session.add(vote)
|
db.session.add(vote)
|
||||||
else:
|
else:
|
||||||
|
@ -675,6 +677,8 @@ def upvote_post_reply(comment, user):
|
||||||
comment.score += effect
|
comment.score += effect
|
||||||
vote = PostReplyVote(user_id=user.id, post_reply_id=comment.id,
|
vote = PostReplyVote(user_id=user.id, post_reply_id=comment.id,
|
||||||
author_id=comment.author.id, effect=effect)
|
author_id=comment.author.id, effect=effect)
|
||||||
|
if comment.community.low_quality and effect > 0:
|
||||||
|
effect = 0
|
||||||
comment.author.reputation += effect
|
comment.author.reputation += effect
|
||||||
db.session.add(vote)
|
db.session.add(vote)
|
||||||
else:
|
else:
|
||||||
|
@ -690,6 +694,8 @@ def upvote_post(post, user):
|
||||||
post.score += effect
|
post.score += effect
|
||||||
vote = PostVote(user_id=user.id, post_id=post.id, author_id=post.author.id,
|
vote = PostVote(user_id=user.id, post_id=post.id, author_id=post.author.id,
|
||||||
effect=effect)
|
effect=effect)
|
||||||
|
if post.community.low_quality and effect > 0:
|
||||||
|
effect = 0
|
||||||
post.author.reputation += effect
|
post.author.reputation += effect
|
||||||
db.session.add(vote)
|
db.session.add(vote)
|
||||||
else:
|
else:
|
||||||
|
@ -705,6 +711,8 @@ def upvote_post(post, user):
|
||||||
post.score += effect
|
post.score += effect
|
||||||
vote = PostVote(user_id=user.id, post_id=post.id, author_id=post.author.id,
|
vote = PostVote(user_id=user.id, post_id=post.id, author_id=post.author.id,
|
||||||
effect=effect)
|
effect=effect)
|
||||||
|
if post.community.low_quality and effect > 0:
|
||||||
|
effect = 0
|
||||||
post.author.reputation += effect
|
post.author.reputation += effect
|
||||||
db.session.add(vote)
|
db.session.add(vote)
|
||||||
|
|
||||||
|
|
|
@ -150,7 +150,8 @@ def post_vote(post_id: int, vote_direction):
|
||||||
post = Post.query.get_or_404(post_id)
|
post = Post.query.get_or_404(post_id)
|
||||||
existing_vote = PostVote.query.filter_by(user_id=current_user.id, post_id=post.id).first()
|
existing_vote = PostVote.query.filter_by(user_id=current_user.id, post_id=post.id).first()
|
||||||
if existing_vote:
|
if existing_vote:
|
||||||
post.author.reputation -= existing_vote.effect
|
if not post.community.low_quality:
|
||||||
|
post.author.reputation -= existing_vote.effect
|
||||||
if existing_vote.effect > 0: # previous vote was up
|
if existing_vote.effect > 0: # previous vote was up
|
||||||
if vote_direction == 'upvote': # new vote is also up, so remove it
|
if vote_direction == 'upvote': # new vote is also up, so remove it
|
||||||
db.session.delete(existing_vote)
|
db.session.delete(existing_vote)
|
||||||
|
@ -186,20 +187,38 @@ def post_vote(post_id: int, vote_direction):
|
||||||
downvoted_class = 'voted_down'
|
downvoted_class = 'voted_down'
|
||||||
vote = PostVote(user_id=current_user.id, post_id=post.id, author_id=post.author.id,
|
vote = PostVote(user_id=current_user.id, post_id=post.id, author_id=post.author.id,
|
||||||
effect=effect)
|
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
|
post.author.reputation += effect
|
||||||
db.session.add(vote)
|
db.session.add(vote)
|
||||||
|
|
||||||
|
action_type = 'Like' if vote_direction == 'upvote' else 'Dislike'
|
||||||
|
action_json = {
|
||||||
|
'actor': current_user.profile_id(),
|
||||||
|
'object': post.profile_id(),
|
||||||
|
'type': action_type,
|
||||||
|
'id': f"https://{current_app.config['SERVER_NAME']}/activities/{action_type.lower()}/{gibberish(15)}",
|
||||||
|
'audience': post.community.profile_id()
|
||||||
|
}
|
||||||
if post.community.is_local():
|
if post.community.is_local():
|
||||||
...
|
announce = {
|
||||||
else:
|
"id": f"https://{current_app.config['SERVER_NAME']}/activities/announce/{gibberish(15)}",
|
||||||
action_type = 'Like' if vote_direction == 'upvote' else 'Dislike'
|
"type": 'Announce',
|
||||||
action_json = {
|
"to": [
|
||||||
'actor': current_user.profile_id(),
|
"https://www.w3.org/ns/activitystreams#Public"
|
||||||
'object': post.profile_id(),
|
],
|
||||||
'type': action_type,
|
"actor": post.community.ap_profile_id,
|
||||||
'id': f"https://{current_app.config['SERVER_NAME']}/activities/{action_type.lower()}/{gibberish(15)}",
|
"cc": [
|
||||||
'audience': post.community.profile_id()
|
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,
|
success = post_request(post.community.ap_inbox_url, action_json, current_user.private_key,
|
||||||
current_user.ap_profile_id + '#main-key')
|
current_user.ap_profile_id + '#main-key')
|
||||||
if not success:
|
if not success:
|
||||||
|
|
|
@ -153,8 +153,8 @@
|
||||||
<h2>{{ _('About community') }}</h2>
|
<h2>{{ _('About community') }}</h2>
|
||||||
</div>
|
</div>
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
<p>{{ community.description_html|safe if community.description_html else '' }}</p>
|
<p>{{ post.community.description_html|safe if post.community.description_html else '' }}</p>
|
||||||
<p>{{ community.rules_html|safe if community.rules_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 %}
|
{% if len(mods) > 0 and not post.community.private_mods %}
|
||||||
<h3>Moderators</h3>
|
<h3>Moderators</h3>
|
||||||
<ul class="moderator_list">
|
<ul class="moderator_list">
|
||||||
|
|
Loading…
Add table
Reference in a new issue