mirror of
https://codeberg.org/rimu/pyfedi
synced 2025-01-23 11:26:56 -08:00
simplify voting
This commit is contained in:
parent
60efbe988f
commit
78d1dfb45c
5 changed files with 2 additions and 26 deletions
|
@ -967,10 +967,6 @@ def create_post_reply(activity_log: ActivityPubLog, community: Community, in_rep
|
|||
db.session.commit()
|
||||
|
||||
if user.reputation > 100:
|
||||
vote = PostReplyVote(user_id=1, author_id=post_reply.user_id,
|
||||
post_reply_id=post_reply.id,
|
||||
effect=instance_weight(user.ap_domain))
|
||||
db.session.add(vote)
|
||||
post_reply.up_votes += 1
|
||||
post_reply.score += 1
|
||||
post_reply.ranking = confidence(post_reply.up_votes, post_reply.down_votes)
|
||||
|
@ -1056,10 +1052,6 @@ def create_post(activity_log: ActivityPubLog, community: Community, request_json
|
|||
notify_about_post(post)
|
||||
|
||||
if user.reputation > 100:
|
||||
vote = PostVote(user_id=1, author_id=post.user_id,
|
||||
post_id=post.id,
|
||||
effect=instance_weight(user.ap_domain))
|
||||
db.session.add(vote)
|
||||
post.up_votes += 1
|
||||
post.score += 1
|
||||
post.ranking = post_ranking(post.score, post.posted_at)
|
||||
|
|
|
@ -266,16 +266,10 @@ def save_post(form, post: Post):
|
|||
raise Exception('invalid post type')
|
||||
if post.id is None:
|
||||
if current_user.reputation > 100:
|
||||
postvote = PostVote(user_id=1, author_id=current_user.id, post=post, effect=1.0)
|
||||
post.up_votes = 1
|
||||
post.score = 1
|
||||
post.ranking = 1
|
||||
db.session.add(postvote)
|
||||
if current_user.reputation < -100:
|
||||
postvote = PostVote(user_id=1, author_id=current_user.id, post=post, effect=-1.0)
|
||||
post.score = -1
|
||||
post.ranking = -1
|
||||
db.session.add(postvote)
|
||||
post.ranking = post_ranking(post.score, utcnow())
|
||||
db.session.add(post)
|
||||
|
||||
|
|
|
@ -88,18 +88,12 @@ def show_post(post_id: int):
|
|||
db.session.commit()
|
||||
reply.ap_id = reply.profile_id()
|
||||
if current_user.reputation > 100:
|
||||
reply_vote = PostReplyVote(user_id=1, author_id=current_user.id, post_reply_id=reply.id,
|
||||
effect=1.0)
|
||||
reply.up_votes += 1
|
||||
reply.score += 1
|
||||
reply.ranking += 1
|
||||
db.session.add(reply_vote)
|
||||
elif current_user.reputation < -100:
|
||||
reply_vote = PostReplyVote(user_id=1, author_id=current_user.id, post_reply_id=reply.id,
|
||||
effect=-1.0)
|
||||
reply.score -= 1
|
||||
reply.ranking -= 1
|
||||
db.session.add(reply_vote)
|
||||
db.session.commit()
|
||||
form.body.data = ''
|
||||
flash('Your comment has been added.')
|
||||
|
@ -425,16 +419,12 @@ def add_reply(post_id: int, comment_id: int):
|
|||
reply.ap_id = reply.profile_id()
|
||||
db.session.commit()
|
||||
if current_user.reputation > 100:
|
||||
reply_vote = PostReplyVote(user_id=1, author_id=current_user.id, post_reply_id=reply.id, effect=1.0)
|
||||
reply.up_votes += 1
|
||||
reply.score += 1
|
||||
reply.ranking += 1
|
||||
db.session.add(reply_vote)
|
||||
elif current_user.reputation < -100:
|
||||
reply_vote = PostReplyVote(user_id=1, author_id=current_user.id, post_reply_id=reply.id, effect=-1.0)
|
||||
reply.score -= 1
|
||||
reply.ranking -= 1
|
||||
db.session.add(reply_vote)
|
||||
post.reply_count = post_reply_count(post.id)
|
||||
post.last_active = post.community.last_active = utcnow()
|
||||
db.session.commit()
|
||||
|
|
|
@ -232,7 +232,7 @@ def html_to_markdown_worker(element, indent_level=0):
|
|||
|
||||
def markdown_to_html(markdown_text) -> str:
|
||||
if markdown_text:
|
||||
return allowlist_html(markdown2.markdown(markdown_text, safe_mode=True))
|
||||
return allowlist_html(markdown2.markdown(markdown_text, safe_mode=True, extras={'middle-word-em': False}))
|
||||
else:
|
||||
return ''
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@ pycryptodome==3.18.0
|
|||
arrow==1.2.3
|
||||
pyld==2.0.3
|
||||
boto3==1.28.35
|
||||
markdown2==2.4.10
|
||||
markdown2==2.4.12
|
||||
beautifulsoup4==4.12.2
|
||||
flask-caching==2.0.2
|
||||
Pillow
|
||||
|
|
Loading…
Reference in a new issue