use crate::{
newtypes::{CommunityId, DbUrl, PersonId},
- source::community::{
- Community,
- CommunityFollower,
- CommunityFollowerForm,
- CommunityForm,
- CommunityModerator,
- CommunityModeratorForm,
- CommunityPersonBan,
- CommunityPersonBanForm,
- CommunitySafe,
+ source::{
+ actor_language::{CommunityLanguage, SiteLanguage},
+ community::{
+ Community,
+ CommunityFollower,
+ CommunityFollowerForm,
+ CommunityForm,
+ CommunityModerator,
+ CommunityModeratorForm,
+ CommunityPersonBan,
+ CommunityPersonBanForm,
+ CommunitySafe,
+ },
},
traits::{ApubActor, Bannable, Crud, DeleteableOrRemoveable, Followable, Joinable},
utils::{functions::lower, naive_now},
fn create(conn: &mut PgConnection, new_community: &CommunityForm) -> Result<Self, Error> {
use crate::schema::community::dsl::*;
- insert_into(community)
+ let community_ = insert_into(community)
.values(new_community)
- .get_result::<Self>(conn)
+ .get_result::<Self>(conn)?;
+
+ let site_languages = SiteLanguage::read_local(conn);
+ if let Ok(langs) = site_languages {
+ // if site exists, init user with site languages
+ CommunityLanguage::update(conn, langs, community_.id)?;
+ } else {
+ // otherwise, init with all languages (this only happens during tests)
+ CommunityLanguage::update(conn, vec![], community_.id)?;
+ }
+
+ Ok(community_)
}
fn update(