Browse Source

fix bugs

master
hole-thu 3 years ago
parent
commit
9937bc0dc7
  1. 9
      src/api/attention.rs

9
src/api/attention.rs

@ -35,17 +35,22 @@ pub async fn attention_post(
if att.has(ai.pid).await? != switch_to { if att.has(ai.pid).await? != switch_to {
if switch_to { if switch_to {
att.add(ai.pid).await?; att.add(ai.pid).await?;
delta = (p.n_attentions < 3 * p.n_comments) as i32; delta = 1;
} else { } else {
att.remove(ai.pid).await?; att.remove(ai.pid).await?;
delta = -1; delta = -1;
} }
let hot_delta = if p.n_attentions <= 3 * p.n_comments {
delta * 2
} else {
0
};
update!( update!(
p, p,
posts, posts,
&db, &db,
{ n_attentions, add delta }, { n_attentions, add delta },
{ hot_score, add delta * 2 } { hot_score, add hot_delta }
); );
if switch_to && user.is_admin { if switch_to && user.is_admin {
update!(p, posts, &db, { is_reported, to false }); update!(p, posts, &db, { is_reported, to false });

Loading…
Cancel
Save