mirror of
https://github.com/LemmyNet/lemmy.git
synced 2024-07-05 21:46:08 +00:00
Adding back in transaction.
This commit is contained in:
parent
763424d61e
commit
d784c17af5
|
@ -40,7 +40,7 @@ fn local_instance(context: &LemmyContext) -> &'static LocalInstance {
|
||||||
.debug(context.settings().federation.debug)
|
.debug(context.settings().federation.debug)
|
||||||
// TODO No idea why, but you can't pass context.settings() to the verify_url_function closure
|
// TODO No idea why, but you can't pass context.settings() to the verify_url_function closure
|
||||||
// without the value getting captured.
|
// without the value getting captured.
|
||||||
.verify_url_function(|url| check_apub_id_valid(url, &SETTINGS.to_owned()))
|
.verify_url_function(|url| check_apub_id_valid(url, &SETTINGS))
|
||||||
.build()
|
.build()
|
||||||
.expect("configure federation");
|
.expect("configure federation");
|
||||||
LocalInstance::new(
|
LocalInstance::new(
|
||||||
|
|
|
@ -15,9 +15,6 @@ impl LocalUserLanguage {
|
||||||
) -> Result<(), Error> {
|
) -> Result<(), Error> {
|
||||||
use crate::schema::local_user_language::dsl::*;
|
use crate::schema::local_user_language::dsl::*;
|
||||||
|
|
||||||
// Clear the current user languages
|
|
||||||
delete(local_user_language.filter(local_user_id.eq(for_local_user_id))).execute(conn)?;
|
|
||||||
|
|
||||||
// If no language is given, read all languages
|
// If no language is given, read all languages
|
||||||
let lang_ids = language_ids.unwrap_or(
|
let lang_ids = language_ids.unwrap_or(
|
||||||
Language::read_all(conn)?
|
Language::read_all(conn)?
|
||||||
|
@ -26,6 +23,10 @@ impl LocalUserLanguage {
|
||||||
.collect(),
|
.collect(),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
conn.build_transaction().read_write().run(|| {
|
||||||
|
// Clear the current user languages
|
||||||
|
delete(local_user_language.filter(local_user_id.eq(for_local_user_id))).execute(conn)?;
|
||||||
|
|
||||||
for l in lang_ids {
|
for l in lang_ids {
|
||||||
let form = LocalUserLanguageForm {
|
let form = LocalUserLanguageForm {
|
||||||
local_user_id: for_local_user_id,
|
local_user_id: for_local_user_id,
|
||||||
|
@ -36,5 +37,6 @@ impl LocalUserLanguage {
|
||||||
.get_result::<Self>(conn)?;
|
.get_result::<Self>(conn)?;
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue