add: user achievements
This commit is contained in:
parent
e7c4cf14aa
commit
b860f74124
15 changed files with 318 additions and 11 deletions
|
@ -15,6 +15,7 @@ use crate::{
|
|||
use tetratto_core::{
|
||||
database::NAME_REGEX,
|
||||
model::{
|
||||
auth::AchievementName,
|
||||
journals::{Journal, JournalPrivacyPermission},
|
||||
oauth,
|
||||
permissions::FinePermission,
|
||||
|
@ -106,11 +107,22 @@ pub async fn create_request(
|
|||
.create_journal(Journal::new(user.id, props.title))
|
||||
.await
|
||||
{
|
||||
Ok(x) => Json(ApiReturn {
|
||||
ok: true,
|
||||
message: "Journal created".to_string(),
|
||||
payload: Some(x.id.to_string()),
|
||||
}),
|
||||
Ok(x) => {
|
||||
// award achievement
|
||||
if let Err(e) = data
|
||||
.add_achievement(&user, AchievementName::CreateJournal.into())
|
||||
.await
|
||||
{
|
||||
return Json(e.into());
|
||||
}
|
||||
|
||||
// ...
|
||||
Json(ApiReturn {
|
||||
ok: true,
|
||||
message: "Journal created".to_string(),
|
||||
payload: Some(x.id.to_string()),
|
||||
})
|
||||
}
|
||||
Err(e) => Json(e.into()),
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue