diff options
author | Dessalines <happydooby@gmail.com> | 2019-06-02 19:46:35 -0700 |
---|---|---|
committer | Dessalines <happydooby@gmail.com> | 2019-06-02 19:46:35 -0700 |
commit | 0a0c80fbbeac2342bacf68e0cd6c047a369ed742 (patch) | |
tree | 2c52cc84554c9d9953085235658f990424627428 /server/src/api/user.rs | |
parent | c337f54a49fcb9dcf96e90f81783ba9817cc01a1 (diff) | |
parent | 73e8b3fcd8439d95bb671d67f8f862b4cb82cc74 (diff) |
Merge branch 'dev'
Diffstat (limited to 'server/src/api/user.rs')
-rw-r--r-- | server/src/api/user.rs | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/server/src/api/user.rs b/server/src/api/user.rs index 9361ca4d..d6d5962e 100644 --- a/server/src/api/user.rs +++ b/server/src/api/user.rs @@ -161,9 +161,27 @@ impl Perform<LoginResponse> for Oper<Register> { } }; + // Create the main community if it doesn't exist + let main_community: Community = match Community::read_from_name(&conn, "main".to_string()) { + Ok(c) => c, + Err(_e) => { + let community_form = CommunityForm { + name: "main".to_string(), + title: "The Default Community".to_string(), + description: Some("The Default Community".to_string()), + category_id: 1, + creator_id: inserted_user.id, + removed: None, + deleted: None, + updated: None, + }; + Community::create(&conn, &community_form).unwrap() + } + }; + // Sign them up for main community no matter what let community_follower_form = CommunityFollowerForm { - community_id: 1, + community_id: main_community.id, user_id: inserted_user.id, }; @@ -177,7 +195,7 @@ impl Perform<LoginResponse> for Oper<Register> { // If its an admin, add them as a mod and follower to main if data.admin { let community_moderator_form = CommunityModeratorForm { - community_id: 1, + community_id: main_community.id, user_id: inserted_user.id, }; |