add: 4 more achievements
This commit is contained in:
parent
50f4592de2
commit
b501a7c5f0
5 changed files with 52 additions and 7 deletions
|
@ -582,6 +582,7 @@ input[type="checkbox"]:checked {
|
||||||
font-size: 12px;
|
font-size: 12px;
|
||||||
border-radius: 6px;
|
border-radius: 6px;
|
||||||
height: max-content;
|
height: max-content;
|
||||||
|
font-weight: 600;
|
||||||
}
|
}
|
||||||
|
|
||||||
.notification.tr {
|
.notification.tr {
|
||||||
|
@ -670,7 +671,7 @@ nav .button:not(.title):not(.active):hover {
|
||||||
margin-bottom: 0;
|
margin-bottom: 0;
|
||||||
backdrop-filter: none;
|
backdrop-filter: none;
|
||||||
bottom: 0;
|
bottom: 0;
|
||||||
position: absolute;
|
position: fixed;
|
||||||
height: max-content;
|
height: max-content;
|
||||||
top: unset;
|
top: unset;
|
||||||
}
|
}
|
||||||
|
|
|
@ -464,11 +464,20 @@ pub async fn enable_totp_request(
|
||||||
Extension(data): Extension<State>,
|
Extension(data): Extension<State>,
|
||||||
) -> impl IntoResponse {
|
) -> impl IntoResponse {
|
||||||
let data = &(data.read().await).0;
|
let data = &(data.read().await).0;
|
||||||
let user = match get_user_from_token!(jar, data) {
|
let mut user = match get_user_from_token!(jar, data) {
|
||||||
Some(ua) => ua,
|
Some(ua) => ua,
|
||||||
None => return Json(Error::NotAllowed.into()),
|
None => return Json(Error::NotAllowed.into()),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// award achievement
|
||||||
|
if let Err(e) = data
|
||||||
|
.add_achievement(&mut user, AchievementName::Enable2fa.into())
|
||||||
|
.await
|
||||||
|
{
|
||||||
|
return Json(e.into());
|
||||||
|
}
|
||||||
|
|
||||||
|
// ...
|
||||||
match data.enable_totp(id, user).await {
|
match data.enable_totp(id, user).await {
|
||||||
Ok(x) => Json(ApiReturn {
|
Ok(x) => Json(ApiReturn {
|
||||||
ok: true,
|
ok: true,
|
||||||
|
|
|
@ -16,6 +16,7 @@ use crate::{
|
||||||
use tetratto_core::{
|
use tetratto_core::{
|
||||||
database::NAME_REGEX,
|
database::NAME_REGEX,
|
||||||
model::{
|
model::{
|
||||||
|
auth::AchievementName,
|
||||||
journals::{JournalPrivacyPermission, Note},
|
journals::{JournalPrivacyPermission, Note},
|
||||||
oauth,
|
oauth,
|
||||||
permissions::FinePermission,
|
permissions::FinePermission,
|
||||||
|
@ -190,11 +191,20 @@ pub async fn update_content_request(
|
||||||
Json(props): Json<UpdateNoteContent>,
|
Json(props): Json<UpdateNoteContent>,
|
||||||
) -> impl IntoResponse {
|
) -> impl IntoResponse {
|
||||||
let data = &(data.read().await).0;
|
let data = &(data.read().await).0;
|
||||||
let user = match get_user_from_token!(jar, data, oauth::AppScope::UserManageNotes) {
|
let mut user = match get_user_from_token!(jar, data, oauth::AppScope::UserManageNotes) {
|
||||||
Some(ua) => ua,
|
Some(ua) => ua,
|
||||||
None => return Json(Error::NotAllowed.into()),
|
None => return Json(Error::NotAllowed.into()),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// award achievement
|
||||||
|
if let Err(e) = data
|
||||||
|
.add_achievement(&mut user, AchievementName::EditNote.into())
|
||||||
|
.await
|
||||||
|
{
|
||||||
|
return Json(e.into());
|
||||||
|
}
|
||||||
|
|
||||||
|
// ...
|
||||||
match data.update_note_content(id, &user, &props.content).await {
|
match data.update_note_content(id, &user, &props.content).await {
|
||||||
Ok(_) => {
|
Ok(_) => {
|
||||||
if let Err(e) = data
|
if let Err(e) = data
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
use crate::config::StringBan;
|
use crate::config::StringBan;
|
||||||
use crate::model::auth::Notification;
|
use crate::model::auth::{AchievementName, Notification};
|
||||||
use crate::model::communities::{CommunityMembership, CommunityReadAccess, Poll, Question};
|
use crate::model::communities::{CommunityMembership, CommunityReadAccess, Poll, Question};
|
||||||
use crate::model::communities_permissions::CommunityPermission;
|
use crate::model::communities_permissions::CommunityPermission;
|
||||||
use crate::model::moderation::AuditLogEntry;
|
use crate::model::moderation::AuditLogEntry;
|
||||||
|
@ -1624,6 +1624,8 @@ impl DataManager {
|
||||||
self.get_community_by_id(data.community).await?
|
self.get_community_by_id(data.community).await?
|
||||||
};
|
};
|
||||||
|
|
||||||
|
let mut owner = self.get_user_by_id(data.owner).await?;
|
||||||
|
|
||||||
// check values (if this isn't reposting something else)
|
// check values (if this isn't reposting something else)
|
||||||
let is_reposting = if let Some(ref repost) = data.context.repost {
|
let is_reposting = if let Some(ref repost) = data.context.repost {
|
||||||
repost.reposting.is_some()
|
repost.reposting.is_some()
|
||||||
|
@ -1651,6 +1653,10 @@ impl DataManager {
|
||||||
} else if data.title.len() > 128 {
|
} else if data.title.len() > 128 {
|
||||||
return Err(Error::DataTooLong("title".to_string()));
|
return Err(Error::DataTooLong("title".to_string()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// award achievement
|
||||||
|
self.add_achievement(&mut owner, AchievementName::CreatePostWithTitle.into())
|
||||||
|
.await?;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1663,7 +1669,6 @@ impl DataManager {
|
||||||
data.context.is_nsfw = community.context.is_nsfw;
|
data.context.is_nsfw = community.context.is_nsfw;
|
||||||
|
|
||||||
// remove request if we were answering a question
|
// remove request if we were answering a question
|
||||||
let owner = self.get_user_by_id(data.owner).await?;
|
|
||||||
if data.context.answering != 0 {
|
if data.context.answering != 0 {
|
||||||
let question = self.get_question_by_id(data.context.answering).await?;
|
let question = self.get_question_by_id(data.context.answering).await?;
|
||||||
|
|
||||||
|
@ -1790,6 +1795,10 @@ impl DataManager {
|
||||||
)
|
)
|
||||||
.await?;
|
.await?;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// award achievement
|
||||||
|
self.add_achievement(&mut owner, AchievementName::CreateRepost.into())
|
||||||
|
.await?;
|
||||||
}
|
}
|
||||||
|
|
||||||
// check if the post we're replying to allows commments
|
// check if the post we're replying to allows commments
|
||||||
|
|
|
@ -490,7 +490,7 @@ pub struct ExternalConnectionData {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The total number of achievements needed to 100% Tetratto!
|
/// The total number of achievements needed to 100% Tetratto!
|
||||||
pub const ACHIEVEMENTS: usize = 24;
|
pub const ACHIEVEMENTS: usize = 28;
|
||||||
|
|
||||||
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq, Eq)]
|
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq, Eq)]
|
||||||
pub enum AchievementName {
|
pub enum AchievementName {
|
||||||
|
@ -518,6 +518,10 @@ pub enum AchievementName {
|
||||||
JoinCommunity,
|
JoinCommunity,
|
||||||
CreateDraft,
|
CreateDraft,
|
||||||
EditPost,
|
EditPost,
|
||||||
|
Enable2fa,
|
||||||
|
EditNote,
|
||||||
|
CreatePostWithTitle,
|
||||||
|
CreateRepost,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq, Eq)]
|
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq, Eq)]
|
||||||
|
@ -554,6 +558,10 @@ impl AchievementName {
|
||||||
Self::JoinCommunity => "A sense of community...",
|
Self::JoinCommunity => "A sense of community...",
|
||||||
Self::CreateDraft => "Maybe later!",
|
Self::CreateDraft => "Maybe later!",
|
||||||
Self::EditPost => "Grammar police?",
|
Self::EditPost => "Grammar police?",
|
||||||
|
Self::Enable2fa => "Locked in",
|
||||||
|
Self::EditNote => "I take it back!",
|
||||||
|
Self::CreatePostWithTitle => "Must declutter",
|
||||||
|
Self::CreateRepost => "More than a like or a comment...",
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -575,7 +583,7 @@ impl AchievementName {
|
||||||
Self::Get50Likes => "Get 50 likes on one post.",
|
Self::Get50Likes => "Get 50 likes on one post.",
|
||||||
Self::Get100Likes => "Get 100 likes on one post.",
|
Self::Get100Likes => "Get 100 likes on one post.",
|
||||||
Self::Get25Dislikes => "Get 25 dislikes on one post... :(",
|
Self::Get25Dislikes => "Get 25 dislikes on one post... :(",
|
||||||
Self::Get1Follower => "Get 1 follow. Cool!",
|
Self::Get1Follower => "Get 1 follower. Cool!",
|
||||||
Self::Get10Followers => "Get 10 followers. You're getting popular!",
|
Self::Get10Followers => "Get 10 followers. You're getting popular!",
|
||||||
Self::Get50Followers => "Get 50 followers. Okay, you're fairly popular!",
|
Self::Get50Followers => "Get 50 followers. Okay, you're fairly popular!",
|
||||||
Self::Get100Followers => "Get 100 followers. You might be famous..?",
|
Self::Get100Followers => "Get 100 followers. You might be famous..?",
|
||||||
|
@ -583,6 +591,10 @@ impl AchievementName {
|
||||||
Self::JoinCommunity => "Join a community. Welcome!",
|
Self::JoinCommunity => "Join a community. Welcome!",
|
||||||
Self::CreateDraft => "Save a post as a draft.",
|
Self::CreateDraft => "Save a post as a draft.",
|
||||||
Self::EditPost => "Edit a post.",
|
Self::EditPost => "Edit a post.",
|
||||||
|
Self::Enable2fa => "Enable TOTP 2FA.",
|
||||||
|
Self::EditNote => "Edit a note.",
|
||||||
|
Self::CreatePostWithTitle => "Create a post with a title.",
|
||||||
|
Self::CreateRepost => "Create a repost or quote.",
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -614,6 +626,10 @@ impl AchievementName {
|
||||||
Self::JoinCommunity => Common,
|
Self::JoinCommunity => Common,
|
||||||
Self::CreateDraft => Common,
|
Self::CreateDraft => Common,
|
||||||
Self::EditPost => Common,
|
Self::EditPost => Common,
|
||||||
|
Self::Enable2fa => Rare,
|
||||||
|
Self::EditNote => Uncommon,
|
||||||
|
Self::CreatePostWithTitle => Common,
|
||||||
|
Self::CreateRepost => Common,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue