mirror of
https://github.com/LemmyNet/lemmy.git
synced 2024-11-10 11:09:46 +00:00
* Fixing issue with saving site language. Fixes #2748 * Add a warning to Site::read
This commit is contained in:
parent
a42f7271e6
commit
cd5c79527a
2 changed files with 7 additions and 7 deletions
|
@ -44,7 +44,9 @@ impl PerformCrud for EditSite {
|
||||||
let data: &EditSite = self;
|
let data: &EditSite = self;
|
||||||
let local_user_view =
|
let local_user_view =
|
||||||
get_local_user_view_from_jwt(&data.auth, context.pool(), context.secret()).await?;
|
get_local_user_view_from_jwt(&data.auth, context.pool(), context.secret()).await?;
|
||||||
let local_site = LocalSite::read(context.pool()).await?;
|
let site_view = SiteView::read_local(context.pool()).await?;
|
||||||
|
let local_site = site_view.local_site;
|
||||||
|
let site = site_view.site;
|
||||||
|
|
||||||
// Make sure user is an admin
|
// Make sure user is an admin
|
||||||
is_admin(&local_user_view)?;
|
is_admin(&local_user_view)?;
|
||||||
|
@ -76,9 +78,7 @@ impl PerformCrud for EditSite {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let site_id = local_site.site_id;
|
|
||||||
if let Some(discussion_languages) = data.discussion_languages.clone() {
|
if let Some(discussion_languages) = data.discussion_languages.clone() {
|
||||||
let site = Site::read(context.pool(), site_id).await?;
|
|
||||||
SiteLanguage::update(context.pool(), discussion_languages.clone(), &site).await?;
|
SiteLanguage::update(context.pool(), discussion_languages.clone(), &site).await?;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -92,7 +92,7 @@ impl PerformCrud for EditSite {
|
||||||
.updated(Some(Some(naive_now())))
|
.updated(Some(Some(naive_now())))
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
Site::update(context.pool(), site_id, &site_form)
|
Site::update(context.pool(), site.id, &site_form)
|
||||||
.await
|
.await
|
||||||
// Ignore errors for all these, so as to not throw errors if no update occurs
|
// Ignore errors for all these, so as to not throw errors if no update occurs
|
||||||
// Diesel will throw an error for empty update forms
|
// Diesel will throw an error for empty update forms
|
||||||
|
|
|
@ -18,9 +18,9 @@ impl Crud for Site {
|
||||||
type UpdateForm = SiteUpdateForm;
|
type UpdateForm = SiteUpdateForm;
|
||||||
type IdType = SiteId;
|
type IdType = SiteId;
|
||||||
|
|
||||||
async fn read(pool: &DbPool, _site_id: SiteId) -> Result<Self, Error> {
|
/// Use SiteView::read_local, or Site::read_from_apub_id instead
|
||||||
let conn = &mut get_conn(pool).await?;
|
async fn read(_pool: &DbPool, _site_id: SiteId) -> Result<Self, Error> {
|
||||||
site.first::<Self>(conn).await
|
unimplemented!()
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn create(pool: &DbPool, form: &Self::InsertForm) -> Result<Self, Error> {
|
async fn create(pool: &DbPool, form: &Self::InsertForm) -> Result<Self, Error> {
|
||||||
|
|
Loading…
Reference in a new issue