add: 8 achievements add: larger text setting fix: small infinite
timeline bugs
This commit is contained in:
parent
b860f74124
commit
5dd9fa01cb
19 changed files with 241 additions and 123 deletions
|
@ -116,7 +116,7 @@ pub async fn update_user_settings_request(
|
|||
Json(mut req): Json<UserSettings>,
|
||||
) -> impl IntoResponse {
|
||||
let data = &(data.read().await).0;
|
||||
let user = match get_user_from_token!(jar, data, oauth::AppScope::UserManageProfile) {
|
||||
let mut user = match get_user_from_token!(jar, data, oauth::AppScope::UserManageProfile) {
|
||||
Some(ua) => ua,
|
||||
None => return Json(Error::NotAllowed.into()),
|
||||
};
|
||||
|
@ -153,7 +153,7 @@ pub async fn update_user_settings_request(
|
|||
|
||||
// award achievement
|
||||
if let Err(e) = data
|
||||
.add_achievement(&user, AchievementName::EditSettings.into())
|
||||
.add_achievement(&mut user, AchievementName::EditSettings.into())
|
||||
.await
|
||||
{
|
||||
return Json(e.into());
|
||||
|
|
|
@ -22,7 +22,7 @@ pub async fn follow_request(
|
|||
Extension(data): Extension<State>,
|
||||
) -> impl IntoResponse {
|
||||
let data = &(data.read().await).0;
|
||||
let user = match get_user_from_token!(jar, data, oauth::AppScope::UserManageFollowing) {
|
||||
let mut user = match get_user_from_token!(jar, data, oauth::AppScope::UserManageFollowing) {
|
||||
Some(ua) => ua,
|
||||
None => return Json(Error::NotAllowed.into()),
|
||||
};
|
||||
|
@ -40,7 +40,7 @@ pub async fn follow_request(
|
|||
} else {
|
||||
// create
|
||||
match data
|
||||
.create_userfollow(UserFollow::new(user.id, id), false)
|
||||
.create_userfollow(UserFollow::new(user.id, id), &user, false)
|
||||
.await
|
||||
{
|
||||
Ok(r) => {
|
||||
|
@ -59,13 +59,15 @@ pub async fn follow_request(
|
|||
return Json(e.into());
|
||||
};
|
||||
|
||||
// award achievement
|
||||
if let Err(e) = data
|
||||
.add_achievement(&user, AchievementName::FollowUser.into())
|
||||
.add_achievement(&mut user, AchievementName::FollowUser.into())
|
||||
.await
|
||||
{
|
||||
return Json(e.into());
|
||||
}
|
||||
|
||||
// ...
|
||||
Json(ApiReturn {
|
||||
ok: true,
|
||||
message: "User followed".to_string(),
|
||||
|
@ -123,7 +125,7 @@ pub async fn accept_follow_request(
|
|||
|
||||
// create follow
|
||||
match data
|
||||
.create_userfollow(UserFollow::new(id, user.id), true)
|
||||
.create_userfollow(UserFollow::new(id, user.id), &user, true)
|
||||
.await
|
||||
{
|
||||
Ok(_) => {
|
||||
|
|
|
@ -37,7 +37,7 @@ pub async fn create_request(
|
|||
JsonMultipart(images, req): JsonMultipart<CreatePost>,
|
||||
) -> impl IntoResponse {
|
||||
let data = &(data.read().await).0;
|
||||
let user = match get_user_from_token!(jar, data, oauth::AppScope::UserCreatePosts) {
|
||||
let mut user = match get_user_from_token!(jar, data, oauth::AppScope::UserCreatePosts) {
|
||||
Some(ua) => ua,
|
||||
None => return Json(Error::NotAllowed.into()),
|
||||
};
|
||||
|
@ -181,7 +181,7 @@ pub async fn create_request(
|
|||
|
||||
// achievements
|
||||
if let Err(e) = data
|
||||
.add_achievement(&user, AchievementName::CreatePost.into())
|
||||
.add_achievement(&mut user, AchievementName::CreatePost.into())
|
||||
.await
|
||||
{
|
||||
return Json(e.into());
|
||||
|
@ -189,7 +189,7 @@ pub async fn create_request(
|
|||
|
||||
if user.post_count >= 49 {
|
||||
if let Err(e) = data
|
||||
.add_achievement(&user, AchievementName::Create50Posts.into())
|
||||
.add_achievement(&mut user, AchievementName::Create50Posts.into())
|
||||
.await
|
||||
{
|
||||
return Json(e.into());
|
||||
|
@ -198,7 +198,7 @@ pub async fn create_request(
|
|||
|
||||
if user.post_count >= 99 {
|
||||
if let Err(e) = data
|
||||
.add_achievement(&user, AchievementName::Create100Posts.into())
|
||||
.add_achievement(&mut user, AchievementName::Create100Posts.into())
|
||||
.await
|
||||
{
|
||||
return Json(e.into());
|
||||
|
@ -207,7 +207,7 @@ pub async fn create_request(
|
|||
|
||||
if user.post_count >= 999 {
|
||||
if let Err(e) = data
|
||||
.add_achievement(&user, AchievementName::Create1000Posts.into())
|
||||
.add_achievement(&mut user, AchievementName::Create1000Posts.into())
|
||||
.await
|
||||
{
|
||||
return Json(e.into());
|
||||
|
|
|
@ -52,12 +52,23 @@ pub async fn create_request(
|
|||
|
||||
// award achievement
|
||||
if let Some(ref user) = user {
|
||||
let mut user = user.clone();
|
||||
|
||||
if let Err(e) = data
|
||||
.add_achievement(user, AchievementName::CreateQuestion.into())
|
||||
.add_achievement(&mut user, AchievementName::CreateQuestion.into())
|
||||
.await
|
||||
{
|
||||
return Json(e.into());
|
||||
}
|
||||
|
||||
if drawings.len() > 0 {
|
||||
if let Err(e) = data
|
||||
.add_achievement(&mut user, AchievementName::CreateDrawing.into())
|
||||
.await
|
||||
{
|
||||
return Json(e.into());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ...
|
||||
|
|
|
@ -98,7 +98,7 @@ pub async fn create_request(
|
|||
Json(props): Json<CreateJournal>,
|
||||
) -> impl IntoResponse {
|
||||
let data = &(data.read().await).0;
|
||||
let user = match get_user_from_token!(jar, data, oauth::AppScope::UserCreateJournals) {
|
||||
let mut user = match get_user_from_token!(jar, data, oauth::AppScope::UserCreateJournals) {
|
||||
Some(ua) => ua,
|
||||
None => return Json(Error::NotAllowed.into()),
|
||||
};
|
||||
|
@ -110,7 +110,7 @@ pub async fn create_request(
|
|||
Ok(x) => {
|
||||
// award achievement
|
||||
if let Err(e) = data
|
||||
.add_achievement(&user, AchievementName::CreateJournal.into())
|
||||
.add_achievement(&mut user, AchievementName::CreateJournal.into())
|
||||
.await
|
||||
{
|
||||
return Json(e.into());
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue