add: user achievements

This commit is contained in:
trisua 2025-06-27 03:45:50 -04:00
parent e7c4cf14aa
commit b860f74124
15 changed files with 318 additions and 11 deletions

View file

@ -7,6 +7,7 @@ use axum::{
use axum_extra::extract::CookieJar;
use tetratto_core::model::{
addr::RemoteAddr,
auth::AchievementName,
communities::{Poll, PollVote, Post},
oauth,
permissions::FinePermission,
@ -178,6 +179,41 @@ pub async fn create_request(
}
}
// achievements
if let Err(e) = data
.add_achievement(&user, AchievementName::CreatePost.into())
.await
{
return Json(e.into());
}
if user.post_count >= 49 {
if let Err(e) = data
.add_achievement(&user, AchievementName::Create50Posts.into())
.await
{
return Json(e.into());
}
}
if user.post_count >= 99 {
if let Err(e) = data
.add_achievement(&user, AchievementName::Create100Posts.into())
.await
{
return Json(e.into());
}
}
if user.post_count >= 999 {
if let Err(e) = data
.add_achievement(&user, AchievementName::Create1000Posts.into())
.await
{
return Json(e.into());
}
}
// return
Json(ApiReturn {
ok: true,