|
|
@ -5,20 +5,16 @@ use crate::{
|
|
|
|
CommentSortType,
|
|
|
|
CommentSortType,
|
|
|
|
SortType,
|
|
|
|
SortType,
|
|
|
|
};
|
|
|
|
};
|
|
|
|
use activitypub_federation::{fetch::object_id::ObjectId, traits::Object};
|
|
|
|
|
|
|
|
use anyhow::Context;
|
|
|
|
use anyhow::Context;
|
|
|
|
use chrono::{DateTime, Utc};
|
|
|
|
use chrono::{DateTime, Utc};
|
|
|
|
use deadpool::Runtime;
|
|
|
|
use deadpool::Runtime;
|
|
|
|
use diesel::{
|
|
|
|
use diesel::{
|
|
|
|
backend::Backend,
|
|
|
|
|
|
|
|
deserialize::FromSql,
|
|
|
|
|
|
|
|
helper_types::AsExprOf,
|
|
|
|
helper_types::AsExprOf,
|
|
|
|
pg::Pg,
|
|
|
|
pg::Pg,
|
|
|
|
query_builder::{Query, QueryFragment},
|
|
|
|
query_builder::{Query, QueryFragment},
|
|
|
|
query_dsl::methods::LimitDsl,
|
|
|
|
query_dsl::methods::LimitDsl,
|
|
|
|
result::{ConnectionError, ConnectionResult, Error as DieselError, Error::QueryBuilderError},
|
|
|
|
result::{ConnectionError, ConnectionResult, Error as DieselError, Error::QueryBuilderError},
|
|
|
|
serialize::{Output, ToSql},
|
|
|
|
sql_types::{self, Timestamptz},
|
|
|
|
sql_types::{self, Text, Timestamptz},
|
|
|
|
|
|
|
|
IntoSql,
|
|
|
|
IntoSql,
|
|
|
|
PgConnection,
|
|
|
|
PgConnection,
|
|
|
|
};
|
|
|
|
};
|
|
|
@ -475,32 +471,6 @@ pub mod functions {
|
|
|
|
|
|
|
|
|
|
|
|
pub const DELETED_REPLACEMENT_TEXT: &str = "*Permanently Deleted*";
|
|
|
|
pub const DELETED_REPLACEMENT_TEXT: &str = "*Permanently Deleted*";
|
|
|
|
|
|
|
|
|
|
|
|
impl ToSql<Text, Pg> for DbUrl {
|
|
|
|
|
|
|
|
fn to_sql(&self, out: &mut Output<Pg>) -> diesel::serialize::Result {
|
|
|
|
|
|
|
|
<std::string::String as ToSql<Text, Pg>>::to_sql(&self.0.to_string(), &mut out.reborrow())
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
impl<DB: Backend> FromSql<Text, DB> for DbUrl
|
|
|
|
|
|
|
|
where
|
|
|
|
|
|
|
|
String: FromSql<Text, DB>,
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
fn from_sql(value: DB::RawValue<'_>) -> diesel::deserialize::Result<Self> {
|
|
|
|
|
|
|
|
let str = String::from_sql(value)?;
|
|
|
|
|
|
|
|
Ok(DbUrl(Box::new(Url::parse(&str)?)))
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
impl<Kind> From<ObjectId<Kind>> for DbUrl
|
|
|
|
|
|
|
|
where
|
|
|
|
|
|
|
|
Kind: Object + Send + 'static,
|
|
|
|
|
|
|
|
for<'de2> <Kind as Object>::Kind: serde::Deserialize<'de2>,
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
fn from(id: ObjectId<Kind>) -> Self {
|
|
|
|
|
|
|
|
DbUrl(Box::new(id.into()))
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
pub fn now() -> AsExprOf<diesel::dsl::now, diesel::sql_types::Timestamptz> {
|
|
|
|
pub fn now() -> AsExprOf<diesel::dsl::now, diesel::sql_types::Timestamptz> {
|
|
|
|
// https://github.com/diesel-rs/diesel/issues/1514
|
|
|
|
// https://github.com/diesel-rs/diesel/issues/1514
|
|
|
|
diesel::dsl::now.into_sql::<Timestamptz>()
|
|
|
|
diesel::dsl::now.into_sql::<Timestamptz>()
|
|
|
|