fix bugs
This commit is contained in:
@@ -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 });
|
||||||
|
|||||||
Reference in New Issue
Block a user