mirror of
https://github.com/LemmyNet/lemmy.git
synced 2024-06-09 00:49:21 +00:00
235cc8b228
* Moving settings to Database. - Moves many settings into the database. Fixes #2285 - Adds a local_site and instance table. Fixes #2365 . Fixes #2368 - Separates SQL update an insert forms, to avoid runtime errors. - Adds TypedBuilder to all the SQL forms, instead of default. * Fix weird clippy issue. * Removing extra lines. * Some fixes from suggestions. * Fixing apub tests. * Using instance creation helper function. * Move forms to their own line. * Trying to fix local_site_data, still broken. * Fixing federation tests. * Trying to fix check features 1. * Addressing PR comments. * Adding check_apub to all verify functions.
35 lines
1,022 B
Rust
35 lines
1,022 B
Rust
use crate::{newtypes::LocalUserId, source::email_verification::*};
|
|
use diesel::{
|
|
dsl::*,
|
|
insert_into,
|
|
result::Error,
|
|
ExpressionMethods,
|
|
PgConnection,
|
|
QueryDsl,
|
|
RunQueryDsl,
|
|
};
|
|
|
|
impl EmailVerification {
|
|
pub fn create(conn: &mut PgConnection, form: &EmailVerificationForm) -> Result<Self, Error> {
|
|
use crate::schema::email_verification::dsl::*;
|
|
insert_into(email_verification)
|
|
.values(form)
|
|
.get_result::<Self>(conn)
|
|
}
|
|
|
|
pub fn read_for_token(conn: &mut PgConnection, token: &str) -> Result<Self, Error> {
|
|
use crate::schema::email_verification::dsl::*;
|
|
email_verification
|
|
.filter(verification_token.eq(token))
|
|
.filter(published.gt(now - 7.days()))
|
|
.first::<Self>(conn)
|
|
}
|
|
pub fn delete_old_tokens_for_local_user(
|
|
conn: &mut PgConnection,
|
|
local_user_id_: LocalUserId,
|
|
) -> Result<usize, Error> {
|
|
use crate::schema::email_verification::dsl::*;
|
|
diesel::delete(email_verification.filter(local_user_id.eq(local_user_id_))).execute(conn)
|
|
}
|
|
}
|