type InsertForm = PrivateMessageInsertForm;
type UpdateForm = PrivateMessageUpdateForm;
type IdType = PrivateMessageId;
- async fn read(pool: &DbPool, private_message_id: PrivateMessageId) -> Result<Self, Error> {
+ async fn read(
+ pool: &mut DbPool<'_>,
+ private_message_id: PrivateMessageId,
+ ) -> Result<Self, Error> {
let conn = &mut get_conn(pool).await?;
private_message
.find(private_message_id)
.await
}
- async fn create(pool: &DbPool, form: &Self::InsertForm) -> Result<Self, Error> {
+ async fn create(pool: &mut DbPool<'_>, form: &Self::InsertForm) -> Result<Self, Error> {
let conn = &mut get_conn(pool).await?;
insert_into(private_message)
.values(form)
}
async fn update(
- pool: &DbPool,
+ pool: &mut DbPool<'_>,
private_message_id: PrivateMessageId,
form: &Self::UpdateForm,
) -> Result<Self, Error> {
.get_result::<Self>(conn)
.await
}
- async fn delete(pool: &DbPool, pm_id: Self::IdType) -> Result<usize, Error> {
+ async fn delete(pool: &mut DbPool<'_>, pm_id: Self::IdType) -> Result<usize, Error> {
let conn = &mut get_conn(pool).await?;
diesel::delete(private_message.find(pm_id))
.execute(conn)
impl PrivateMessage {
pub async fn mark_all_as_read(
- pool: &DbPool,
+ pool: &mut DbPool<'_>,
for_recipient_id: PersonId,
) -> Result<Vec<PrivateMessage>, Error> {
let conn = &mut get_conn(pool).await?;
}
pub async fn read_from_apub_id(
- pool: &DbPool,
+ pool: &mut DbPool<'_>,
object_id: Url,
) -> Result<Option<Self>, LemmyError> {
let conn = &mut get_conn(pool).await?;
#[cfg(test)]
mod tests {
+ #![allow(clippy::unwrap_used)]
+ #![allow(clippy::indexing_slicing)]
+
use crate::{
source::{
instance::Instance,
#[serial]
async fn test_crud() {
let pool = &build_db_pool_for_tests().await;
+ let pool = &mut pool.into();
let inserted_instance = Instance::read_or_create(pool, "my_domain.tld".to_string())
.await