utils::{check_community_ban, check_community_deleted_or_removed, get_local_user_view_from_jwt},
};
use lemmy_db_schema::{
- source::community::{Community, CommunityFollower, CommunityFollowerForm},
+ source::{
+ actor_language::CommunityLanguage,
+ community::{Community, CommunityFollower, CommunityFollowerForm},
+ },
traits::{Crud, Followable},
};
use lemmy_db_views_actor::structs::CommunityView;
let community_id = data.community_id;
let person_id = local_user_view.person.id;
let community_view = CommunityView::read(context.pool(), community_id, Some(person_id)).await?;
+ let discussion_languages = CommunityLanguage::read(context.pool(), community_id).await?;
- Ok(Self::Response { community_view })
+ Ok(Self::Response {
+ community_view,
+ discussion_languages,
+ })
}
}
pub banner: Option<String>,
pub nsfw: Option<bool>,
pub posting_restricted_to_mods: Option<bool>,
+ pub discussion_languages: Option<Vec<LanguageId>>,
pub auth: Sensitive<String>,
}
#[derive(Debug, Serialize, Deserialize, Clone)]
pub struct CommunityResponse {
pub community_view: CommunityView,
+ pub discussion_languages: Vec<LanguageId>,
}
#[derive(Debug, Serialize, Deserialize, Clone, Default)]
pub captcha_difficulty: Option<String>,
pub allowed_instances: Option<Vec<String>>,
pub blocked_instances: Option<Vec<String>>,
+ pub taglines: Option<Vec<String>>,
pub auth: Sensitive<String>,
}
pub moderates: Vec<CommunityModeratorView>,
pub community_blocks: Vec<CommunityBlockView>,
pub person_blocks: Vec<PersonBlockView>,
- pub discussion_languages: Vec<Language>,
+ pub discussion_languages: Vec<LanguageId>,
}
#[derive(Debug, Serialize, Deserialize, Clone)]
use lemmy_db_schema::{
newtypes::{CommentId, CommunityId, LocalUserId, PersonId, PostId, PrivateMessageId},
source::{
+ actor_language::CommunityLanguage,
comment::Comment,
comment_reply::{CommentReply, CommentReplyInsertForm},
person::Person,
context: &LemmyContext,
) -> Result<CommunityResponse, LemmyError> {
let community_view = CommunityView::read(context.pool(), community_id, person_id).await?;
+ let discussion_languages = CommunityLanguage::read(context.pool(), community_id).await?;
- let mut res = CommunityResponse { community_view };
+ let mut res = CommunityResponse {
+ community_view,
+ discussion_languages,
+ };
// Strip out the person id and subscribed when sending to others
res.community_view.subscribed = SubscribedType::NotSubscribed;
},
};
use lemmy_db_schema::{
- source::community::{
- Community,
- CommunityFollower,
- CommunityFollowerForm,
- CommunityInsertForm,
- CommunityModerator,
- CommunityModeratorForm,
+ source::{
+ actor_language::{CommunityLanguage, SiteLanguage},
+ community::{
+ Community,
+ CommunityFollower,
+ CommunityFollowerForm,
+ CommunityInsertForm,
+ CommunityModerator,
+ CommunityModeratorForm,
+ },
},
traits::{ApubActor, Crud, Followable, Joinable},
utils::diesel_option_overwrite_to_url_create,
.await
.map_err(|e| LemmyError::from_error_message(e, "community_follower_already_exists"))?;
+ // Update the discussion_languages if that's provided
+ let community_id = inserted_community.id;
+ if let Some(languages) = data.discussion_languages.clone() {
+ let site_languages = SiteLanguage::read_local(context.pool()).await?;
+ // check that community languages are a subset of site languages
+ // https://stackoverflow.com/a/64227550
+ let is_subset = languages.iter().all(|item| site_languages.contains(item));
+ if !is_subset {
+ return Err(LemmyError::from_message("language_not_allowed"));
+ }
+ CommunityLanguage::update(context.pool(), languages, community_id).await?;
+ }
+
let person_id = local_user_view.person.id;
let community_view =
CommunityView::read(context.pool(), inserted_community.id, Some(person_id)).await?;
+ let discussion_languages =
+ CommunityLanguage::read(context.pool(), inserted_community.id).await?;
- Ok(CommunityResponse { community_view })
+ Ok(CommunityResponse {
+ community_view,
+ discussion_languages,
+ })
}
}
site::{GetSite, GetSiteResponse, MyUserInfo},
utils::{build_federated_instances, get_local_user_settings_view_from_jwt_opt},
};
-use lemmy_db_schema::source::{actor_language::SiteLanguage, language::Language, tagline::Tagline};
-use lemmy_db_views::structs::{LocalUserDiscussionLanguageView, SiteView};
+use lemmy_db_schema::source::{
+ actor_language::{LocalUserLanguage, SiteLanguage},
+ language::Language,
+ tagline::Tagline,
+};
+use lemmy_db_views::structs::SiteView;
use lemmy_db_views_actor::structs::{
CommunityBlockView,
CommunityFollowerView,
.await
.map_err(|e| LemmyError::from_error_message(e, "system_err_login"))?;
- let discussion_languages =
- LocalUserDiscussionLanguageView::read_languages(context.pool(), local_user_id)
- .await
- .map_err(|e| LemmyError::from_error_message(e, "system_err_login"))?;
+ let discussion_languages = LocalUserLanguage::read(context.pool(), local_user_id)
+ .await
+ .map_err(|e| LemmyError::from_error_message(e, "system_err_login"))?;
Some(MyUserInfo {
local_user_view,
context::LemmyContext,
websocket::UserOperation,
};
-use lemmy_db_schema::{source::community::CommunityFollower, traits::Followable};
+use lemmy_db_schema::{
+ source::{actor_language::CommunityLanguage, community::CommunityFollower},
+ traits::Followable,
+};
use lemmy_db_views::structs::LocalUserView;
use lemmy_db_views_actor::structs::CommunityView;
use lemmy_utils::error::LemmyError;
.await?
.local_user
.id;
+ let discussion_languages = CommunityLanguage::read(context.pool(), community_id).await?;
- let response = CommunityResponse { community_view };
+ let response = CommunityResponse {
+ community_view,
+ discussion_languages,
+ };
context
.chat_server()
#[cfg(feature = "full")]
pub mod comment_view;
#[cfg(feature = "full")]
-pub mod local_user_discussion_language_view;
-#[cfg(feature = "full")]
pub mod local_user_view;
#[cfg(feature = "full")]
pub mod post_report_view;
#[cfg(feature = "full")]
pub mod post_view;
#[cfg(feature = "full")]
-#[cfg(feature = "full")]
pub mod private_message_report_view;
#[cfg(feature = "full")]
pub mod private_message_view;
+++ /dev/null
-use crate::structs::LocalUserDiscussionLanguageView;
-use diesel::{result::Error, ExpressionMethods, QueryDsl};
-use diesel_async::RunQueryDsl;
-use lemmy_db_schema::{
- newtypes::LocalUserId,
- schema::{language, local_user, local_user_language},
- source::{
- language::Language,
- local_user::{LocalUser, LocalUserSettings},
- },
- traits::ToSafeSettings,
- utils::{get_conn, DbPool},
-};
-
-type LocalUserDiscussionLanguageViewTuple = (LocalUserSettings, Language);
-
-impl LocalUserDiscussionLanguageView {
- pub async fn read_languages(
- pool: &DbPool,
- local_user_id: LocalUserId,
- ) -> Result<Vec<Language>, Error> {
- let conn = &mut get_conn(pool).await?;
-
- let res = local_user_language::table
- .inner_join(local_user::table)
- .inner_join(language::table)
- .select((
- LocalUser::safe_settings_columns_tuple(),
- language::all_columns,
- ))
- .filter(local_user::id.eq(local_user_id))
- .load::<LocalUserDiscussionLanguageViewTuple>(conn)
- .await?;
-
- Ok(res.into_iter().map(|a| a.1).collect::<Vec<Language>>())
- }
-}
comment::Comment,
comment_report::CommentReport,
community::CommunitySafe,
- language::Language,
local_site::LocalSite,
local_site_rate_limit::LocalSiteRateLimit,
local_user::{LocalUser, LocalUserSettings},
pub local_site_rate_limit: LocalSiteRateLimit,
pub counts: SiteAggregates,
}
-
-#[derive(Debug, Serialize, Deserialize, Clone)]
-pub struct LocalUserDiscussionLanguageView {
- pub local_user: LocalUserSettings,
- pub language: Language,
-}
ports:
# actual and only port facing any connection from outside
- "1236:1236"
+ - "8536:8536"
volumes:
- ./nginx.conf:/etc/nginx/nginx.conf:ro
restart: always
- pictrs
lemmy-ui:
- # image: dessalines/lemmy-ui:dev
+ image: dessalines/lemmy-ui:dev
# use this to build your local lemmy ui image for development
# run docker compose up --build
# assuming lemmy-ui is cloned besides lemmy directory
- build:
- context: ../../../lemmy-ui
- dockerfile: dev.dockerfile
+ # build:
+ # context: ../../../lemmy-ui
+ # dockerfile: dev.dockerfile
networks:
- lemmyinternal
environment:
server {
# this is the port inside docker, not the public one yet
listen 1236;
+ listen 8536;
# change if needed, this is facing the public web
server_name localhost;
server_tokens off;