diff options
author | Dessalines <tyhou13@gmx.com> | 2019-08-13 19:52:43 -0700 |
---|---|---|
committer | Dessalines <tyhou13@gmx.com> | 2019-08-13 19:52:43 -0700 |
commit | d7ab85ab70478f1ec440c920d726d08b145cef5e (patch) | |
tree | cc799c34a29c4e6070a3f3a34823e7c091cddaad /server/src/api/community.rs | |
parent | ad4dbbcd7726e75aea1e06111a1af3039cbeca70 (diff) |
Squashed commit of the following:
commit ecd6c5a2f47cbbb2fc4bf482fadd78380303a904
Author: Dessalines <happydooby@gmail.com>
Date: Tue Aug 13 19:49:38 2019 -0700
Adding some docs
commit 3babd09affb1920da3d0a0ceb7e24c8aeeb9cf1a
Author: Dessalines <happydooby@gmail.com>
Date: Tue Aug 13 19:28:46 2019 -0700
Adding save user settings
commit 6e8da9cc9e522d0da668bfa31944c3348cc79620
Merge: 3246d5d c148eef
Author: Dessalines <happydooby@gmail.com>
Date: Tue Aug 13 17:26:25 2019 -0700
Merge branch 'dev' into nsfw
commit b3d4a5c4ce441bcc664704aba44cedb51d887599
Author: Dessalines <happydooby@gmail.com>
Date: Sun Aug 11 20:55:09 2019 -0700
nsfw mostly done, except for settings page.
Diffstat (limited to 'server/src/api/community.rs')
-rw-r--r-- | server/src/api/community.rs | 30 |
1 files changed, 25 insertions, 5 deletions
diff --git a/server/src/api/community.rs b/server/src/api/community.rs index ca73de49..74058488 100644 --- a/server/src/api/community.rs +++ b/server/src/api/community.rs @@ -22,7 +22,8 @@ pub struct CreateCommunity { name: String, title: String, description: Option<String>, - category_id: i32 , + category_id: i32, + nsfw: bool, auth: String } @@ -86,6 +87,7 @@ pub struct EditCommunity { category_id: i32, removed: Option<bool>, deleted: Option<bool>, + nsfw: bool, reason: Option<String>, expires: Option<i64>, auth: String @@ -194,6 +196,7 @@ impl Perform<CommunityResponse> for Oper<CreateCommunity> { creator_id: user_id, removed: None, deleted: None, + nsfw: data.nsfw, updated: None, }; @@ -291,6 +294,7 @@ impl Perform<CommunityResponse> for Oper<EditCommunity> { creator_id: user_id, removed: data.removed.to_owned(), deleted: data.deleted.to_owned(), + nsfw: data.nsfw, updated: Some(naive_now()) }; @@ -333,22 +337,38 @@ impl Perform<ListCommunitiesResponse> for Oper<ListCommunities> { let data: &ListCommunities = &self.data; let conn = establish_connection(); - let user_id: Option<i32> = match &data.auth { + let user_claims: Option<Claims> = match &data.auth { Some(auth) => { match Claims::decode(&auth) { Ok(claims) => { - let user_id = claims.claims.id; - Some(user_id) + Some(claims.claims) } Err(_e) => None } } None => None }; + + let user_id = match &user_claims { + Some(claims) => Some(claims.id), + None => None + }; + + let show_nsfw = match &user_claims { + Some(claims) => claims.show_nsfw, + None => false + }; let sort = SortType::from_str(&data.sort)?; - let communities: Vec<CommunityView> = CommunityView::list(&conn, &sort, user_id, None, data.page, data.limit)?; + let communities: Vec<CommunityView> = CommunityView::list( + &conn, + &sort, + user_id, + show_nsfw, + None, + data.page, + data.limit)?; // Return the jwt Ok( |