mirror of
https://github.com/LemmyNet/lemmy
synced 2024-11-10 06:54:12 +00:00
Fix time zone handling (#3496)
* convert naive time to utc time * compounding fixes * cargo fmt * fix the rest * fix down migration * fix migrations * fix after merge * clippy fix * ap-fed 0.5.0 --------- Co-authored-by: Nutomic <me@nutomic.com>
This commit is contained in:
parent
6047257bfc
commit
514f2222e0
82 changed files with 1094 additions and 352 deletions
4
Cargo.lock
generated
4
Cargo.lock
generated
|
@ -10,9 +10,9 @@ checksum = "fe438c63458706e03479442743baae6c88256498e6431708f6dfc520a26515d3"
|
|||
|
||||
[[package]]
|
||||
name = "activitypub_federation"
|
||||
version = "0.4.6"
|
||||
version = "0.5.0-beta.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4e6e7fefba6602240fcf612931b70640ad1e249dff833551ebc218f1c96a4193"
|
||||
checksum = "fb4c5f0e97215be7fb8bdd632283f66d78168f388029d678ab4854ff599f0238"
|
||||
dependencies = [
|
||||
"activitystreams-kinds",
|
||||
"actix-web",
|
||||
|
|
|
@ -67,7 +67,7 @@ lemmy_routes = { version = "=0.18.1", path = "./crates/routes" }
|
|||
lemmy_db_views = { version = "=0.18.1", path = "./crates/db_views" }
|
||||
lemmy_db_views_actor = { version = "=0.18.1", path = "./crates/db_views_actor" }
|
||||
lemmy_db_views_moderator = { version = "=0.18.1", path = "./crates/db_views_moderator" }
|
||||
activitypub_federation = { version = "0.4.6", default-features = false, features = [
|
||||
activitypub_federation = { version = "0.5.0-beta.1", default-features = false, features = [
|
||||
"actix-web",
|
||||
] }
|
||||
diesel = "2.1.0"
|
||||
|
|
|
@ -5,7 +5,7 @@ use crate::{
|
|||
site::FederatedInstances,
|
||||
};
|
||||
use anyhow::Context;
|
||||
use chrono::NaiveDateTime;
|
||||
use chrono::{DateTime, Utc};
|
||||
use lemmy_db_schema::{
|
||||
impls::person::is_banned,
|
||||
newtypes::{CommunityId, DbUrl, LocalUserId, PersonId, PostId},
|
||||
|
@ -163,7 +163,7 @@ pub async fn local_user_view_from_jwt_opt(
|
|||
|
||||
/// Checks if user's token was issued before user's password reset.
|
||||
pub fn check_validator_time(
|
||||
validator_time: &NaiveDateTime,
|
||||
validator_time: &DateTime<Utc>,
|
||||
claims: &Claims,
|
||||
) -> Result<(), LemmyError> {
|
||||
let user_validation_time = validator_time.timestamp();
|
||||
|
@ -176,7 +176,7 @@ pub fn check_validator_time(
|
|||
|
||||
pub fn check_user_valid(
|
||||
banned: bool,
|
||||
ban_expires: Option<NaiveDateTime>,
|
||||
ban_expires: Option<DateTime<Utc>>,
|
||||
deleted: bool,
|
||||
) -> Result<(), LemmyError> {
|
||||
// Check for a site ban
|
||||
|
|
|
@ -8,6 +8,6 @@
|
|||
"type": "Block",
|
||||
"removeData": true,
|
||||
"summary": "spam post",
|
||||
"expires": "2021-11-01T12:23:50.151874+00:00",
|
||||
"expires": "2021-11-01T12:23:50.151874Z",
|
||||
"id": "http://enterprise.lemmy.ml/activities/block/5d42fffb-0903-4625-86d4-0b39bb344fc2"
|
||||
}
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
"type": "Block",
|
||||
"removeData": true,
|
||||
"summary": "spam post",
|
||||
"expires": "2021-11-01T12:23:50.151874+00:00",
|
||||
"expires": "2021-11-01T12:23:50.151874Z",
|
||||
"id": "http://enterprise.lemmy.ml/activities/block/726f43ab-bd0e-4ab3-89c8-627e976f553c"
|
||||
},
|
||||
"cc": ["http://enterprise.lemmy.ml/c/main"],
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
"commentsEnabled": true,
|
||||
"sensitive": false,
|
||||
"stickied": false,
|
||||
"published": "2021-11-01T12:11:22.871846+00:00"
|
||||
"published": "2021-11-01T12:11:22.871846Z"
|
||||
},
|
||||
"cc": ["http://enterprise.lemmy.ml/c/main"],
|
||||
"type": "Create",
|
||||
|
|
|
@ -35,8 +35,8 @@
|
|||
"name": "Deutsch"
|
||||
}
|
||||
],
|
||||
"published": "2021-10-29T15:05:51.476984+00:00",
|
||||
"updated": "2021-11-01T12:23:50.151874+00:00"
|
||||
"published": "2021-10-29T15:05:51.476984Z",
|
||||
"updated": "2021-11-01T12:23:50.151874Z"
|
||||
},
|
||||
"cc": ["http://enterprise.lemmy.ml/c/main"],
|
||||
"audience": "http://enterprise.lemmy.ml/u/main",
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
"mediaType": "text/markdown"
|
||||
},
|
||||
"inReplyTo": "http://ds9.lemmy.ml/post/1",
|
||||
"published": "2021-11-01T11:45:49.794920+00:00"
|
||||
"published": "2021-11-01T11:45:49.794920Z"
|
||||
},
|
||||
"cc": [
|
||||
"http://enterprise.lemmy.ml/c/main",
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
"identifier": "ko",
|
||||
"name": "한국어"
|
||||
},
|
||||
"published": "2021-10-29T15:10:51.557399+00:00"
|
||||
"published": "2021-10-29T15:10:51.557399Z"
|
||||
},
|
||||
"cc": ["http://enterprise.lemmy.ml/c/main"],
|
||||
"audience": "https://enterprise.lemmy.ml/c/main",
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
"content": "hello",
|
||||
"mediaType": "text/markdown"
|
||||
},
|
||||
"published": "2021-10-29T15:31:56.058289+00:00"
|
||||
"published": "2021-10-29T15:31:56.058289Z"
|
||||
},
|
||||
"type": "Create"
|
||||
}
|
||||
|
|
|
@ -25,8 +25,8 @@
|
|||
],
|
||||
"commentsEnabled": true,
|
||||
"sensitive": false,
|
||||
"published": "2021-10-29T15:10:51.557399+00:00",
|
||||
"updated": "2021-10-29T15:11:35.976374+00:00"
|
||||
"published": "2021-10-29T15:10:51.557399Z",
|
||||
"updated": "2021-10-29T15:11:35.976374Z"
|
||||
},
|
||||
"cc": ["http://enterprise.lemmy.ml/c/main"],
|
||||
"audience": "https://enterprise.lemmy.ml/c/main",
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
"attachment": [],
|
||||
"commentsEnabled": true,
|
||||
"sensitive": false,
|
||||
"published": "2023-02-06T06:42:41.939437+00:00",
|
||||
"published": "2023-02-06T06:42:41.939437Z",
|
||||
"language": {
|
||||
"identifier": "de",
|
||||
"name": "Deutsch"
|
||||
|
@ -38,7 +38,7 @@
|
|||
"attachment": [],
|
||||
"commentsEnabled": true,
|
||||
"sensitive": false,
|
||||
"published": "2023-02-06T06:42:37.119567+00:00",
|
||||
"published": "2023-02-06T06:42:37.119567Z",
|
||||
"language": {
|
||||
"identifier": "de",
|
||||
"name": "Deutsch"
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
"commentsEnabled": true,
|
||||
"sensitive": false,
|
||||
"stickied": false,
|
||||
"published": "2021-11-18T17:19:45.895163+00:00"
|
||||
"published": "2021-11-18T17:19:45.895163Z"
|
||||
}
|
||||
},
|
||||
"cc": ["https://ds9.lemmy.ml/c/testcom/followers"],
|
||||
|
@ -54,7 +54,7 @@
|
|||
"commentsEnabled": true,
|
||||
"sensitive": false,
|
||||
"stickied": false,
|
||||
"published": "2021-11-18T17:19:05.763109+00:00"
|
||||
"published": "2021-11-18T17:19:05.763109Z"
|
||||
}
|
||||
},
|
||||
"cc": ["https://ds9.lemmy.ml/c/testcom/followers"],
|
||||
|
|
|
@ -9,5 +9,5 @@
|
|||
"content": "Hello hello, testing",
|
||||
"mediaType": "text/markdown"
|
||||
},
|
||||
"published": "2021-10-21T10:13:14.597721+00:00"
|
||||
"published": "2021-10-21T10:13:14.597721Z"
|
||||
}
|
||||
|
|
|
@ -41,6 +41,6 @@
|
|||
"name": "Deutsch"
|
||||
}
|
||||
],
|
||||
"published": "2019-06-02T16:43:50.799554+00:00",
|
||||
"updated": "2021-03-10T17:18:10.498868+00:00"
|
||||
"published": "2019-06-02T16:43:50.799554Z",
|
||||
"updated": "2021-03-10T17:18:10.498868Z"
|
||||
}
|
||||
|
|
|
@ -26,5 +26,5 @@
|
|||
"name": "Español"
|
||||
}
|
||||
],
|
||||
"published": "2022-01-19T21:52:11.110741+00:00"
|
||||
"published": "2022-01-19T21:52:11.110741Z"
|
||||
}
|
||||
|
|
|
@ -27,6 +27,6 @@
|
|||
"identifier": "fr",
|
||||
"name": "Français"
|
||||
},
|
||||
"published": "2021-03-01T13:42:43.966208+00:00",
|
||||
"updated": "2021-03-01T13:43:03.955787+00:00"
|
||||
"published": "2021-03-01T13:42:43.966208Z",
|
||||
"updated": "2021-03-01T13:43:03.955787Z"
|
||||
}
|
||||
|
|
|
@ -30,5 +30,5 @@
|
|||
"identifier": "fr",
|
||||
"name": "Français"
|
||||
},
|
||||
"published": "2021-02-26T12:35:34.292626+00:00"
|
||||
"published": "2021-02-26T12:35:34.292626Z"
|
||||
}
|
||||
|
|
|
@ -22,8 +22,8 @@
|
|||
"endpoints": {
|
||||
"sharedInbox": "https://enterprise.lemmy.ml/inbox"
|
||||
},
|
||||
"published": "2020-01-17T01:38:22.348392+00:00",
|
||||
"updated": "2021-08-13T00:11:15.941990+00:00",
|
||||
"published": "2020-01-17T01:38:22.348392Z",
|
||||
"updated": "2021-08-13T00:11:15.941990Z",
|
||||
"publicKey": {
|
||||
"id": "https://enterprise.lemmy.ml/u/picard#main-key",
|
||||
"owner": "https://enterprise.lemmy.ml/u/picard",
|
||||
|
|
|
@ -20,7 +20,7 @@ use activitypub_federation::{
|
|||
traits::{ActivityHandler, Actor},
|
||||
};
|
||||
use anyhow::anyhow;
|
||||
use chrono::NaiveDateTime;
|
||||
use chrono::{DateTime, Utc};
|
||||
use lemmy_api_common::{
|
||||
context::LemmyContext,
|
||||
utils::{remove_user_data, remove_user_data_in_community, sanitize_html_opt},
|
||||
|
@ -38,7 +38,7 @@ use lemmy_db_schema::{
|
|||
},
|
||||
traits::{Bannable, Crud, Followable},
|
||||
};
|
||||
use lemmy_utils::{error::LemmyError, utils::time::convert_datetime};
|
||||
use lemmy_utils::error::LemmyError;
|
||||
use url::Url;
|
||||
|
||||
impl BlockUser {
|
||||
|
@ -48,7 +48,7 @@ impl BlockUser {
|
|||
mod_: &ApubPerson,
|
||||
remove_data: Option<bool>,
|
||||
reason: Option<String>,
|
||||
expires: Option<NaiveDateTime>,
|
||||
expires: Option<DateTime<Utc>>,
|
||||
context: &Data<LemmyContext>,
|
||||
) -> Result<BlockUser, LemmyError> {
|
||||
let audience = if let SiteOrCommunity::Community(c) = target {
|
||||
|
@ -70,7 +70,7 @@ impl BlockUser {
|
|||
&context.settings().get_protocol_and_hostname(),
|
||||
)?,
|
||||
audience,
|
||||
expires: expires.map(convert_datetime),
|
||||
expires,
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -81,7 +81,7 @@ impl BlockUser {
|
|||
mod_: &ApubPerson,
|
||||
remove_data: bool,
|
||||
reason: Option<String>,
|
||||
expires: Option<NaiveDateTime>,
|
||||
expires: Option<DateTime<Utc>>,
|
||||
context: &Data<LemmyContext>,
|
||||
) -> Result<(), LemmyError> {
|
||||
let block = BlockUser::new(
|
||||
|
@ -148,7 +148,7 @@ impl ActivityHandler for BlockUser {
|
|||
|
||||
#[tracing::instrument(skip_all)]
|
||||
async fn receive(self, context: &Data<LemmyContext>) -> Result<(), LemmyError> {
|
||||
let expires = self.expires.map(|u| u.naive_local());
|
||||
let expires = self.expires.map(Into::into);
|
||||
let mod_person = self.actor.dereference(context).await?;
|
||||
let blocked_person = self.object.dereference(context).await?;
|
||||
let target = self.target.dereference(context).await?;
|
||||
|
|
|
@ -10,7 +10,7 @@ use activitypub_federation::{
|
|||
fetch::object_id::ObjectId,
|
||||
traits::{Actor, Object},
|
||||
};
|
||||
use chrono::NaiveDateTime;
|
||||
use chrono::{DateTime, Utc};
|
||||
use lemmy_api_common::{community::BanFromCommunity, context::LemmyContext, person::BanPerson};
|
||||
use lemmy_db_schema::{
|
||||
newtypes::CommunityId,
|
||||
|
@ -49,7 +49,7 @@ impl Object for SiteOrCommunity {
|
|||
type Error = LemmyError;
|
||||
|
||||
#[tracing::instrument(skip_all)]
|
||||
fn last_refreshed_at(&self) -> Option<NaiveDateTime> {
|
||||
fn last_refreshed_at(&self) -> Option<DateTime<Utc>> {
|
||||
Some(match self {
|
||||
SiteOrCommunity::Site(i) => i.last_refreshed_at,
|
||||
SiteOrCommunity::Community(c) => c.last_refreshed_at,
|
||||
|
|
|
@ -97,7 +97,7 @@ impl ActivityHandler for UndoBlockUser {
|
|||
|
||||
#[tracing::instrument(skip_all)]
|
||||
async fn receive(self, context: &Data<LemmyContext>) -> Result<(), LemmyError> {
|
||||
let expires = self.object.expires.map(|u| u.naive_local());
|
||||
let expires = self.object.expires.map(Into::into);
|
||||
let mod_person = self.actor.dereference(context).await?;
|
||||
let blocked_person = self.object.object.dereference(context).await?;
|
||||
match self.object.target.dereference(context).await? {
|
||||
|
|
|
@ -6,7 +6,7 @@ use crate::{
|
|||
},
|
||||
};
|
||||
use activitypub_federation::{config::Data, traits::Object};
|
||||
use chrono::NaiveDateTime;
|
||||
use chrono::{DateTime, Utc};
|
||||
use lemmy_api_common::context::LemmyContext;
|
||||
use lemmy_db_schema::{
|
||||
source::{community::Community, post::Post},
|
||||
|
@ -35,7 +35,7 @@ impl Object for PostOrComment {
|
|||
type Kind = PageOrNote;
|
||||
type Error = LemmyError;
|
||||
|
||||
fn last_refreshed_at(&self) -> Option<NaiveDateTime> {
|
||||
fn last_refreshed_at(&self) -> Option<DateTime<Utc>> {
|
||||
None
|
||||
}
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@ use activitypub_federation::{
|
|||
fetch::{object_id::ObjectId, webfinger::webfinger_resolve_actor},
|
||||
traits::Object,
|
||||
};
|
||||
use chrono::NaiveDateTime;
|
||||
use chrono::{DateTime, Utc};
|
||||
use lemmy_api_common::context::LemmyContext;
|
||||
use lemmy_utils::error::{LemmyError, LemmyErrorType};
|
||||
use serde::Deserialize;
|
||||
|
@ -80,7 +80,7 @@ impl Object for SearchableObjects {
|
|||
type Kind = SearchableKinds;
|
||||
type Error = LemmyError;
|
||||
|
||||
fn last_refreshed_at(&self) -> Option<NaiveDateTime> {
|
||||
fn last_refreshed_at(&self) -> Option<DateTime<Utc>> {
|
||||
match self {
|
||||
SearchableObjects::Person(p) => p.last_refreshed_at(),
|
||||
SearchableObjects::Community(c) => c.last_refreshed_at(),
|
||||
|
|
|
@ -6,7 +6,7 @@ use activitypub_federation::{
|
|||
config::Data,
|
||||
traits::{Actor, Object},
|
||||
};
|
||||
use chrono::NaiveDateTime;
|
||||
use chrono::{DateTime, Utc};
|
||||
use lemmy_api_common::context::LemmyContext;
|
||||
use lemmy_utils::error::LemmyError;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
@ -37,7 +37,7 @@ impl Object for UserOrCommunity {
|
|||
type Kind = PersonOrGroup;
|
||||
type Error = LemmyError;
|
||||
|
||||
fn last_refreshed_at(&self) -> Option<NaiveDateTime> {
|
||||
fn last_refreshed_at(&self) -> Option<DateTime<Utc>> {
|
||||
Some(match self {
|
||||
UserOrCommunity::User(p) => p.last_refreshed_at,
|
||||
UserOrCommunity::Community(p) => p.last_refreshed_at,
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
use crate::fetcher::post_or_comment::PostOrComment;
|
||||
use activitypub_federation::config::{Data, UrlVerifier};
|
||||
use anyhow::anyhow;
|
||||
use async_trait::async_trait;
|
||||
use lemmy_api_common::context::LemmyContext;
|
||||
use lemmy_db_schema::{
|
||||
|
@ -38,7 +39,7 @@ pub struct VerifyUrlData(pub ActualDbPool);
|
|||
|
||||
#[async_trait]
|
||||
impl UrlVerifier for VerifyUrlData {
|
||||
async fn verify(&self, url: &Url) -> Result<(), &'static str> {
|
||||
async fn verify(&self, url: &Url) -> Result<(), anyhow::Error> {
|
||||
let local_site_data = local_site_data_cached(&mut (&self.0).into())
|
||||
.await
|
||||
.expect("read local site data");
|
||||
|
@ -46,16 +47,16 @@ impl UrlVerifier for VerifyUrlData {
|
|||
LemmyError {
|
||||
error_type: LemmyErrorType::FederationDisabled,
|
||||
..
|
||||
} => "Federation disabled",
|
||||
} => anyhow!("Federation disabled"),
|
||||
LemmyError {
|
||||
error_type: LemmyErrorType::DomainBlocked(_),
|
||||
..
|
||||
} => "Domain is blocked",
|
||||
} => anyhow!("Domain is blocked"),
|
||||
LemmyError {
|
||||
error_type: LemmyErrorType::DomainNotInAllowList(_),
|
||||
..
|
||||
} => "Domain is not in allowlist",
|
||||
_ => "Failed validating apub id",
|
||||
} => anyhow!("Domain is not in allowlist"),
|
||||
_ => anyhow!("Failed validating apub id"),
|
||||
})?;
|
||||
Ok(())
|
||||
}
|
||||
|
|
|
@ -15,7 +15,7 @@ use activitypub_federation::{
|
|||
protocol::{values::MediaTypeMarkdownOrHtml, verification::verify_domains_match},
|
||||
traits::Object,
|
||||
};
|
||||
use chrono::NaiveDateTime;
|
||||
use chrono::{DateTime, Utc};
|
||||
use lemmy_api_common::{
|
||||
context::LemmyContext,
|
||||
utils::{local_site_opt_to_slur_regex, sanitize_html},
|
||||
|
@ -59,7 +59,7 @@ impl Object for ApubComment {
|
|||
type Kind = Note;
|
||||
type Error = LemmyError;
|
||||
|
||||
fn last_refreshed_at(&self) -> Option<NaiveDateTime> {
|
||||
fn last_refreshed_at(&self) -> Option<DateTime<Utc>> {
|
||||
None
|
||||
}
|
||||
|
||||
|
@ -170,8 +170,8 @@ impl Object for ApubComment {
|
|||
post_id: post.id,
|
||||
content,
|
||||
removed: None,
|
||||
published: note.published.map(|u| u.naive_local()),
|
||||
updated: note.updated.map(|u| u.naive_local()),
|
||||
published: note.published.map(Into::into),
|
||||
updated: note.updated.map(Into::into),
|
||||
deleted: Some(false),
|
||||
ap_id: Some(note.id.into()),
|
||||
distinguished: note.distinguished,
|
||||
|
|
|
@ -13,7 +13,7 @@ use activitypub_federation::{
|
|||
kinds::actor::GroupType,
|
||||
traits::{Actor, Object},
|
||||
};
|
||||
use chrono::NaiveDateTime;
|
||||
use chrono::{DateTime, Utc};
|
||||
use lemmy_api_common::{
|
||||
context::LemmyContext,
|
||||
utils::{generate_featured_url, generate_moderators_url, generate_outbox_url},
|
||||
|
@ -56,7 +56,7 @@ impl Object for ApubCommunity {
|
|||
type Kind = Group;
|
||||
type Error = LemmyError;
|
||||
|
||||
fn last_refreshed_at(&self) -> Option<NaiveDateTime> {
|
||||
fn last_refreshed_at(&self) -> Option<DateTime<Utc>> {
|
||||
Some(self.last_refreshed_at)
|
||||
}
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@ use activitypub_federation::{
|
|||
protocol::{values::MediaTypeHtml, verification::verify_domains_match},
|
||||
traits::{Actor, Object},
|
||||
};
|
||||
use chrono::NaiveDateTime;
|
||||
use chrono::{DateTime, Utc};
|
||||
use lemmy_api_common::{
|
||||
context::LemmyContext,
|
||||
utils::{local_site_opt_to_slur_regex, sanitize_html_opt},
|
||||
|
@ -64,7 +64,7 @@ impl Object for ApubSite {
|
|||
type Kind = Instance;
|
||||
type Error = LemmyError;
|
||||
|
||||
fn last_refreshed_at(&self) -> Option<NaiveDateTime> {
|
||||
fn last_refreshed_at(&self) -> Option<DateTime<Utc>> {
|
||||
Some(self.last_refreshed_at)
|
||||
}
|
||||
|
||||
|
@ -139,7 +139,7 @@ impl Object for ApubSite {
|
|||
let site_form = SiteInsertForm {
|
||||
name: apub.name.clone(),
|
||||
sidebar,
|
||||
updated: apub.updated.map(|u| u.clone().naive_local()),
|
||||
updated: apub.updated,
|
||||
icon: apub.icon.clone().map(|i| i.url.into()),
|
||||
banner: apub.image.clone().map(|i| i.url.into()),
|
||||
description,
|
||||
|
|
|
@ -16,7 +16,7 @@ use activitypub_federation::{
|
|||
protocol::verification::verify_domains_match,
|
||||
traits::{Actor, Object},
|
||||
};
|
||||
use chrono::NaiveDateTime;
|
||||
use chrono::{DateTime, Utc};
|
||||
use lemmy_api_common::{
|
||||
context::LemmyContext,
|
||||
utils::{generate_outbox_url, local_site_opt_to_slur_regex, sanitize_html, sanitize_html_opt},
|
||||
|
@ -59,7 +59,7 @@ impl Object for ApubPerson {
|
|||
type Kind = Person;
|
||||
type Error = LemmyError;
|
||||
|
||||
fn last_refreshed_at(&self) -> Option<NaiveDateTime> {
|
||||
fn last_refreshed_at(&self) -> Option<DateTime<Utc>> {
|
||||
Some(self.last_refreshed_at)
|
||||
}
|
||||
|
||||
|
@ -158,8 +158,8 @@ impl Object for ApubPerson {
|
|||
deleted: Some(false),
|
||||
avatar: person.icon.map(|i| i.url.into()),
|
||||
banner: person.image.map(|i| i.url.into()),
|
||||
published: person.published.map(|u| u.naive_local()),
|
||||
updated: person.updated.map(|u| u.naive_local()),
|
||||
published: person.published.map(Into::into),
|
||||
updated: person.updated.map(Into::into),
|
||||
actor_id: Some(person.id.into()),
|
||||
bio,
|
||||
local: Some(false),
|
||||
|
|
|
@ -20,7 +20,7 @@ use activitypub_federation::{
|
|||
traits::Object,
|
||||
};
|
||||
use anyhow::anyhow;
|
||||
use chrono::NaiveDateTime;
|
||||
use chrono::{DateTime, Utc};
|
||||
use html2md::parse_html;
|
||||
use lemmy_api_common::{
|
||||
context::LemmyContext,
|
||||
|
@ -80,7 +80,7 @@ impl Object for ApubPost {
|
|||
type Kind = Page;
|
||||
type Error = LemmyError;
|
||||
|
||||
fn last_refreshed_at(&self) -> Option<NaiveDateTime> {
|
||||
fn last_refreshed_at(&self) -> Option<DateTime<Utc>> {
|
||||
None
|
||||
}
|
||||
|
||||
|
@ -249,8 +249,8 @@ impl Object for ApubPost {
|
|||
community_id: community.id,
|
||||
removed: None,
|
||||
locked: page.comments_enabled.map(|e| !e),
|
||||
published: page.published.map(|u| u.naive_local()),
|
||||
updated: page.updated.map(|u| u.naive_local()),
|
||||
published: page.published.map(Into::into),
|
||||
updated: page.updated.map(Into::into),
|
||||
deleted: Some(false),
|
||||
nsfw: page.sensitive,
|
||||
embed_title,
|
||||
|
@ -271,7 +271,7 @@ impl Object for ApubPost {
|
|||
.community_id(community.id)
|
||||
.ap_id(Some(page.id.clone().into()))
|
||||
.locked(page.comments_enabled.map(|e| !e))
|
||||
.updated(page.updated.map(|u| u.naive_local()))
|
||||
.updated(page.updated.map(Into::into))
|
||||
.build()
|
||||
};
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@ use activitypub_federation::{
|
|||
protocol::{values::MediaTypeHtml, verification::verify_domains_match},
|
||||
traits::Object,
|
||||
};
|
||||
use chrono::NaiveDateTime;
|
||||
use chrono::{DateTime, Utc};
|
||||
use lemmy_api_common::{
|
||||
context::LemmyContext,
|
||||
utils::{check_person_block, sanitize_html},
|
||||
|
@ -52,7 +52,7 @@ impl Object for ApubPrivateMessage {
|
|||
type Kind = ChatMessage;
|
||||
type Error = LemmyError;
|
||||
|
||||
fn last_refreshed_at(&self) -> Option<NaiveDateTime> {
|
||||
fn last_refreshed_at(&self) -> Option<DateTime<Utc>> {
|
||||
None
|
||||
}
|
||||
|
||||
|
@ -130,8 +130,8 @@ impl Object for ApubPrivateMessage {
|
|||
creator_id: creator.id,
|
||||
recipient_id: recipient.id,
|
||||
content,
|
||||
published: note.published.map(|u| u.naive_local()),
|
||||
updated: note.updated.map(|u| u.naive_local()),
|
||||
published: note.published.map(Into::into),
|
||||
updated: note.updated.map(Into::into),
|
||||
deleted: Some(false),
|
||||
read: None,
|
||||
ap_id: Some(note.id.into()),
|
||||
|
|
|
@ -10,7 +10,7 @@ use activitypub_federation::{
|
|||
protocol::helpers::deserialize_one_or_many,
|
||||
};
|
||||
use anyhow::anyhow;
|
||||
use chrono::{DateTime, FixedOffset};
|
||||
use chrono::{DateTime, Utc};
|
||||
use lemmy_api_common::context::LemmyContext;
|
||||
use lemmy_utils::error::LemmyError;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
@ -38,7 +38,7 @@ pub struct BlockUser {
|
|||
pub(crate) remove_data: Option<bool>,
|
||||
/// block reason, written to mod log
|
||||
pub(crate) summary: Option<String>,
|
||||
pub(crate) expires: Option<DateTime<FixedOffset>>,
|
||||
pub(crate) expires: Option<DateTime<Utc>>,
|
||||
}
|
||||
|
||||
#[async_trait::async_trait]
|
||||
|
|
|
@ -9,7 +9,7 @@ use activitypub_federation::{
|
|||
values::MediaTypeHtml,
|
||||
},
|
||||
};
|
||||
use chrono::{DateTime, FixedOffset};
|
||||
use chrono::{DateTime, Utc};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use serde_with::skip_serializing_none;
|
||||
|
||||
|
@ -27,8 +27,8 @@ pub struct ChatMessage {
|
|||
pub(crate) media_type: Option<MediaTypeHtml>,
|
||||
#[serde(deserialize_with = "deserialize_skip_error", default)]
|
||||
pub(crate) source: Option<Source>,
|
||||
pub(crate) published: Option<DateTime<FixedOffset>>,
|
||||
pub(crate) updated: Option<DateTime<FixedOffset>>,
|
||||
pub(crate) published: Option<DateTime<Utc>>,
|
||||
pub(crate) updated: Option<DateTime<Utc>>,
|
||||
}
|
||||
|
||||
/// https://docs.pleroma.social/backend/development/ap_extensions/#chatmessages
|
||||
|
|
|
@ -22,7 +22,7 @@ use activitypub_federation::{
|
|||
verification::verify_domains_match,
|
||||
},
|
||||
};
|
||||
use chrono::{DateTime, FixedOffset};
|
||||
use chrono::{DateTime, Utc};
|
||||
use lemmy_api_common::{
|
||||
context::LemmyContext,
|
||||
utils::{local_site_opt_to_slur_regex, sanitize_html, sanitize_html_opt},
|
||||
|
@ -73,8 +73,8 @@ pub struct Group {
|
|||
pub(crate) featured: Option<CollectionId<ApubCommunityFeatured>>,
|
||||
#[serde(default)]
|
||||
pub(crate) language: Vec<LanguageTag>,
|
||||
pub(crate) published: Option<DateTime<FixedOffset>>,
|
||||
pub(crate) updated: Option<DateTime<FixedOffset>>,
|
||||
pub(crate) published: Option<DateTime<Utc>>,
|
||||
pub(crate) updated: Option<DateTime<Utc>>,
|
||||
}
|
||||
|
||||
impl Group {
|
||||
|
@ -107,8 +107,8 @@ impl Group {
|
|||
title,
|
||||
description,
|
||||
removed: None,
|
||||
published: self.published.map(|u| u.naive_local()),
|
||||
updated: self.updated.map(|u| u.naive_local()),
|
||||
published: self.published,
|
||||
updated: self.updated,
|
||||
deleted: Some(false),
|
||||
nsfw: Some(self.sensitive.unwrap_or(false)),
|
||||
actor_id: Some(self.id.into()),
|
||||
|
@ -138,8 +138,8 @@ impl Group {
|
|||
&self.source,
|
||||
)),
|
||||
removed: None,
|
||||
published: self.published.map(|u| u.naive_local()),
|
||||
updated: Some(self.updated.map(|u| u.naive_local())),
|
||||
published: self.published.map(Into::into),
|
||||
updated: Some(self.updated.map(Into::into)),
|
||||
deleted: None,
|
||||
nsfw: Some(self.sensitive.unwrap_or(false)),
|
||||
actor_id: Some(self.id.into()),
|
||||
|
|
|
@ -7,7 +7,7 @@ use activitypub_federation::{
|
|||
kinds::actor::ApplicationType,
|
||||
protocol::{helpers::deserialize_skip_error, public_key::PublicKey, values::MediaTypeHtml},
|
||||
};
|
||||
use chrono::{DateTime, FixedOffset};
|
||||
use chrono::{DateTime, Utc};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use serde_with::skip_serializing_none;
|
||||
use url::Url;
|
||||
|
@ -39,6 +39,6 @@ pub struct Instance {
|
|||
pub(crate) image: Option<ImageObject>,
|
||||
#[serde(default)]
|
||||
pub(crate) language: Vec<LanguageTag>,
|
||||
pub(crate) published: DateTime<FixedOffset>,
|
||||
pub(crate) updated: Option<DateTime<FixedOffset>>,
|
||||
pub(crate) published: DateTime<Utc>,
|
||||
pub(crate) updated: Option<DateTime<Utc>>,
|
||||
}
|
||||
|
|
|
@ -14,7 +14,7 @@ use activitypub_federation::{
|
|||
values::MediaTypeMarkdownOrHtml,
|
||||
},
|
||||
};
|
||||
use chrono::{DateTime, FixedOffset};
|
||||
use chrono::{DateTime, Utc};
|
||||
use lemmy_api_common::context::LemmyContext;
|
||||
use lemmy_db_schema::{
|
||||
source::{community::Community, post::Post},
|
||||
|
@ -43,8 +43,8 @@ pub struct Note {
|
|||
pub(crate) media_type: Option<MediaTypeMarkdownOrHtml>,
|
||||
#[serde(deserialize_with = "deserialize_skip_error", default)]
|
||||
pub(crate) source: Option<Source>,
|
||||
pub(crate) published: Option<DateTime<FixedOffset>>,
|
||||
pub(crate) updated: Option<DateTime<FixedOffset>>,
|
||||
pub(crate) published: Option<DateTime<Utc>>,
|
||||
pub(crate) updated: Option<DateTime<Utc>>,
|
||||
#[serde(default)]
|
||||
pub(crate) tag: Vec<MentionOrValue>,
|
||||
// lemmy extension
|
||||
|
|
|
@ -17,7 +17,7 @@ use activitypub_federation::{
|
|||
},
|
||||
traits::{ActivityHandler, Object},
|
||||
};
|
||||
use chrono::{DateTime, FixedOffset};
|
||||
use chrono::{DateTime, Utc};
|
||||
use itertools::Itertools;
|
||||
use lemmy_api_common::context::LemmyContext;
|
||||
use lemmy_db_schema::newtypes::DbUrl;
|
||||
|
@ -63,8 +63,8 @@ pub struct Page {
|
|||
pub(crate) image: Option<ImageObject>,
|
||||
pub(crate) comments_enabled: Option<bool>,
|
||||
pub(crate) sensitive: Option<bool>,
|
||||
pub(crate) published: Option<DateTime<FixedOffset>>,
|
||||
pub(crate) updated: Option<DateTime<FixedOffset>>,
|
||||
pub(crate) published: Option<DateTime<Utc>>,
|
||||
pub(crate) updated: Option<DateTime<Utc>>,
|
||||
pub(crate) language: Option<LanguageTag>,
|
||||
pub(crate) audience: Option<ObjectId<ApubCommunity>>,
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@ use activitypub_federation::{
|
|||
fetch::object_id::ObjectId,
|
||||
protocol::{helpers::deserialize_skip_error, public_key::PublicKey},
|
||||
};
|
||||
use chrono::{DateTime, FixedOffset};
|
||||
use chrono::{DateTime, Utc};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use serde_with::skip_serializing_none;
|
||||
use url::Url;
|
||||
|
@ -43,6 +43,6 @@ pub struct Person {
|
|||
pub(crate) image: Option<ImageObject>,
|
||||
pub(crate) matrix_user_id: Option<String>,
|
||||
pub(crate) endpoints: Option<Endpoints>,
|
||||
pub(crate) published: Option<DateTime<FixedOffset>>,
|
||||
pub(crate) updated: Option<DateTime<FixedOffset>>,
|
||||
pub(crate) published: Option<DateTime<Utc>>,
|
||||
pub(crate) updated: Option<DateTime<Utc>>,
|
||||
}
|
||||
|
|
|
@ -8,10 +8,10 @@ use crate::schema::{
|
|||
post_aggregates,
|
||||
site_aggregates,
|
||||
};
|
||||
use chrono::{DateTime, Utc};
|
||||
use serde::{Deserialize, Serialize};
|
||||
#[cfg(feature = "full")]
|
||||
use ts_rs::TS;
|
||||
|
||||
#[derive(PartialEq, Debug, Serialize, Deserialize, Clone)]
|
||||
#[cfg_attr(feature = "full", derive(Queryable, Associations, Identifiable, TS))]
|
||||
#[cfg_attr(feature = "full", diesel(table_name = comment_aggregates))]
|
||||
|
@ -24,7 +24,7 @@ pub struct CommentAggregates {
|
|||
pub score: i64,
|
||||
pub upvotes: i64,
|
||||
pub downvotes: i64,
|
||||
pub published: chrono::NaiveDateTime,
|
||||
pub published: DateTime<Utc>,
|
||||
/// The total number of children in this comment branch.
|
||||
pub child_count: i32,
|
||||
pub hot_rank: i32,
|
||||
|
@ -46,7 +46,7 @@ pub struct CommunityAggregates {
|
|||
pub subscribers: i64,
|
||||
pub posts: i64,
|
||||
pub comments: i64,
|
||||
pub published: chrono::NaiveDateTime,
|
||||
pub published: DateTime<Utc>,
|
||||
/// The number of users with any activity in the last day.
|
||||
pub users_active_day: i64,
|
||||
/// The number of users with any activity in the last week.
|
||||
|
@ -86,11 +86,11 @@ pub struct PostAggregates {
|
|||
pub score: i64,
|
||||
pub upvotes: i64,
|
||||
pub downvotes: i64,
|
||||
pub published: chrono::NaiveDateTime,
|
||||
pub published: DateTime<Utc>,
|
||||
/// A newest comment time, limited to 2 days, to prevent necrobumping
|
||||
pub newest_comment_time_necro: chrono::NaiveDateTime,
|
||||
pub newest_comment_time_necro: DateTime<Utc>,
|
||||
/// The time of the newest comment in the post.
|
||||
pub newest_comment_time: chrono::NaiveDateTime,
|
||||
pub newest_comment_time: DateTime<Utc>,
|
||||
/// If the post is featured on the community.
|
||||
pub featured_community: bool,
|
||||
/// If the post is featured on the site / to local.
|
||||
|
@ -115,7 +115,7 @@ pub struct PersonPostAggregates {
|
|||
///
|
||||
/// This is updated to the current post comment count every time they view a post.
|
||||
pub read_comments: i64,
|
||||
pub published: chrono::NaiveDateTime,
|
||||
pub published: DateTime<Utc>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Default)]
|
||||
|
@ -125,7 +125,7 @@ pub struct PersonPostAggregatesForm {
|
|||
pub person_id: PersonId,
|
||||
pub post_id: PostId,
|
||||
pub read_comments: i64,
|
||||
pub published: Option<chrono::NaiveDateTime>,
|
||||
pub published: Option<DateTime<Utc>>,
|
||||
}
|
||||
|
||||
#[derive(PartialEq, Eq, Debug, Serialize, Deserialize, Clone)]
|
||||
|
|
|
@ -20,7 +20,7 @@ index 255c6422..f2ccf5e2 100644
|
|||
#[derive(diesel::sql_types::SqlType)]
|
||||
#[diesel(postgres_type(name = "sort_type_enum"))]
|
||||
@@ -76,13 +76,13 @@ diesel::table! {
|
||||
published -> Timestamp,
|
||||
published -> Timestamptz,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -13,7 +13,9 @@ use diesel::{
|
|||
dsl::{now, IntervalDsl},
|
||||
insert_into,
|
||||
result::Error,
|
||||
sql_types::Timestamptz,
|
||||
ExpressionMethods,
|
||||
IntoSql,
|
||||
QueryDsl,
|
||||
};
|
||||
use diesel_async::RunQueryDsl;
|
||||
|
@ -31,7 +33,7 @@ impl EmailVerification {
|
|||
let conn = &mut get_conn(pool).await?;
|
||||
email_verification
|
||||
.filter(verification_token.eq(token))
|
||||
.filter(published.gt(now - 7.days()))
|
||||
.filter(published.gt(now.into_sql::<Timestamptz>() - 7.days()))
|
||||
.first::<Self>(conn)
|
||||
.await
|
||||
}
|
||||
|
|
|
@ -3,12 +3,12 @@ use crate::{
|
|||
newtypes::InstanceId,
|
||||
schema::{federation_allowlist, federation_blocklist, instance, local_site, site},
|
||||
source::instance::{Instance, InstanceForm},
|
||||
utils::{functions::lower, get_conn, naive_now, DbPool},
|
||||
utils::{functions::lower, get_conn, naive_now, now, DbPool},
|
||||
};
|
||||
use diesel::{
|
||||
dsl::{insert_into, now},
|
||||
dsl::insert_into,
|
||||
result::Error,
|
||||
sql_types::{Nullable, Timestamp},
|
||||
sql_types::{Nullable, Timestamptz},
|
||||
ExpressionMethods,
|
||||
QueryDsl,
|
||||
};
|
||||
|
@ -66,7 +66,7 @@ impl Instance {
|
|||
let conn = &mut get_conn(pool).await?;
|
||||
instance::table
|
||||
.select(instance::domain)
|
||||
.filter(coalesce(instance::updated, instance::published).lt(now - 3.days()))
|
||||
.filter(coalesce(instance::updated, instance::published).lt(now() - 3.days()))
|
||||
.get_results(conn)
|
||||
.await
|
||||
}
|
||||
|
@ -109,4 +109,4 @@ impl Instance {
|
|||
}
|
||||
}
|
||||
|
||||
sql_function! { fn coalesce(x: Nullable<Timestamp>, y: Timestamp) -> Timestamp; }
|
||||
sql_function! { fn coalesce(x: Nullable<Timestamptz>, y: Timestamptz) -> Timestamptz; }
|
||||
|
|
|
@ -8,7 +8,9 @@ use crate::{
|
|||
use diesel::{
|
||||
dsl::{insert_into, now, IntervalDsl},
|
||||
result::Error,
|
||||
sql_types::Timestamptz,
|
||||
ExpressionMethods,
|
||||
IntoSql,
|
||||
QueryDsl,
|
||||
};
|
||||
use diesel_async::RunQueryDsl;
|
||||
|
@ -59,7 +61,7 @@ impl PasswordResetRequest {
|
|||
let conn = &mut get_conn(pool).await?;
|
||||
password_reset_request
|
||||
.filter(token.eq(token_))
|
||||
.filter(published.gt(now - 1.days()))
|
||||
.filter(published.gt(now.into_sql::<Timestamptz>() - 1.days()))
|
||||
.first::<Self>(conn)
|
||||
.await
|
||||
}
|
||||
|
@ -71,7 +73,7 @@ impl PasswordResetRequest {
|
|||
let conn = &mut get_conn(pool).await?;
|
||||
password_reset_request
|
||||
.filter(local_user_id.eq(user_id))
|
||||
.filter(published.gt(now - 1.days()))
|
||||
.filter(published.gt(now.into_sql::<Timestamptz>() - 1.days()))
|
||||
.count()
|
||||
.get_result(conn)
|
||||
.await
|
||||
|
|
|
@ -11,6 +11,7 @@ use crate::{
|
|||
traits::{ApubActor, Crud, Followable},
|
||||
utils::{functions::lower, get_conn, naive_now, DbPool},
|
||||
};
|
||||
use chrono::{DateTime, Utc};
|
||||
use diesel::{dsl::insert_into, result::Error, ExpressionMethods, JoinOnDsl, QueryDsl};
|
||||
use diesel_async::RunQueryDsl;
|
||||
|
||||
|
@ -89,7 +90,7 @@ impl Person {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn is_banned(banned_: bool, expires: Option<chrono::NaiveDateTime>) -> bool {
|
||||
pub fn is_banned(banned_: bool, expires: Option<DateTime<Utc>>) -> bool {
|
||||
if let Some(expires) = expires {
|
||||
banned_ && expires.gt(&naive_now())
|
||||
} else {
|
||||
|
|
|
@ -20,7 +20,7 @@ diesel::table! {
|
|||
admin_person_id -> Int4,
|
||||
post_id -> Int4,
|
||||
reason -> Nullable<Text>,
|
||||
when_ -> Timestamp,
|
||||
when_ -> Timestamptz,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -29,7 +29,7 @@ diesel::table! {
|
|||
id -> Int4,
|
||||
admin_person_id -> Int4,
|
||||
reason -> Nullable<Text>,
|
||||
when_ -> Timestamp,
|
||||
when_ -> Timestamptz,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -38,7 +38,7 @@ diesel::table! {
|
|||
id -> Int4,
|
||||
admin_person_id -> Int4,
|
||||
reason -> Nullable<Text>,
|
||||
when_ -> Timestamp,
|
||||
when_ -> Timestamptz,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -48,7 +48,7 @@ diesel::table! {
|
|||
admin_person_id -> Int4,
|
||||
community_id -> Int4,
|
||||
reason -> Nullable<Text>,
|
||||
when_ -> Timestamp,
|
||||
when_ -> Timestamptz,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -57,7 +57,7 @@ diesel::table! {
|
|||
id -> Int4,
|
||||
uuid -> Uuid,
|
||||
answer -> Text,
|
||||
published -> Timestamp,
|
||||
published -> Timestamptz,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -71,8 +71,8 @@ diesel::table! {
|
|||
post_id -> Int4,
|
||||
content -> Text,
|
||||
removed -> Bool,
|
||||
published -> Timestamp,
|
||||
updated -> Nullable<Timestamp>,
|
||||
published -> Timestamptz,
|
||||
updated -> Nullable<Timestamptz>,
|
||||
deleted -> Bool,
|
||||
#[max_length = 255]
|
||||
ap_id -> Varchar,
|
||||
|
@ -90,7 +90,7 @@ diesel::table! {
|
|||
score -> Int8,
|
||||
upvotes -> Int8,
|
||||
downvotes -> Int8,
|
||||
published -> Timestamp,
|
||||
published -> Timestamptz,
|
||||
child_count -> Int4,
|
||||
hot_rank -> Int4,
|
||||
controversy_rank -> Float8,
|
||||
|
@ -104,7 +104,7 @@ diesel::table! {
|
|||
comment_id -> Int4,
|
||||
post_id -> Int4,
|
||||
score -> Int2,
|
||||
published -> Timestamp,
|
||||
published -> Timestamptz,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -114,7 +114,7 @@ diesel::table! {
|
|||
recipient_id -> Int4,
|
||||
comment_id -> Int4,
|
||||
read -> Bool,
|
||||
published -> Timestamp,
|
||||
published -> Timestamptz,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -127,8 +127,8 @@ diesel::table! {
|
|||
reason -> Text,
|
||||
resolved -> Bool,
|
||||
resolver_id -> Nullable<Int4>,
|
||||
published -> Timestamp,
|
||||
updated -> Nullable<Timestamp>,
|
||||
published -> Timestamptz,
|
||||
updated -> Nullable<Timestamptz>,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -137,7 +137,7 @@ diesel::table! {
|
|||
id -> Int4,
|
||||
comment_id -> Int4,
|
||||
person_id -> Int4,
|
||||
published -> Timestamp,
|
||||
published -> Timestamptz,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -150,8 +150,8 @@ diesel::table! {
|
|||
title -> Varchar,
|
||||
description -> Nullable<Text>,
|
||||
removed -> Bool,
|
||||
published -> Timestamp,
|
||||
updated -> Nullable<Timestamp>,
|
||||
published -> Timestamptz,
|
||||
updated -> Nullable<Timestamptz>,
|
||||
deleted -> Bool,
|
||||
nsfw -> Bool,
|
||||
#[max_length = 255]
|
||||
|
@ -159,7 +159,7 @@ diesel::table! {
|
|||
local -> Bool,
|
||||
private_key -> Nullable<Text>,
|
||||
public_key -> Text,
|
||||
last_refreshed_at -> Timestamp,
|
||||
last_refreshed_at -> Timestamptz,
|
||||
icon -> Nullable<Text>,
|
||||
banner -> Nullable<Text>,
|
||||
#[max_length = 255]
|
||||
|
@ -185,7 +185,7 @@ diesel::table! {
|
|||
subscribers -> Int8,
|
||||
posts -> Int8,
|
||||
comments -> Int8,
|
||||
published -> Timestamp,
|
||||
published -> Timestamptz,
|
||||
users_active_day -> Int8,
|
||||
users_active_week -> Int8,
|
||||
users_active_month -> Int8,
|
||||
|
@ -199,7 +199,7 @@ diesel::table! {
|
|||
id -> Int4,
|
||||
person_id -> Int4,
|
||||
community_id -> Int4,
|
||||
published -> Timestamp,
|
||||
published -> Timestamptz,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -208,7 +208,7 @@ diesel::table! {
|
|||
id -> Int4,
|
||||
community_id -> Int4,
|
||||
person_id -> Int4,
|
||||
published -> Timestamp,
|
||||
published -> Timestamptz,
|
||||
pending -> Bool,
|
||||
}
|
||||
}
|
||||
|
@ -226,7 +226,7 @@ diesel::table! {
|
|||
id -> Int4,
|
||||
community_id -> Int4,
|
||||
person_id -> Int4,
|
||||
published -> Timestamp,
|
||||
published -> Timestamptz,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -235,8 +235,8 @@ diesel::table! {
|
|||
id -> Int4,
|
||||
community_id -> Int4,
|
||||
person_id -> Int4,
|
||||
published -> Timestamp,
|
||||
expires -> Nullable<Timestamp>,
|
||||
published -> Timestamptz,
|
||||
expires -> Nullable<Timestamptz>,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -249,8 +249,8 @@ diesel::table! {
|
|||
image_url -> Text,
|
||||
alt_text -> Text,
|
||||
category -> Text,
|
||||
published -> Timestamp,
|
||||
updated -> Nullable<Timestamp>,
|
||||
published -> Timestamptz,
|
||||
updated -> Nullable<Timestamptz>,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -269,7 +269,7 @@ diesel::table! {
|
|||
local_user_id -> Int4,
|
||||
email -> Text,
|
||||
verification_token -> Text,
|
||||
published -> Timestamp,
|
||||
published -> Timestamptz,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -277,8 +277,8 @@ diesel::table! {
|
|||
federation_allowlist (id) {
|
||||
id -> Int4,
|
||||
instance_id -> Int4,
|
||||
published -> Timestamp,
|
||||
updated -> Nullable<Timestamp>,
|
||||
published -> Timestamptz,
|
||||
updated -> Nullable<Timestamptz>,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -286,8 +286,8 @@ diesel::table! {
|
|||
federation_blocklist (id) {
|
||||
id -> Int4,
|
||||
instance_id -> Int4,
|
||||
published -> Timestamp,
|
||||
updated -> Nullable<Timestamp>,
|
||||
published -> Timestamptz,
|
||||
updated -> Nullable<Timestamptz>,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -296,8 +296,8 @@ diesel::table! {
|
|||
id -> Int4,
|
||||
#[max_length = 255]
|
||||
domain -> Varchar,
|
||||
published -> Timestamp,
|
||||
updated -> Nullable<Timestamp>,
|
||||
published -> Timestamptz,
|
||||
updated -> Nullable<Timestamptz>,
|
||||
#[max_length = 255]
|
||||
software -> Nullable<Varchar>,
|
||||
#[max_length = 255]
|
||||
|
@ -340,8 +340,8 @@ diesel::table! {
|
|||
captcha_enabled -> Bool,
|
||||
#[max_length = 255]
|
||||
captcha_difficulty -> Varchar,
|
||||
published -> Timestamp,
|
||||
updated -> Nullable<Timestamp>,
|
||||
published -> Timestamptz,
|
||||
updated -> Nullable<Timestamptz>,
|
||||
registration_mode -> RegistrationModeEnum,
|
||||
reports_email_admins -> Bool,
|
||||
}
|
||||
|
@ -363,8 +363,8 @@ diesel::table! {
|
|||
comment_per_second -> Int4,
|
||||
search -> Int4,
|
||||
search_per_second -> Int4,
|
||||
published -> Timestamp,
|
||||
updated -> Nullable<Timestamp>,
|
||||
published -> Timestamptz,
|
||||
updated -> Nullable<Timestamptz>,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -386,7 +386,7 @@ diesel::table! {
|
|||
interface_language -> Varchar,
|
||||
show_avatars -> Bool,
|
||||
send_notifications_to_email -> Bool,
|
||||
validator_time -> Timestamp,
|
||||
validator_time -> Timestamptz,
|
||||
show_scores -> Bool,
|
||||
show_bot_accounts -> Bool,
|
||||
show_read_posts -> Bool,
|
||||
|
@ -396,9 +396,9 @@ diesel::table! {
|
|||
totp_2fa_secret -> Nullable<Text>,
|
||||
totp_2fa_url -> Nullable<Text>,
|
||||
open_links_in_new_tab -> Bool,
|
||||
infinite_scroll_enabled -> Bool,
|
||||
blur_nsfw -> Bool,
|
||||
auto_expand -> Bool,
|
||||
infinite_scroll_enabled -> Bool,
|
||||
admin -> Bool,
|
||||
}
|
||||
}
|
||||
|
@ -417,7 +417,7 @@ diesel::table! {
|
|||
mod_person_id -> Int4,
|
||||
other_person_id -> Int4,
|
||||
removed -> Bool,
|
||||
when_ -> Timestamp,
|
||||
when_ -> Timestamptz,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -428,7 +428,7 @@ diesel::table! {
|
|||
other_person_id -> Int4,
|
||||
community_id -> Int4,
|
||||
removed -> Bool,
|
||||
when_ -> Timestamp,
|
||||
when_ -> Timestamptz,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -439,8 +439,8 @@ diesel::table! {
|
|||
other_person_id -> Int4,
|
||||
reason -> Nullable<Text>,
|
||||
banned -> Bool,
|
||||
expires -> Nullable<Timestamp>,
|
||||
when_ -> Timestamp,
|
||||
expires -> Nullable<Timestamptz>,
|
||||
when_ -> Timestamptz,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -452,8 +452,8 @@ diesel::table! {
|
|||
community_id -> Int4,
|
||||
reason -> Nullable<Text>,
|
||||
banned -> Bool,
|
||||
expires -> Nullable<Timestamp>,
|
||||
when_ -> Timestamp,
|
||||
expires -> Nullable<Timestamptz>,
|
||||
when_ -> Timestamptz,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -463,7 +463,7 @@ diesel::table! {
|
|||
mod_person_id -> Int4,
|
||||
post_id -> Int4,
|
||||
featured -> Bool,
|
||||
when_ -> Timestamp,
|
||||
when_ -> Timestamptz,
|
||||
is_featured_community -> Bool,
|
||||
}
|
||||
}
|
||||
|
@ -473,7 +473,7 @@ diesel::table! {
|
|||
id -> Int4,
|
||||
community_id -> Int4,
|
||||
mod_person_id -> Int4,
|
||||
when_ -> Timestamp,
|
||||
when_ -> Timestamptz,
|
||||
reason -> Nullable<Text>,
|
||||
hidden -> Bool,
|
||||
}
|
||||
|
@ -485,7 +485,7 @@ diesel::table! {
|
|||
mod_person_id -> Int4,
|
||||
post_id -> Int4,
|
||||
locked -> Bool,
|
||||
when_ -> Timestamp,
|
||||
when_ -> Timestamptz,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -496,7 +496,7 @@ diesel::table! {
|
|||
comment_id -> Int4,
|
||||
reason -> Nullable<Text>,
|
||||
removed -> Bool,
|
||||
when_ -> Timestamp,
|
||||
when_ -> Timestamptz,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -507,8 +507,8 @@ diesel::table! {
|
|||
community_id -> Int4,
|
||||
reason -> Nullable<Text>,
|
||||
removed -> Bool,
|
||||
expires -> Nullable<Timestamp>,
|
||||
when_ -> Timestamp,
|
||||
expires -> Nullable<Timestamptz>,
|
||||
when_ -> Timestamptz,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -519,7 +519,7 @@ diesel::table! {
|
|||
post_id -> Int4,
|
||||
reason -> Nullable<Text>,
|
||||
removed -> Bool,
|
||||
when_ -> Timestamp,
|
||||
when_ -> Timestamptz,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -529,7 +529,7 @@ diesel::table! {
|
|||
mod_person_id -> Int4,
|
||||
other_person_id -> Int4,
|
||||
community_id -> Int4,
|
||||
when_ -> Timestamp,
|
||||
when_ -> Timestamptz,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -537,7 +537,7 @@ diesel::table! {
|
|||
password_reset_request (id) {
|
||||
id -> Int4,
|
||||
token -> Text,
|
||||
published -> Timestamp,
|
||||
published -> Timestamptz,
|
||||
local_user_id -> Int4,
|
||||
}
|
||||
}
|
||||
|
@ -551,15 +551,15 @@ diesel::table! {
|
|||
display_name -> Nullable<Varchar>,
|
||||
avatar -> Nullable<Text>,
|
||||
banned -> Bool,
|
||||
published -> Timestamp,
|
||||
updated -> Nullable<Timestamp>,
|
||||
published -> Timestamptz,
|
||||
updated -> Nullable<Timestamptz>,
|
||||
#[max_length = 255]
|
||||
actor_id -> Varchar,
|
||||
bio -> Nullable<Text>,
|
||||
local -> Bool,
|
||||
private_key -> Nullable<Text>,
|
||||
public_key -> Text,
|
||||
last_refreshed_at -> Timestamp,
|
||||
last_refreshed_at -> Timestamptz,
|
||||
banner -> Nullable<Text>,
|
||||
deleted -> Bool,
|
||||
#[max_length = 255]
|
||||
|
@ -568,7 +568,7 @@ diesel::table! {
|
|||
shared_inbox_url -> Nullable<Varchar>,
|
||||
matrix_user_id -> Nullable<Text>,
|
||||
bot_account -> Bool,
|
||||
ban_expires -> Nullable<Timestamp>,
|
||||
ban_expires -> Nullable<Timestamptz>,
|
||||
instance_id -> Int4,
|
||||
}
|
||||
}
|
||||
|
@ -588,7 +588,7 @@ diesel::table! {
|
|||
person_ban (id) {
|
||||
id -> Int4,
|
||||
person_id -> Int4,
|
||||
published -> Timestamp,
|
||||
published -> Timestamptz,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -597,7 +597,7 @@ diesel::table! {
|
|||
id -> Int4,
|
||||
person_id -> Int4,
|
||||
target_id -> Int4,
|
||||
published -> Timestamp,
|
||||
published -> Timestamptz,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -606,7 +606,7 @@ diesel::table! {
|
|||
id -> Int4,
|
||||
person_id -> Int4,
|
||||
follower_id -> Int4,
|
||||
published -> Timestamp,
|
||||
published -> Timestamptz,
|
||||
pending -> Bool,
|
||||
}
|
||||
}
|
||||
|
@ -617,7 +617,7 @@ diesel::table! {
|
|||
recipient_id -> Int4,
|
||||
comment_id -> Int4,
|
||||
read -> Bool,
|
||||
published -> Timestamp,
|
||||
published -> Timestamptz,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -627,7 +627,7 @@ diesel::table! {
|
|||
person_id -> Int4,
|
||||
post_id -> Int4,
|
||||
read_comments -> Int8,
|
||||
published -> Timestamp,
|
||||
published -> Timestamptz,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -643,8 +643,8 @@ diesel::table! {
|
|||
community_id -> Int4,
|
||||
removed -> Bool,
|
||||
locked -> Bool,
|
||||
published -> Timestamp,
|
||||
updated -> Nullable<Timestamp>,
|
||||
published -> Timestamptz,
|
||||
updated -> Nullable<Timestamptz>,
|
||||
deleted -> Bool,
|
||||
nsfw -> Bool,
|
||||
embed_title -> Nullable<Text>,
|
||||
|
@ -668,9 +668,9 @@ diesel::table! {
|
|||
score -> Int8,
|
||||
upvotes -> Int8,
|
||||
downvotes -> Int8,
|
||||
published -> Timestamp,
|
||||
newest_comment_time_necro -> Timestamp,
|
||||
newest_comment_time -> Timestamp,
|
||||
published -> Timestamptz,
|
||||
newest_comment_time_necro -> Timestamptz,
|
||||
newest_comment_time -> Timestamptz,
|
||||
featured_community -> Bool,
|
||||
featured_local -> Bool,
|
||||
hot_rank -> Int4,
|
||||
|
@ -687,7 +687,7 @@ diesel::table! {
|
|||
post_id -> Int4,
|
||||
person_id -> Int4,
|
||||
score -> Int2,
|
||||
published -> Timestamp,
|
||||
published -> Timestamptz,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -696,7 +696,7 @@ diesel::table! {
|
|||
id -> Int4,
|
||||
post_id -> Int4,
|
||||
person_id -> Int4,
|
||||
published -> Timestamp,
|
||||
published -> Timestamptz,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -712,8 +712,8 @@ diesel::table! {
|
|||
reason -> Text,
|
||||
resolved -> Bool,
|
||||
resolver_id -> Nullable<Int4>,
|
||||
published -> Timestamp,
|
||||
updated -> Nullable<Timestamp>,
|
||||
published -> Timestamptz,
|
||||
updated -> Nullable<Timestamptz>,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -722,7 +722,7 @@ diesel::table! {
|
|||
id -> Int4,
|
||||
post_id -> Int4,
|
||||
person_id -> Int4,
|
||||
published -> Timestamp,
|
||||
published -> Timestamptz,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -734,8 +734,8 @@ diesel::table! {
|
|||
content -> Text,
|
||||
deleted -> Bool,
|
||||
read -> Bool,
|
||||
published -> Timestamp,
|
||||
updated -> Nullable<Timestamp>,
|
||||
published -> Timestamptz,
|
||||
updated -> Nullable<Timestamptz>,
|
||||
#[max_length = 255]
|
||||
ap_id -> Varchar,
|
||||
local -> Bool,
|
||||
|
@ -751,8 +751,8 @@ diesel::table! {
|
|||
reason -> Text,
|
||||
resolved -> Bool,
|
||||
resolver_id -> Nullable<Int4>,
|
||||
published -> Timestamp,
|
||||
updated -> Nullable<Timestamp>,
|
||||
published -> Timestamptz,
|
||||
updated -> Nullable<Timestamptz>,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -760,7 +760,7 @@ diesel::table! {
|
|||
received_activity (id) {
|
||||
id -> Int8,
|
||||
ap_id -> Text,
|
||||
published -> Timestamp,
|
||||
published -> Timestamptz,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -771,7 +771,7 @@ diesel::table! {
|
|||
answer -> Text,
|
||||
admin_id -> Nullable<Int4>,
|
||||
deny_reason -> Nullable<Text>,
|
||||
published -> Timestamp,
|
||||
published -> Timestamptz,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -788,7 +788,7 @@ diesel::table! {
|
|||
ap_id -> Text,
|
||||
data -> Json,
|
||||
sensitive -> Bool,
|
||||
published -> Timestamp,
|
||||
published -> Timestamptz,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -798,15 +798,15 @@ diesel::table! {
|
|||
#[max_length = 20]
|
||||
name -> Varchar,
|
||||
sidebar -> Nullable<Text>,
|
||||
published -> Timestamp,
|
||||
updated -> Nullable<Timestamp>,
|
||||
published -> Timestamptz,
|
||||
updated -> Nullable<Timestamptz>,
|
||||
icon -> Nullable<Text>,
|
||||
banner -> Nullable<Text>,
|
||||
#[max_length = 150]
|
||||
description -> Nullable<Varchar>,
|
||||
#[max_length = 255]
|
||||
actor_id -> Varchar,
|
||||
last_refreshed_at -> Timestamp,
|
||||
last_refreshed_at -> Timestamptz,
|
||||
#[max_length = 255]
|
||||
inbox_url -> Varchar,
|
||||
private_key -> Nullable<Text>,
|
||||
|
@ -843,8 +843,8 @@ diesel::table! {
|
|||
id -> Int4,
|
||||
local_site_id -> Int4,
|
||||
content -> Text,
|
||||
published -> Timestamp,
|
||||
updated -> Nullable<Timestamp>,
|
||||
published -> Timestamptz,
|
||||
updated -> Nullable<Timestamptz>,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
use crate::{newtypes::DbUrl, schema::sent_activity};
|
||||
use chrono::{DateTime, Utc};
|
||||
use serde_json::Value;
|
||||
use std::fmt::Debug;
|
||||
|
||||
|
@ -9,7 +10,7 @@ pub struct SentActivity {
|
|||
pub ap_id: DbUrl,
|
||||
pub data: Value,
|
||||
pub sensitive: bool,
|
||||
pub published: chrono::NaiveDateTime,
|
||||
pub published: DateTime<Utc>,
|
||||
}
|
||||
#[derive(Insertable)]
|
||||
#[diesel(table_name = sent_activity)]
|
||||
|
@ -24,5 +25,5 @@ pub struct SentActivityForm {
|
|||
pub struct ReceivedActivity {
|
||||
pub id: i64,
|
||||
pub ap_id: DbUrl,
|
||||
pub published: chrono::NaiveDateTime,
|
||||
pub published: DateTime<Utc>,
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#[cfg(feature = "full")]
|
||||
use crate::schema::captcha_answer;
|
||||
use chrono::{DateTime, Utc};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use serde_with::skip_serializing_none;
|
||||
use uuid::Uuid;
|
||||
|
@ -12,7 +13,7 @@ pub struct CaptchaAnswer {
|
|||
pub id: i32,
|
||||
pub uuid: Uuid,
|
||||
pub answer: String,
|
||||
pub published: chrono::NaiveDateTime,
|
||||
pub published: DateTime<Utc>,
|
||||
}
|
||||
|
||||
#[skip_serializing_none]
|
||||
|
|
|
@ -3,6 +3,7 @@ use crate::newtypes::LtreeDef;
|
|||
use crate::newtypes::{CommentId, DbUrl, LanguageId, PersonId, PostId};
|
||||
#[cfg(feature = "full")]
|
||||
use crate::schema::{comment, comment_like, comment_saved};
|
||||
use chrono::{DateTime, Utc};
|
||||
#[cfg(feature = "full")]
|
||||
use diesel_ltree::Ltree;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
@ -25,8 +26,8 @@ pub struct Comment {
|
|||
pub content: String,
|
||||
/// Whether the comment has been removed.
|
||||
pub removed: bool,
|
||||
pub published: chrono::NaiveDateTime,
|
||||
pub updated: Option<chrono::NaiveDateTime>,
|
||||
pub published: DateTime<Utc>,
|
||||
pub updated: Option<DateTime<Utc>>,
|
||||
/// Whether the comment has been deleted by its creator.
|
||||
pub deleted: bool,
|
||||
/// The federated activity id / ap_id.
|
||||
|
@ -57,8 +58,8 @@ pub struct CommentInsertForm {
|
|||
#[builder(!default)]
|
||||
pub content: String,
|
||||
pub removed: Option<bool>,
|
||||
pub published: Option<chrono::NaiveDateTime>,
|
||||
pub updated: Option<chrono::NaiveDateTime>,
|
||||
pub published: Option<DateTime<Utc>>,
|
||||
pub updated: Option<DateTime<Utc>>,
|
||||
pub deleted: Option<bool>,
|
||||
pub ap_id: Option<DbUrl>,
|
||||
pub local: Option<bool>,
|
||||
|
@ -73,7 +74,7 @@ pub struct CommentUpdateForm {
|
|||
pub content: Option<String>,
|
||||
pub removed: Option<bool>,
|
||||
// Don't use a default naive_now here, because the create function does a lot of comment updates
|
||||
pub updated: Option<Option<chrono::NaiveDateTime>>,
|
||||
pub updated: Option<Option<DateTime<Utc>>>,
|
||||
pub deleted: Option<bool>,
|
||||
pub ap_id: Option<DbUrl>,
|
||||
pub local: Option<bool>,
|
||||
|
@ -91,7 +92,7 @@ pub struct CommentLike {
|
|||
pub comment_id: CommentId,
|
||||
pub post_id: PostId, // TODO this is redundant
|
||||
pub score: i16,
|
||||
pub published: chrono::NaiveDateTime,
|
||||
pub published: DateTime<Utc>,
|
||||
}
|
||||
|
||||
#[derive(Clone)]
|
||||
|
@ -112,7 +113,7 @@ pub struct CommentSaved {
|
|||
pub id: i32,
|
||||
pub comment_id: CommentId,
|
||||
pub person_id: PersonId,
|
||||
pub published: chrono::NaiveDateTime,
|
||||
pub published: DateTime<Utc>,
|
||||
}
|
||||
|
||||
#[cfg_attr(feature = "full", derive(Insertable, AsChangeset))]
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
use crate::newtypes::{CommentId, CommentReplyId, PersonId};
|
||||
#[cfg(feature = "full")]
|
||||
use crate::schema::comment_reply;
|
||||
use chrono::{DateTime, Utc};
|
||||
use serde::{Deserialize, Serialize};
|
||||
#[cfg(feature = "full")]
|
||||
use ts_rs::TS;
|
||||
|
@ -16,7 +17,7 @@ pub struct CommentReply {
|
|||
pub recipient_id: PersonId,
|
||||
pub comment_id: CommentId,
|
||||
pub read: bool,
|
||||
pub published: chrono::NaiveDateTime,
|
||||
pub published: DateTime<Utc>,
|
||||
}
|
||||
|
||||
#[cfg_attr(feature = "full", derive(Insertable, AsChangeset))]
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
use crate::newtypes::{CommentId, CommentReportId, PersonId};
|
||||
#[cfg(feature = "full")]
|
||||
use crate::schema::comment_report;
|
||||
use chrono::{DateTime, Utc};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use serde_with::skip_serializing_none;
|
||||
#[cfg(feature = "full")]
|
||||
|
@ -21,8 +22,8 @@ pub struct CommentReport {
|
|||
pub reason: String,
|
||||
pub resolved: bool,
|
||||
pub resolver_id: Option<PersonId>,
|
||||
pub published: chrono::NaiveDateTime,
|
||||
pub updated: Option<chrono::NaiveDateTime>,
|
||||
pub published: DateTime<Utc>,
|
||||
pub updated: Option<DateTime<Utc>>,
|
||||
}
|
||||
|
||||
#[derive(Clone)]
|
||||
|
|
|
@ -4,6 +4,7 @@ use crate::{
|
|||
newtypes::{CommunityId, DbUrl, InstanceId, PersonId},
|
||||
source::placeholder_apub_url,
|
||||
};
|
||||
use chrono::{DateTime, Utc};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use serde_with::skip_serializing_none;
|
||||
#[cfg(feature = "full")]
|
||||
|
@ -25,8 +26,8 @@ pub struct Community {
|
|||
pub description: Option<String>,
|
||||
/// Whether the community is removed by a mod.
|
||||
pub removed: bool,
|
||||
pub published: chrono::NaiveDateTime,
|
||||
pub updated: Option<chrono::NaiveDateTime>,
|
||||
pub published: DateTime<Utc>,
|
||||
pub updated: Option<DateTime<Utc>>,
|
||||
/// Whether the community has been deleted by its creator.
|
||||
pub deleted: bool,
|
||||
/// Whether its an NSFW community.
|
||||
|
@ -40,7 +41,7 @@ pub struct Community {
|
|||
#[serde(skip)]
|
||||
pub public_key: String,
|
||||
#[serde(skip)]
|
||||
pub last_refreshed_at: chrono::NaiveDateTime,
|
||||
pub last_refreshed_at: DateTime<Utc>,
|
||||
/// A URL for an icon.
|
||||
pub icon: Option<DbUrl>,
|
||||
/// A URL for a banner.
|
||||
|
@ -75,15 +76,15 @@ pub struct CommunityInsertForm {
|
|||
pub title: String,
|
||||
pub description: Option<String>,
|
||||
pub removed: Option<bool>,
|
||||
pub published: Option<chrono::NaiveDateTime>,
|
||||
pub updated: Option<chrono::NaiveDateTime>,
|
||||
pub published: Option<DateTime<Utc>>,
|
||||
pub updated: Option<DateTime<Utc>>,
|
||||
pub deleted: Option<bool>,
|
||||
pub nsfw: Option<bool>,
|
||||
pub actor_id: Option<DbUrl>,
|
||||
pub local: Option<bool>,
|
||||
pub private_key: Option<String>,
|
||||
pub public_key: String,
|
||||
pub last_refreshed_at: Option<chrono::NaiveDateTime>,
|
||||
pub last_refreshed_at: Option<DateTime<Utc>>,
|
||||
pub icon: Option<DbUrl>,
|
||||
pub banner: Option<DbUrl>,
|
||||
pub followers_url: Option<DbUrl>,
|
||||
|
@ -104,15 +105,15 @@ pub struct CommunityUpdateForm {
|
|||
pub title: Option<String>,
|
||||
pub description: Option<Option<String>>,
|
||||
pub removed: Option<bool>,
|
||||
pub published: Option<chrono::NaiveDateTime>,
|
||||
pub updated: Option<Option<chrono::NaiveDateTime>>,
|
||||
pub published: Option<DateTime<Utc>>,
|
||||
pub updated: Option<Option<DateTime<Utc>>>,
|
||||
pub deleted: Option<bool>,
|
||||
pub nsfw: Option<bool>,
|
||||
pub actor_id: Option<DbUrl>,
|
||||
pub local: Option<bool>,
|
||||
pub public_key: Option<String>,
|
||||
pub private_key: Option<Option<String>>,
|
||||
pub last_refreshed_at: Option<chrono::NaiveDateTime>,
|
||||
pub last_refreshed_at: Option<DateTime<Utc>>,
|
||||
pub icon: Option<Option<DbUrl>>,
|
||||
pub banner: Option<Option<DbUrl>>,
|
||||
pub followers_url: Option<DbUrl>,
|
||||
|
@ -135,7 +136,7 @@ pub struct CommunityModerator {
|
|||
pub id: i32,
|
||||
pub community_id: CommunityId,
|
||||
pub person_id: PersonId,
|
||||
pub published: chrono::NaiveDateTime,
|
||||
pub published: DateTime<Utc>,
|
||||
}
|
||||
|
||||
#[derive(Clone)]
|
||||
|
@ -157,8 +158,8 @@ pub struct CommunityPersonBan {
|
|||
pub id: i32,
|
||||
pub community_id: CommunityId,
|
||||
pub person_id: PersonId,
|
||||
pub published: chrono::NaiveDateTime,
|
||||
pub expires: Option<chrono::NaiveDateTime>,
|
||||
pub published: DateTime<Utc>,
|
||||
pub expires: Option<DateTime<Utc>>,
|
||||
}
|
||||
|
||||
#[derive(Clone)]
|
||||
|
@ -167,7 +168,7 @@ pub struct CommunityPersonBan {
|
|||
pub struct CommunityPersonBanForm {
|
||||
pub community_id: CommunityId,
|
||||
pub person_id: PersonId,
|
||||
pub expires: Option<Option<chrono::NaiveDateTime>>,
|
||||
pub expires: Option<Option<DateTime<Utc>>>,
|
||||
}
|
||||
|
||||
#[derive(PartialEq, Eq, Debug)]
|
||||
|
@ -181,7 +182,7 @@ pub struct CommunityFollower {
|
|||
pub id: i32,
|
||||
pub community_id: CommunityId,
|
||||
pub person_id: PersonId,
|
||||
pub published: chrono::NaiveDateTime,
|
||||
pub published: DateTime<Utc>,
|
||||
pub pending: bool,
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
use crate::newtypes::{CommunityBlockId, CommunityId, PersonId};
|
||||
#[cfg(feature = "full")]
|
||||
use crate::schema::community_block;
|
||||
use chrono::{DateTime, Utc};
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[derive(Clone, PartialEq, Eq, Debug, Serialize, Deserialize)]
|
||||
|
@ -14,7 +15,7 @@ pub struct CommunityBlock {
|
|||
pub id: CommunityBlockId,
|
||||
pub person_id: PersonId,
|
||||
pub community_id: CommunityId,
|
||||
pub published: chrono::NaiveDateTime,
|
||||
pub published: DateTime<Utc>,
|
||||
}
|
||||
|
||||
#[cfg_attr(feature = "full", derive(Insertable, AsChangeset))]
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
use crate::newtypes::{CustomEmojiId, DbUrl, LocalSiteId};
|
||||
#[cfg(feature = "full")]
|
||||
use crate::schema::custom_emoji;
|
||||
use chrono::{DateTime, Utc};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use serde_with::skip_serializing_none;
|
||||
#[cfg(feature = "full")]
|
||||
|
@ -24,8 +25,8 @@ pub struct CustomEmoji {
|
|||
pub image_url: DbUrl,
|
||||
pub alt_text: String,
|
||||
pub category: String,
|
||||
pub published: chrono::NaiveDateTime,
|
||||
pub updated: Option<chrono::NaiveDateTime>,
|
||||
pub published: DateTime<Utc>,
|
||||
pub updated: Option<DateTime<Utc>>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, TypedBuilder)]
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
use crate::newtypes::LocalUserId;
|
||||
#[cfg(feature = "full")]
|
||||
use crate::schema::email_verification;
|
||||
use chrono::{DateTime, Utc};
|
||||
|
||||
#[derive(Clone)]
|
||||
#[cfg_attr(feature = "full", derive(Queryable, Identifiable))]
|
||||
|
@ -10,7 +11,7 @@ pub struct EmailVerification {
|
|||
pub local_user_id: LocalUserId,
|
||||
pub email: String,
|
||||
pub verification_code: String,
|
||||
pub published: chrono::NaiveDateTime,
|
||||
pub published: DateTime<Utc>,
|
||||
}
|
||||
|
||||
#[cfg_attr(feature = "full", derive(Insertable, AsChangeset))]
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
use crate::newtypes::InstanceId;
|
||||
#[cfg(feature = "full")]
|
||||
use crate::schema::federation_allowlist;
|
||||
use chrono::{DateTime, Utc};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::fmt::Debug;
|
||||
|
||||
|
@ -14,8 +15,8 @@ use std::fmt::Debug;
|
|||
pub struct FederationAllowList {
|
||||
pub id: i32,
|
||||
pub instance_id: InstanceId,
|
||||
pub published: chrono::NaiveDateTime,
|
||||
pub updated: Option<chrono::NaiveDateTime>,
|
||||
pub published: DateTime<Utc>,
|
||||
pub updated: Option<DateTime<Utc>>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Default)]
|
||||
|
@ -23,5 +24,5 @@ pub struct FederationAllowList {
|
|||
#[cfg_attr(feature = "full", diesel(table_name = federation_allowlist))]
|
||||
pub struct FederationAllowListForm {
|
||||
pub instance_id: InstanceId,
|
||||
pub updated: Option<chrono::NaiveDateTime>,
|
||||
pub updated: Option<DateTime<Utc>>,
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
use crate::newtypes::InstanceId;
|
||||
#[cfg(feature = "full")]
|
||||
use crate::schema::federation_blocklist;
|
||||
use chrono::{DateTime, Utc};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::fmt::Debug;
|
||||
|
||||
|
@ -14,8 +15,8 @@ use std::fmt::Debug;
|
|||
pub struct FederationBlockList {
|
||||
pub id: i32,
|
||||
pub instance_id: InstanceId,
|
||||
pub published: chrono::NaiveDateTime,
|
||||
pub updated: Option<chrono::NaiveDateTime>,
|
||||
pub published: DateTime<Utc>,
|
||||
pub updated: Option<DateTime<Utc>>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Default)]
|
||||
|
@ -23,5 +24,5 @@ pub struct FederationBlockList {
|
|||
#[cfg_attr(feature = "full", diesel(table_name = federation_blocklist))]
|
||||
pub struct FederationBlockListForm {
|
||||
pub instance_id: InstanceId,
|
||||
pub updated: Option<chrono::NaiveDateTime>,
|
||||
pub updated: Option<DateTime<Utc>>,
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
use crate::newtypes::InstanceId;
|
||||
#[cfg(feature = "full")]
|
||||
use crate::schema::instance;
|
||||
use chrono::{DateTime, Utc};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use serde_with::skip_serializing_none;
|
||||
use std::fmt::Debug;
|
||||
|
@ -17,8 +18,8 @@ use typed_builder::TypedBuilder;
|
|||
pub struct Instance {
|
||||
pub id: InstanceId,
|
||||
pub domain: String,
|
||||
pub published: chrono::NaiveDateTime,
|
||||
pub updated: Option<chrono::NaiveDateTime>,
|
||||
pub published: DateTime<Utc>,
|
||||
pub updated: Option<DateTime<Utc>>,
|
||||
pub software: Option<String>,
|
||||
pub version: Option<String>,
|
||||
}
|
||||
|
@ -32,5 +33,5 @@ pub struct InstanceForm {
|
|||
pub domain: String,
|
||||
pub software: Option<String>,
|
||||
pub version: Option<String>,
|
||||
pub updated: Option<chrono::NaiveDateTime>,
|
||||
pub updated: Option<DateTime<Utc>>,
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@ use crate::{
|
|||
ListingType,
|
||||
RegistrationMode,
|
||||
};
|
||||
use chrono::{DateTime, Utc};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use serde_with::skip_serializing_none;
|
||||
#[cfg(feature = "full")]
|
||||
|
@ -54,8 +55,8 @@ pub struct LocalSite {
|
|||
pub captcha_enabled: bool,
|
||||
/// The captcha difficulty.
|
||||
pub captcha_difficulty: String,
|
||||
pub published: chrono::NaiveDateTime,
|
||||
pub updated: Option<chrono::NaiveDateTime>,
|
||||
pub published: DateTime<Utc>,
|
||||
pub updated: Option<DateTime<Utc>>,
|
||||
pub registration_mode: RegistrationMode,
|
||||
/// Whether to email admins on new reports.
|
||||
pub reports_email_admins: bool,
|
||||
|
@ -112,5 +113,5 @@ pub struct LocalSiteUpdateForm {
|
|||
pub captcha_difficulty: Option<String>,
|
||||
pub registration_mode: Option<RegistrationMode>,
|
||||
pub reports_email_admins: Option<bool>,
|
||||
pub updated: Option<Option<chrono::NaiveDateTime>>,
|
||||
pub updated: Option<Option<DateTime<Utc>>>,
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
use crate::newtypes::LocalSiteId;
|
||||
#[cfg(feature = "full")]
|
||||
use crate::schema::local_site_rate_limit;
|
||||
use chrono::{DateTime, Utc};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use serde_with::skip_serializing_none;
|
||||
#[cfg(feature = "full")]
|
||||
|
@ -32,8 +33,8 @@ pub struct LocalSiteRateLimit {
|
|||
pub comment_per_second: i32,
|
||||
pub search: i32,
|
||||
pub search_per_second: i32,
|
||||
pub published: chrono::NaiveDateTime,
|
||||
pub updated: Option<chrono::NaiveDateTime>,
|
||||
pub published: DateTime<Utc>,
|
||||
pub updated: Option<DateTime<Utc>>,
|
||||
}
|
||||
|
||||
#[derive(Clone, TypedBuilder)]
|
||||
|
@ -73,5 +74,5 @@ pub struct LocalSiteRateLimitUpdateForm {
|
|||
pub comment_per_second: Option<i32>,
|
||||
pub search: Option<i32>,
|
||||
pub search_per_second: Option<i32>,
|
||||
pub updated: Option<Option<chrono::NaiveDateTime>>,
|
||||
pub updated: Option<Option<DateTime<Utc>>>,
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@ use crate::{
|
|||
ListingType,
|
||||
SortType,
|
||||
};
|
||||
use chrono::{DateTime, Utc};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use serde_with::skip_serializing_none;
|
||||
#[cfg(feature = "full")]
|
||||
|
@ -34,7 +35,7 @@ pub struct LocalUser {
|
|||
pub show_avatars: bool,
|
||||
pub send_notifications_to_email: bool,
|
||||
/// A validation ID used in logging out sessions.
|
||||
pub validator_time: chrono::NaiveDateTime,
|
||||
pub validator_time: DateTime<Utc>,
|
||||
/// Whether to show comment / post scores.
|
||||
pub show_scores: bool,
|
||||
/// Whether to show bot accounts.
|
||||
|
|
|
@ -17,6 +17,7 @@ use crate::schema::{
|
|||
mod_remove_post,
|
||||
mod_transfer_community,
|
||||
};
|
||||
use chrono::{DateTime, Utc};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use serde_with::skip_serializing_none;
|
||||
#[cfg(feature = "full")]
|
||||
|
@ -34,7 +35,7 @@ pub struct ModRemovePost {
|
|||
pub post_id: PostId,
|
||||
pub reason: Option<String>,
|
||||
pub removed: bool,
|
||||
pub when_: chrono::NaiveDateTime,
|
||||
pub when_: DateTime<Utc>,
|
||||
}
|
||||
|
||||
#[cfg_attr(feature = "full", derive(Insertable, AsChangeset))]
|
||||
|
@ -56,7 +57,7 @@ pub struct ModLockPost {
|
|||
pub mod_person_id: PersonId,
|
||||
pub post_id: PostId,
|
||||
pub locked: bool,
|
||||
pub when_: chrono::NaiveDateTime,
|
||||
pub when_: DateTime<Utc>,
|
||||
}
|
||||
|
||||
#[cfg_attr(feature = "full", derive(Insertable, AsChangeset))]
|
||||
|
@ -77,7 +78,7 @@ pub struct ModFeaturePost {
|
|||
pub mod_person_id: PersonId,
|
||||
pub post_id: PostId,
|
||||
pub featured: bool,
|
||||
pub when_: chrono::NaiveDateTime,
|
||||
pub when_: DateTime<Utc>,
|
||||
pub is_featured_community: bool,
|
||||
}
|
||||
|
||||
|
@ -102,7 +103,7 @@ pub struct ModRemoveComment {
|
|||
pub comment_id: CommentId,
|
||||
pub reason: Option<String>,
|
||||
pub removed: bool,
|
||||
pub when_: chrono::NaiveDateTime,
|
||||
pub when_: DateTime<Utc>,
|
||||
}
|
||||
|
||||
#[cfg_attr(feature = "full", derive(Insertable, AsChangeset))]
|
||||
|
@ -126,8 +127,8 @@ pub struct ModRemoveCommunity {
|
|||
pub community_id: CommunityId,
|
||||
pub reason: Option<String>,
|
||||
pub removed: bool,
|
||||
pub expires: Option<chrono::NaiveDateTime>,
|
||||
pub when_: chrono::NaiveDateTime,
|
||||
pub expires: Option<DateTime<Utc>>,
|
||||
pub when_: DateTime<Utc>,
|
||||
}
|
||||
|
||||
#[cfg_attr(feature = "full", derive(Insertable, AsChangeset))]
|
||||
|
@ -137,7 +138,7 @@ pub struct ModRemoveCommunityForm {
|
|||
pub community_id: CommunityId,
|
||||
pub reason: Option<String>,
|
||||
pub removed: Option<bool>,
|
||||
pub expires: Option<chrono::NaiveDateTime>,
|
||||
pub expires: Option<DateTime<Utc>>,
|
||||
}
|
||||
|
||||
#[skip_serializing_none]
|
||||
|
@ -153,8 +154,8 @@ pub struct ModBanFromCommunity {
|
|||
pub community_id: CommunityId,
|
||||
pub reason: Option<String>,
|
||||
pub banned: bool,
|
||||
pub expires: Option<chrono::NaiveDateTime>,
|
||||
pub when_: chrono::NaiveDateTime,
|
||||
pub expires: Option<DateTime<Utc>>,
|
||||
pub when_: DateTime<Utc>,
|
||||
}
|
||||
|
||||
#[cfg_attr(feature = "full", derive(Insertable, AsChangeset))]
|
||||
|
@ -165,7 +166,7 @@ pub struct ModBanFromCommunityForm {
|
|||
pub community_id: CommunityId,
|
||||
pub reason: Option<String>,
|
||||
pub banned: Option<bool>,
|
||||
pub expires: Option<chrono::NaiveDateTime>,
|
||||
pub expires: Option<DateTime<Utc>>,
|
||||
}
|
||||
|
||||
#[skip_serializing_none]
|
||||
|
@ -180,8 +181,8 @@ pub struct ModBan {
|
|||
pub other_person_id: PersonId,
|
||||
pub reason: Option<String>,
|
||||
pub banned: bool,
|
||||
pub expires: Option<chrono::NaiveDateTime>,
|
||||
pub when_: chrono::NaiveDateTime,
|
||||
pub expires: Option<DateTime<Utc>>,
|
||||
pub when_: DateTime<Utc>,
|
||||
}
|
||||
|
||||
#[cfg_attr(feature = "full", derive(Insertable, AsChangeset))]
|
||||
|
@ -203,7 +204,7 @@ pub struct ModHideCommunity {
|
|||
pub id: i32,
|
||||
pub community_id: CommunityId,
|
||||
pub mod_person_id: PersonId,
|
||||
pub when_: chrono::NaiveDateTime,
|
||||
pub when_: DateTime<Utc>,
|
||||
pub reason: Option<String>,
|
||||
pub hidden: bool,
|
||||
}
|
||||
|
@ -215,7 +216,7 @@ pub struct ModBanForm {
|
|||
pub other_person_id: PersonId,
|
||||
pub reason: Option<String>,
|
||||
pub banned: Option<bool>,
|
||||
pub expires: Option<chrono::NaiveDateTime>,
|
||||
pub expires: Option<DateTime<Utc>>,
|
||||
}
|
||||
|
||||
#[derive(Clone, PartialEq, Eq, Debug, Serialize, Deserialize)]
|
||||
|
@ -229,7 +230,7 @@ pub struct ModAddCommunity {
|
|||
pub other_person_id: PersonId,
|
||||
pub community_id: CommunityId,
|
||||
pub removed: bool,
|
||||
pub when_: chrono::NaiveDateTime,
|
||||
pub when_: DateTime<Utc>,
|
||||
}
|
||||
|
||||
#[cfg_attr(feature = "full", derive(Insertable, AsChangeset))]
|
||||
|
@ -251,7 +252,7 @@ pub struct ModTransferCommunity {
|
|||
pub mod_person_id: PersonId,
|
||||
pub other_person_id: PersonId,
|
||||
pub community_id: CommunityId,
|
||||
pub when_: chrono::NaiveDateTime,
|
||||
pub when_: DateTime<Utc>,
|
||||
}
|
||||
|
||||
#[cfg_attr(feature = "full", derive(Insertable, AsChangeset))]
|
||||
|
@ -272,7 +273,7 @@ pub struct ModAdd {
|
|||
pub mod_person_id: PersonId,
|
||||
pub other_person_id: PersonId,
|
||||
pub removed: bool,
|
||||
pub when_: chrono::NaiveDateTime,
|
||||
pub when_: DateTime<Utc>,
|
||||
}
|
||||
|
||||
#[cfg_attr(feature = "full", derive(Insertable, AsChangeset))]
|
||||
|
@ -293,7 +294,7 @@ pub struct AdminPurgePerson {
|
|||
pub id: i32,
|
||||
pub admin_person_id: PersonId,
|
||||
pub reason: Option<String>,
|
||||
pub when_: chrono::NaiveDateTime,
|
||||
pub when_: DateTime<Utc>,
|
||||
}
|
||||
|
||||
#[cfg_attr(feature = "full", derive(Insertable, AsChangeset))]
|
||||
|
@ -313,7 +314,7 @@ pub struct AdminPurgeCommunity {
|
|||
pub id: i32,
|
||||
pub admin_person_id: PersonId,
|
||||
pub reason: Option<String>,
|
||||
pub when_: chrono::NaiveDateTime,
|
||||
pub when_: DateTime<Utc>,
|
||||
}
|
||||
|
||||
#[cfg_attr(feature = "full", derive(Insertable, AsChangeset))]
|
||||
|
@ -334,7 +335,7 @@ pub struct AdminPurgePost {
|
|||
pub admin_person_id: PersonId,
|
||||
pub community_id: CommunityId,
|
||||
pub reason: Option<String>,
|
||||
pub when_: chrono::NaiveDateTime,
|
||||
pub when_: DateTime<Utc>,
|
||||
}
|
||||
|
||||
#[cfg_attr(feature = "full", derive(Insertable, AsChangeset))]
|
||||
|
@ -356,7 +357,7 @@ pub struct AdminPurgeComment {
|
|||
pub admin_person_id: PersonId,
|
||||
pub post_id: PostId,
|
||||
pub reason: Option<String>,
|
||||
pub when_: chrono::NaiveDateTime,
|
||||
pub when_: DateTime<Utc>,
|
||||
}
|
||||
|
||||
#[cfg_attr(feature = "full", derive(Insertable, AsChangeset))]
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
use crate::newtypes::LocalUserId;
|
||||
#[cfg(feature = "full")]
|
||||
use crate::schema::password_reset_request;
|
||||
use chrono::{DateTime, Utc};
|
||||
|
||||
#[derive(PartialEq, Eq, Debug)]
|
||||
#[cfg_attr(feature = "full", derive(Queryable, Identifiable))]
|
||||
|
@ -8,7 +9,7 @@ use crate::schema::password_reset_request;
|
|||
pub struct PasswordResetRequest {
|
||||
pub id: i32,
|
||||
pub token: String,
|
||||
pub published: chrono::NaiveDateTime,
|
||||
pub published: DateTime<Utc>,
|
||||
pub local_user_id: LocalUserId,
|
||||
}
|
||||
|
||||
|
|
|
@ -4,6 +4,7 @@ use crate::{
|
|||
newtypes::{DbUrl, InstanceId, PersonId},
|
||||
source::placeholder_apub_url,
|
||||
};
|
||||
use chrono::{DateTime, Utc};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use serde_with::skip_serializing_none;
|
||||
#[cfg(feature = "full")]
|
||||
|
@ -25,8 +26,8 @@ pub struct Person {
|
|||
pub avatar: Option<DbUrl>,
|
||||
/// Whether the person is banned.
|
||||
pub banned: bool,
|
||||
pub published: chrono::NaiveDateTime,
|
||||
pub updated: Option<chrono::NaiveDateTime>,
|
||||
pub published: DateTime<Utc>,
|
||||
pub updated: Option<DateTime<Utc>>,
|
||||
/// The federated actor_id.
|
||||
pub actor_id: DbUrl,
|
||||
/// An optional bio, in markdown.
|
||||
|
@ -38,7 +39,7 @@ pub struct Person {
|
|||
#[serde(skip)]
|
||||
pub public_key: String,
|
||||
#[serde(skip)]
|
||||
pub last_refreshed_at: chrono::NaiveDateTime,
|
||||
pub last_refreshed_at: DateTime<Utc>,
|
||||
/// A URL for a banner.
|
||||
pub banner: Option<DbUrl>,
|
||||
/// Whether the person is deleted.
|
||||
|
@ -52,7 +53,7 @@ pub struct Person {
|
|||
/// Whether the person is a bot account.
|
||||
pub bot_account: bool,
|
||||
/// When their ban, if it exists, expires, if at all.
|
||||
pub ban_expires: Option<chrono::NaiveDateTime>,
|
||||
pub ban_expires: Option<DateTime<Utc>>,
|
||||
pub instance_id: InstanceId,
|
||||
}
|
||||
|
||||
|
@ -70,20 +71,20 @@ pub struct PersonInsertForm {
|
|||
pub display_name: Option<String>,
|
||||
pub avatar: Option<DbUrl>,
|
||||
pub banned: Option<bool>,
|
||||
pub published: Option<chrono::NaiveDateTime>,
|
||||
pub updated: Option<chrono::NaiveDateTime>,
|
||||
pub published: Option<DateTime<Utc>>,
|
||||
pub updated: Option<DateTime<Utc>>,
|
||||
pub actor_id: Option<DbUrl>,
|
||||
pub bio: Option<String>,
|
||||
pub local: Option<bool>,
|
||||
pub private_key: Option<String>,
|
||||
pub last_refreshed_at: Option<chrono::NaiveDateTime>,
|
||||
pub last_refreshed_at: Option<DateTime<Utc>>,
|
||||
pub banner: Option<DbUrl>,
|
||||
pub deleted: Option<bool>,
|
||||
pub inbox_url: Option<DbUrl>,
|
||||
pub shared_inbox_url: Option<DbUrl>,
|
||||
pub matrix_user_id: Option<String>,
|
||||
pub bot_account: Option<bool>,
|
||||
pub ban_expires: Option<chrono::NaiveDateTime>,
|
||||
pub ban_expires: Option<DateTime<Utc>>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Default)]
|
||||
|
@ -93,20 +94,20 @@ pub struct PersonUpdateForm {
|
|||
pub display_name: Option<Option<String>>,
|
||||
pub avatar: Option<Option<DbUrl>>,
|
||||
pub banned: Option<bool>,
|
||||
pub updated: Option<Option<chrono::NaiveDateTime>>,
|
||||
pub updated: Option<Option<DateTime<Utc>>>,
|
||||
pub actor_id: Option<DbUrl>,
|
||||
pub bio: Option<Option<String>>,
|
||||
pub local: Option<bool>,
|
||||
pub public_key: Option<String>,
|
||||
pub private_key: Option<Option<String>>,
|
||||
pub last_refreshed_at: Option<chrono::NaiveDateTime>,
|
||||
pub last_refreshed_at: Option<DateTime<Utc>>,
|
||||
pub banner: Option<Option<DbUrl>>,
|
||||
pub deleted: Option<bool>,
|
||||
pub inbox_url: Option<DbUrl>,
|
||||
pub shared_inbox_url: Option<Option<DbUrl>>,
|
||||
pub matrix_user_id: Option<Option<String>>,
|
||||
pub bot_account: Option<bool>,
|
||||
pub ban_expires: Option<Option<chrono::NaiveDateTime>>,
|
||||
pub ban_expires: Option<Option<DateTime<Utc>>>,
|
||||
}
|
||||
|
||||
#[derive(PartialEq, Eq, Debug)]
|
||||
|
@ -117,7 +118,7 @@ pub struct PersonFollower {
|
|||
pub id: i32,
|
||||
pub person_id: PersonId,
|
||||
pub follower_id: PersonId,
|
||||
pub published: chrono::NaiveDateTime,
|
||||
pub published: DateTime<Utc>,
|
||||
pub pending: bool,
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
use crate::newtypes::{PersonBlockId, PersonId};
|
||||
#[cfg(feature = "full")]
|
||||
use crate::schema::person_block;
|
||||
use chrono::{DateTime, Utc};
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[derive(Clone, PartialEq, Eq, Debug, Serialize, Deserialize)]
|
||||
|
@ -11,7 +12,7 @@ pub struct PersonBlock {
|
|||
pub id: PersonBlockId,
|
||||
pub person_id: PersonId,
|
||||
pub target_id: PersonId,
|
||||
pub published: chrono::NaiveDateTime,
|
||||
pub published: DateTime<Utc>,
|
||||
}
|
||||
|
||||
#[cfg_attr(feature = "full", derive(Insertable, AsChangeset))]
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
use crate::newtypes::{CommentId, PersonId, PersonMentionId};
|
||||
#[cfg(feature = "full")]
|
||||
use crate::schema::person_mention;
|
||||
use chrono::{DateTime, Utc};
|
||||
use serde::{Deserialize, Serialize};
|
||||
#[cfg(feature = "full")]
|
||||
use ts_rs::TS;
|
||||
|
@ -16,7 +17,7 @@ pub struct PersonMention {
|
|||
pub recipient_id: PersonId,
|
||||
pub comment_id: CommentId,
|
||||
pub read: bool,
|
||||
pub published: chrono::NaiveDateTime,
|
||||
pub published: DateTime<Utc>,
|
||||
}
|
||||
|
||||
#[cfg_attr(feature = "full", derive(Insertable, AsChangeset))]
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
use crate::newtypes::{CommunityId, DbUrl, LanguageId, PersonId, PostId};
|
||||
#[cfg(feature = "full")]
|
||||
use crate::schema::{post, post_like, post_read, post_saved};
|
||||
use chrono::{DateTime, Utc};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use serde_with::skip_serializing_none;
|
||||
#[cfg(feature = "full")]
|
||||
|
@ -27,8 +28,8 @@ pub struct Post {
|
|||
pub removed: bool,
|
||||
/// Whether the post is locked.
|
||||
pub locked: bool,
|
||||
pub published: chrono::NaiveDateTime,
|
||||
pub updated: Option<chrono::NaiveDateTime>,
|
||||
pub published: DateTime<Utc>,
|
||||
pub updated: Option<DateTime<Utc>>,
|
||||
/// Whether the post is deleted.
|
||||
pub deleted: bool,
|
||||
/// Whether the post is NSFW.
|
||||
|
@ -71,8 +72,8 @@ pub struct PostInsertForm {
|
|||
pub body: Option<String>,
|
||||
pub removed: Option<bool>,
|
||||
pub locked: Option<bool>,
|
||||
pub updated: Option<chrono::NaiveDateTime>,
|
||||
pub published: Option<chrono::NaiveDateTime>,
|
||||
pub updated: Option<DateTime<Utc>>,
|
||||
pub published: Option<DateTime<Utc>>,
|
||||
pub deleted: Option<bool>,
|
||||
pub embed_title: Option<String>,
|
||||
pub embed_description: Option<String>,
|
||||
|
@ -95,8 +96,8 @@ pub struct PostUpdateForm {
|
|||
pub body: Option<Option<String>>,
|
||||
pub removed: Option<bool>,
|
||||
pub locked: Option<bool>,
|
||||
pub published: Option<chrono::NaiveDateTime>,
|
||||
pub updated: Option<Option<chrono::NaiveDateTime>>,
|
||||
pub published: Option<DateTime<Utc>>,
|
||||
pub updated: Option<Option<DateTime<Utc>>>,
|
||||
pub deleted: Option<bool>,
|
||||
pub embed_title: Option<Option<String>>,
|
||||
pub embed_description: Option<Option<String>>,
|
||||
|
@ -118,7 +119,7 @@ pub struct PostLike {
|
|||
pub post_id: PostId,
|
||||
pub person_id: PersonId,
|
||||
pub score: i16,
|
||||
pub published: chrono::NaiveDateTime,
|
||||
pub published: DateTime<Utc>,
|
||||
}
|
||||
|
||||
#[derive(Clone)]
|
||||
|
@ -138,7 +139,7 @@ pub struct PostSaved {
|
|||
pub id: i32,
|
||||
pub post_id: PostId,
|
||||
pub person_id: PersonId,
|
||||
pub published: chrono::NaiveDateTime,
|
||||
pub published: DateTime<Utc>,
|
||||
}
|
||||
|
||||
#[cfg_attr(feature = "full", derive(Insertable, AsChangeset))]
|
||||
|
@ -156,7 +157,7 @@ pub struct PostRead {
|
|||
pub id: i32,
|
||||
pub post_id: PostId,
|
||||
pub person_id: PersonId,
|
||||
pub published: chrono::NaiveDateTime,
|
||||
pub published: DateTime<Utc>,
|
||||
}
|
||||
|
||||
#[cfg_attr(feature = "full", derive(Insertable, AsChangeset))]
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
use crate::newtypes::{DbUrl, PersonId, PostId, PostReportId};
|
||||
#[cfg(feature = "full")]
|
||||
use crate::schema::post_report;
|
||||
use chrono::{DateTime, Utc};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use serde_with::skip_serializing_none;
|
||||
#[cfg(feature = "full")]
|
||||
|
@ -26,8 +27,8 @@ pub struct PostReport {
|
|||
pub reason: String,
|
||||
pub resolved: bool,
|
||||
pub resolver_id: Option<PersonId>,
|
||||
pub published: chrono::NaiveDateTime,
|
||||
pub updated: Option<chrono::NaiveDateTime>,
|
||||
pub published: DateTime<Utc>,
|
||||
pub updated: Option<DateTime<Utc>>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Default)]
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
use crate::newtypes::{DbUrl, PersonId, PrivateMessageId};
|
||||
#[cfg(feature = "full")]
|
||||
use crate::schema::private_message;
|
||||
use chrono::{DateTime, Utc};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use serde_with::skip_serializing_none;
|
||||
#[cfg(feature = "full")]
|
||||
|
@ -24,8 +25,8 @@ pub struct PrivateMessage {
|
|||
pub content: String,
|
||||
pub deleted: bool,
|
||||
pub read: bool,
|
||||
pub published: chrono::NaiveDateTime,
|
||||
pub updated: Option<chrono::NaiveDateTime>,
|
||||
pub published: DateTime<Utc>,
|
||||
pub updated: Option<DateTime<Utc>>,
|
||||
pub ap_id: DbUrl,
|
||||
pub local: bool,
|
||||
}
|
||||
|
@ -43,8 +44,8 @@ pub struct PrivateMessageInsertForm {
|
|||
pub content: String,
|
||||
pub deleted: Option<bool>,
|
||||
pub read: Option<bool>,
|
||||
pub published: Option<chrono::NaiveDateTime>,
|
||||
pub updated: Option<chrono::NaiveDateTime>,
|
||||
pub published: Option<DateTime<Utc>>,
|
||||
pub updated: Option<DateTime<Utc>>,
|
||||
pub ap_id: Option<DbUrl>,
|
||||
pub local: Option<bool>,
|
||||
}
|
||||
|
@ -56,8 +57,8 @@ pub struct PrivateMessageUpdateForm {
|
|||
pub content: Option<String>,
|
||||
pub deleted: Option<bool>,
|
||||
pub read: Option<bool>,
|
||||
pub published: Option<chrono::NaiveDateTime>,
|
||||
pub updated: Option<Option<chrono::NaiveDateTime>>,
|
||||
pub published: Option<DateTime<Utc>>,
|
||||
pub updated: Option<Option<DateTime<Utc>>>,
|
||||
pub ap_id: Option<DbUrl>,
|
||||
pub local: Option<bool>,
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
use crate::newtypes::{PersonId, PrivateMessageId, PrivateMessageReportId};
|
||||
#[cfg(feature = "full")]
|
||||
use crate::schema::private_message_report;
|
||||
use chrono::{DateTime, Utc};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use serde_with::skip_serializing_none;
|
||||
#[cfg(feature = "full")]
|
||||
|
@ -25,8 +26,8 @@ pub struct PrivateMessageReport {
|
|||
pub reason: String,
|
||||
pub resolved: bool,
|
||||
pub resolver_id: Option<PersonId>,
|
||||
pub published: chrono::NaiveDateTime,
|
||||
pub updated: Option<chrono::NaiveDateTime>,
|
||||
pub published: DateTime<Utc>,
|
||||
pub updated: Option<DateTime<Utc>>,
|
||||
}
|
||||
|
||||
#[derive(Clone)]
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
use crate::newtypes::{LocalUserId, PersonId};
|
||||
#[cfg(feature = "full")]
|
||||
use crate::schema::registration_application;
|
||||
use chrono::{DateTime, Utc};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use serde_with::skip_serializing_none;
|
||||
#[cfg(feature = "full")]
|
||||
|
@ -18,7 +19,7 @@ pub struct RegistrationApplication {
|
|||
pub answer: String,
|
||||
pub admin_id: Option<PersonId>,
|
||||
pub deny_reason: Option<String>,
|
||||
pub published: chrono::NaiveDateTime,
|
||||
pub published: DateTime<Utc>,
|
||||
}
|
||||
|
||||
#[cfg_attr(feature = "full", derive(Insertable))]
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
use crate::newtypes::{DbUrl, InstanceId, SiteId};
|
||||
#[cfg(feature = "full")]
|
||||
use crate::schema::site;
|
||||
use chrono::NaiveDateTime;
|
||||
use chrono::{DateTime, Utc};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use serde_with::skip_serializing_none;
|
||||
#[cfg(feature = "full")]
|
||||
|
@ -19,8 +19,8 @@ pub struct Site {
|
|||
pub name: String,
|
||||
/// A sidebar for the site in markdown.
|
||||
pub sidebar: Option<String>,
|
||||
pub published: NaiveDateTime,
|
||||
pub updated: Option<NaiveDateTime>,
|
||||
pub published: DateTime<Utc>,
|
||||
pub updated: Option<DateTime<Utc>>,
|
||||
/// An icon URL.
|
||||
pub icon: Option<DbUrl>,
|
||||
/// A banner url.
|
||||
|
@ -30,7 +30,7 @@ pub struct Site {
|
|||
/// The federated actor_id.
|
||||
pub actor_id: DbUrl,
|
||||
/// The time the site was last refreshed.
|
||||
pub last_refreshed_at: NaiveDateTime,
|
||||
pub last_refreshed_at: DateTime<Utc>,
|
||||
/// The site inbox
|
||||
pub inbox_url: DbUrl,
|
||||
pub private_key: Option<String>,
|
||||
|
@ -46,12 +46,12 @@ pub struct SiteInsertForm {
|
|||
#[builder(!default)]
|
||||
pub name: String,
|
||||
pub sidebar: Option<String>,
|
||||
pub updated: Option<NaiveDateTime>,
|
||||
pub updated: Option<DateTime<Utc>>,
|
||||
pub icon: Option<DbUrl>,
|
||||
pub banner: Option<DbUrl>,
|
||||
pub description: Option<String>,
|
||||
pub actor_id: Option<DbUrl>,
|
||||
pub last_refreshed_at: Option<NaiveDateTime>,
|
||||
pub last_refreshed_at: Option<DateTime<Utc>>,
|
||||
pub inbox_url: Option<DbUrl>,
|
||||
pub private_key: Option<String>,
|
||||
pub public_key: Option<String>,
|
||||
|
@ -65,13 +65,13 @@ pub struct SiteInsertForm {
|
|||
pub struct SiteUpdateForm {
|
||||
pub name: Option<String>,
|
||||
pub sidebar: Option<Option<String>>,
|
||||
pub updated: Option<Option<NaiveDateTime>>,
|
||||
pub updated: Option<Option<DateTime<Utc>>>,
|
||||
// when you want to null out a column, you have to send Some(None)), since sending None means you just don't want to update that column.
|
||||
pub icon: Option<Option<DbUrl>>,
|
||||
pub banner: Option<Option<DbUrl>>,
|
||||
pub description: Option<Option<String>>,
|
||||
pub actor_id: Option<DbUrl>,
|
||||
pub last_refreshed_at: Option<NaiveDateTime>,
|
||||
pub last_refreshed_at: Option<DateTime<Utc>>,
|
||||
pub inbox_url: Option<DbUrl>,
|
||||
pub private_key: Option<Option<String>>,
|
||||
pub public_key: Option<String>,
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
use crate::newtypes::LocalSiteId;
|
||||
#[cfg(feature = "full")]
|
||||
use crate::schema::tagline;
|
||||
use chrono::{DateTime, Utc};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use serde_with::skip_serializing_none;
|
||||
#[cfg(feature = "full")]
|
||||
|
@ -20,8 +21,8 @@ pub struct Tagline {
|
|||
pub id: i32,
|
||||
pub local_site_id: LocalSiteId,
|
||||
pub content: String,
|
||||
pub published: chrono::NaiveDateTime,
|
||||
pub updated: Option<chrono::NaiveDateTime>,
|
||||
pub published: DateTime<Utc>,
|
||||
pub updated: Option<DateTime<Utc>>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Default)]
|
||||
|
@ -30,5 +31,5 @@ pub struct Tagline {
|
|||
pub struct TaglineForm {
|
||||
pub local_site_id: LocalSiteId,
|
||||
pub content: String,
|
||||
pub updated: Option<chrono::NaiveDateTime>,
|
||||
pub updated: Option<DateTime<Utc>>,
|
||||
}
|
||||
|
|
|
@ -8,15 +8,17 @@ use crate::{
|
|||
SortType,
|
||||
};
|
||||
use activitypub_federation::{fetch::object_id::ObjectId, traits::Object};
|
||||
use chrono::NaiveDateTime;
|
||||
use chrono::{DateTime, Utc};
|
||||
use deadpool::Runtime;
|
||||
use diesel::{
|
||||
backend::Backend,
|
||||
deserialize::FromSql,
|
||||
helper_types::AsExprOf,
|
||||
pg::Pg,
|
||||
result::{ConnectionError, ConnectionResult, Error as DieselError, Error::QueryBuilderError},
|
||||
serialize::{Output, ToSql},
|
||||
sql_types::Text,
|
||||
sql_types::{Text, Timestamptz},
|
||||
IntoSql,
|
||||
PgConnection,
|
||||
};
|
||||
use diesel_async::{
|
||||
|
@ -340,8 +342,8 @@ pub fn get_database_url(settings: Option<&Settings>) -> String {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn naive_now() -> NaiveDateTime {
|
||||
chrono::prelude::Utc::now().naive_utc()
|
||||
pub fn naive_now() -> DateTime<Utc> {
|
||||
chrono::prelude::Utc::now()
|
||||
}
|
||||
|
||||
pub fn post_to_comment_sort_type(sort: SortType) -> CommentSortType {
|
||||
|
@ -380,10 +382,10 @@ static EMAIL_REGEX: Lazy<Regex> = Lazy::new(|| {
|
|||
});
|
||||
|
||||
pub mod functions {
|
||||
use diesel::sql_types::{BigInt, Text, Timestamp};
|
||||
use diesel::sql_types::{BigInt, Text, Timestamptz};
|
||||
|
||||
sql_function! {
|
||||
fn hot_rank(score: BigInt, time: Timestamp) -> Integer;
|
||||
fn hot_rank(score: BigInt, time: Timestamptz) -> Integer;
|
||||
}
|
||||
|
||||
sql_function! {
|
||||
|
@ -421,6 +423,11 @@ where
|
|||
}
|
||||
}
|
||||
|
||||
pub fn now() -> AsExprOf<diesel::dsl::now, diesel::sql_types::Timestamptz> {
|
||||
// https://github.com/diesel-rs/diesel/issues/1514
|
||||
diesel::dsl::now.into_sql::<Timestamptz>()
|
||||
}
|
||||
|
||||
pub type ResultFuture<'a, T> = BoxFuture<'a, Result<T, DieselError>>;
|
||||
|
||||
pub trait ReadFn<'a, T: JoinView, Args>:
|
||||
|
|
|
@ -1,13 +1,14 @@
|
|||
use crate::structs::{LocalUserView, PostView};
|
||||
use diesel::{
|
||||
debug_query,
|
||||
dsl::{now, IntervalDsl},
|
||||
dsl::IntervalDsl,
|
||||
pg::Pg,
|
||||
result::Error,
|
||||
sql_function,
|
||||
sql_types,
|
||||
sql_types::{self, Timestamptz},
|
||||
BoolExpressionMethods,
|
||||
ExpressionMethods,
|
||||
IntoSql,
|
||||
JoinOnDsl,
|
||||
NullableExpressionMethods,
|
||||
PgTextExpressionMethods,
|
||||
|
@ -327,6 +328,7 @@ fn queries<'a>() -> Queries<
|
|||
query = query.filter(person_block::person_id.is_null());
|
||||
}
|
||||
}
|
||||
let now = diesel::dsl::now.into_sql::<Timestamptz>();
|
||||
|
||||
query = match options.sort.unwrap_or(SortType::Hot) {
|
||||
SortType::Active => query
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
use crate::structs::PersonView;
|
||||
use diesel::{
|
||||
dsl::now,
|
||||
pg::Pg,
|
||||
result::Error,
|
||||
BoolExpressionMethods,
|
||||
ExpressionMethods,
|
||||
NullableExpressionMethods,
|
||||
PgTextExpressionMethods,
|
||||
QueryDsl,
|
||||
};
|
||||
|
@ -16,7 +16,7 @@ use lemmy_db_schema::{
|
|||
schema::{local_user, person, person_aggregates},
|
||||
source::person::Person,
|
||||
traits::JoinView,
|
||||
utils::{fuzzy_search, get_conn, limit_and_offset, DbConn, DbPool, ListFn, Queries, ReadFn},
|
||||
utils::{fuzzy_search, get_conn, limit_and_offset, now, DbConn, DbPool, ListFn, Queries, ReadFn},
|
||||
PersonSortType,
|
||||
};
|
||||
|
||||
|
@ -58,7 +58,7 @@ fn queries<'a>(
|
|||
person::banned.eq(true).and(
|
||||
person::ban_expires
|
||||
.is_null()
|
||||
.or(person::ban_expires.gt(now)),
|
||||
.or(person::ban_expires.gt(now().nullable())),
|
||||
),
|
||||
)
|
||||
.filter(person::deleted.eq(false));
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
use actix_web::{error::ErrorBadRequest, web, Error, HttpRequest, HttpResponse, Result};
|
||||
use anyhow::anyhow;
|
||||
use chrono::{DateTime, NaiveDateTime, Utc};
|
||||
use chrono::{DateTime, Utc};
|
||||
use lemmy_api_common::context::LemmyContext;
|
||||
use lemmy_db_schema::{
|
||||
newtypes::LocalUserId,
|
||||
|
@ -449,7 +449,7 @@ fn create_reply_and_mention_items(
|
|||
#[tracing::instrument(skip_all)]
|
||||
fn build_item(
|
||||
creator_name: &str,
|
||||
published: &NaiveDateTime,
|
||||
published: &DateTime<Utc>,
|
||||
url: &str,
|
||||
content: &str,
|
||||
protocol_and_hostname: &str,
|
||||
|
@ -460,7 +460,7 @@ fn build_item(
|
|||
i.author(format!(
|
||||
"/u/{creator_name} <a href=\"{author_url}\">(link)</a>"
|
||||
));
|
||||
let dt = DateTime::<Utc>::from_utc(*published, Utc);
|
||||
let dt = published;
|
||||
i.pub_date(dt.to_rfc2822());
|
||||
i.comments(url.to_owned());
|
||||
let guid = GuidBuilder::default().permalink(true).value(url).build();
|
||||
|
@ -487,7 +487,7 @@ fn create_post_items(
|
|||
|
||||
dc_extension.creators(vec![p.creator.actor_id.to_string()]);
|
||||
|
||||
let dt = DateTime::<Utc>::from_utc(p.post.published, Utc);
|
||||
let dt = p.post.published;
|
||||
i.pub_date(dt.to_rfc2822());
|
||||
|
||||
let post_url = format!("{}/post/{}", protocol_and_hostname, p.post.id);
|
||||
|
|
|
@ -2,7 +2,6 @@ use crate::error::LemmyError;
|
|||
use chrono::Utc;
|
||||
use jsonwebtoken::{decode, encode, DecodingKey, EncodingKey, Header, TokenData, Validation};
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
type Jwt = String;
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize)]
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
use chrono::{DateTime, FixedOffset, NaiveDateTime};
|
||||
use chrono::{DateTime, TimeZone, Utc};
|
||||
|
||||
pub fn naive_from_unix(time: i64) -> NaiveDateTime {
|
||||
NaiveDateTime::from_timestamp_opt(time, 0).expect("convert datetime")
|
||||
pub fn naive_from_unix(time: i64) -> DateTime<Utc> {
|
||||
Utc
|
||||
.timestamp_opt(time, 0)
|
||||
.single()
|
||||
.expect("convert datetime")
|
||||
}
|
||||
|
||||
pub fn convert_datetime(datetime: NaiveDateTime) -> DateTime<FixedOffset> {
|
||||
DateTime::<FixedOffset>::from_utc(
|
||||
datetime,
|
||||
FixedOffset::east_opt(0).expect("create fixed offset"),
|
||||
)
|
||||
pub fn convert_datetime(datetime: DateTime<Utc>) -> DateTime<Utc> {
|
||||
datetime
|
||||
}
|
||||
|
|
346
migrations/2023-08-02-174444_fix-timezones/down.sql
Normal file
346
migrations/2023-08-02-174444_fix-timezones/down.sql
Normal file
|
@ -0,0 +1,346 @@
|
|||
SET timezone TO utc;
|
||||
|
||||
ALTER TABLE community_moderator
|
||||
ALTER COLUMN published TYPE timestamp
|
||||
USING published;
|
||||
|
||||
ALTER TABLE community_follower
|
||||
ALTER COLUMN published TYPE timestamp
|
||||
USING published;
|
||||
|
||||
ALTER TABLE person_ban
|
||||
ALTER COLUMN published TYPE timestamp
|
||||
USING published;
|
||||
|
||||
ALTER TABLE community_person_ban
|
||||
ALTER COLUMN published TYPE timestamp
|
||||
USING published;
|
||||
|
||||
ALTER TABLE community_person_ban
|
||||
ALTER COLUMN expires TYPE timestamp
|
||||
USING expires;
|
||||
|
||||
ALTER TABLE person
|
||||
ALTER COLUMN published TYPE timestamp
|
||||
USING published;
|
||||
|
||||
ALTER TABLE person
|
||||
ALTER COLUMN updated TYPE timestamp
|
||||
USING updated;
|
||||
|
||||
ALTER TABLE person
|
||||
ALTER COLUMN last_refreshed_at TYPE timestamp
|
||||
USING last_refreshed_at;
|
||||
|
||||
ALTER TABLE person
|
||||
ALTER COLUMN ban_expires TYPE timestamp
|
||||
USING ban_expires;
|
||||
|
||||
ALTER TABLE post_like
|
||||
ALTER COLUMN published TYPE timestamp
|
||||
USING published;
|
||||
|
||||
ALTER TABLE post_saved
|
||||
ALTER COLUMN published TYPE timestamp
|
||||
USING published;
|
||||
|
||||
ALTER TABLE post_read
|
||||
ALTER COLUMN published TYPE timestamp
|
||||
USING published;
|
||||
|
||||
ALTER TABLE comment_like
|
||||
ALTER COLUMN published TYPE timestamp
|
||||
USING published;
|
||||
|
||||
ALTER TABLE comment_saved
|
||||
ALTER COLUMN published TYPE timestamp
|
||||
USING published;
|
||||
|
||||
ALTER TABLE comment
|
||||
ALTER COLUMN published TYPE timestamp
|
||||
USING published;
|
||||
|
||||
ALTER TABLE comment
|
||||
ALTER COLUMN updated TYPE timestamp
|
||||
USING updated;
|
||||
|
||||
ALTER TABLE mod_remove_post
|
||||
ALTER COLUMN when_ TYPE timestamp
|
||||
USING when_;
|
||||
|
||||
ALTER TABLE mod_lock_post
|
||||
ALTER COLUMN when_ TYPE timestamp
|
||||
USING when_;
|
||||
|
||||
ALTER TABLE mod_remove_comment
|
||||
ALTER COLUMN when_ TYPE timestamp
|
||||
USING when_;
|
||||
|
||||
ALTER TABLE mod_remove_community
|
||||
ALTER COLUMN expires TYPE timestamp
|
||||
USING expires;
|
||||
|
||||
ALTER TABLE mod_remove_community
|
||||
ALTER COLUMN when_ TYPE timestamp
|
||||
USING when_;
|
||||
|
||||
ALTER TABLE mod_ban_from_community
|
||||
ALTER COLUMN expires TYPE timestamp
|
||||
USING expires;
|
||||
|
||||
ALTER TABLE mod_ban_from_community
|
||||
ALTER COLUMN when_ TYPE timestamp
|
||||
USING when_;
|
||||
|
||||
ALTER TABLE mod_ban
|
||||
ALTER COLUMN expires TYPE timestamp
|
||||
USING expires;
|
||||
|
||||
ALTER TABLE mod_ban
|
||||
ALTER COLUMN when_ TYPE timestamp
|
||||
USING when_;
|
||||
|
||||
ALTER TABLE mod_add_community
|
||||
ALTER COLUMN when_ TYPE timestamp
|
||||
USING when_;
|
||||
|
||||
ALTER TABLE mod_add
|
||||
ALTER COLUMN when_ TYPE timestamp
|
||||
USING when_;
|
||||
|
||||
ALTER TABLE person_mention
|
||||
ALTER COLUMN published TYPE timestamp
|
||||
USING published;
|
||||
|
||||
ALTER TABLE mod_feature_post
|
||||
ALTER COLUMN when_ TYPE timestamp
|
||||
USING when_;
|
||||
|
||||
ALTER TABLE password_reset_request
|
||||
ALTER COLUMN published TYPE timestamp
|
||||
USING published;
|
||||
|
||||
ALTER TABLE private_message
|
||||
ALTER COLUMN published TYPE timestamp
|
||||
USING published;
|
||||
|
||||
ALTER TABLE private_message
|
||||
ALTER COLUMN updated TYPE timestamp
|
||||
USING updated;
|
||||
|
||||
ALTER TABLE sent_activity
|
||||
ALTER COLUMN published TYPE timestamp
|
||||
USING published;
|
||||
|
||||
ALTER TABLE received_activity
|
||||
ALTER COLUMN published TYPE timestamp
|
||||
USING published;
|
||||
|
||||
ALTER TABLE community
|
||||
ALTER COLUMN published TYPE timestamp
|
||||
USING published;
|
||||
|
||||
ALTER TABLE community
|
||||
ALTER COLUMN updated TYPE timestamp
|
||||
USING updated;
|
||||
|
||||
ALTER TABLE community
|
||||
ALTER COLUMN last_refreshed_at TYPE timestamp
|
||||
USING last_refreshed_at;
|
||||
|
||||
ALTER TABLE post
|
||||
ALTER COLUMN published TYPE timestamp
|
||||
USING published;
|
||||
|
||||
ALTER TABLE post
|
||||
ALTER COLUMN updated TYPE timestamp
|
||||
USING updated;
|
||||
|
||||
ALTER TABLE comment_report
|
||||
ALTER COLUMN published TYPE timestamp
|
||||
USING published;
|
||||
|
||||
ALTER TABLE comment_report
|
||||
ALTER COLUMN updated TYPE timestamp
|
||||
USING updated;
|
||||
|
||||
ALTER TABLE post_report
|
||||
ALTER COLUMN published TYPE timestamp
|
||||
USING published;
|
||||
|
||||
ALTER TABLE post_report
|
||||
ALTER COLUMN updated TYPE timestamp
|
||||
USING updated;
|
||||
|
||||
ALTER TABLE post_aggregates
|
||||
ALTER COLUMN published TYPE timestamp
|
||||
USING published;
|
||||
|
||||
ALTER TABLE post_aggregates
|
||||
ALTER COLUMN newest_comment_time_necro TYPE timestamp
|
||||
USING newest_comment_time_necro;
|
||||
|
||||
ALTER TABLE post_aggregates
|
||||
ALTER COLUMN newest_comment_time TYPE timestamp
|
||||
USING newest_comment_time;
|
||||
|
||||
ALTER TABLE comment_aggregates
|
||||
ALTER COLUMN published TYPE timestamp
|
||||
USING published;
|
||||
|
||||
ALTER TABLE community_block
|
||||
ALTER COLUMN published TYPE timestamp
|
||||
USING published;
|
||||
|
||||
ALTER TABLE community_aggregates
|
||||
ALTER COLUMN published TYPE timestamp
|
||||
USING published;
|
||||
|
||||
ALTER TABLE mod_transfer_community
|
||||
ALTER COLUMN when_ TYPE timestamp
|
||||
USING when_;
|
||||
|
||||
ALTER TABLE person_block
|
||||
ALTER COLUMN published TYPE timestamp
|
||||
USING published;
|
||||
|
||||
ALTER TABLE local_user
|
||||
ALTER COLUMN validator_time TYPE timestamp
|
||||
USING validator_time;
|
||||
|
||||
ALTER TABLE admin_purge_person
|
||||
ALTER COLUMN when_ TYPE timestamp
|
||||
USING when_;
|
||||
|
||||
ALTER TABLE email_verification
|
||||
ALTER COLUMN published TYPE timestamp
|
||||
USING published;
|
||||
|
||||
ALTER TABLE admin_purge_community
|
||||
ALTER COLUMN when_ TYPE timestamp
|
||||
USING when_;
|
||||
|
||||
ALTER TABLE admin_purge_post
|
||||
ALTER COLUMN when_ TYPE timestamp
|
||||
USING when_;
|
||||
|
||||
ALTER TABLE admin_purge_comment
|
||||
ALTER COLUMN when_ TYPE timestamp
|
||||
USING when_;
|
||||
|
||||
ALTER TABLE registration_application
|
||||
ALTER COLUMN published TYPE timestamp
|
||||
USING published;
|
||||
|
||||
ALTER TABLE mod_hide_community
|
||||
ALTER COLUMN when_ TYPE timestamp
|
||||
USING when_;
|
||||
|
||||
ALTER TABLE site
|
||||
ALTER COLUMN published TYPE timestamp
|
||||
USING published;
|
||||
|
||||
ALTER TABLE site
|
||||
ALTER COLUMN updated TYPE timestamp
|
||||
USING updated;
|
||||
|
||||
ALTER TABLE site
|
||||
ALTER COLUMN last_refreshed_at TYPE timestamp
|
||||
USING last_refreshed_at;
|
||||
|
||||
ALTER TABLE comment_reply
|
||||
ALTER COLUMN published TYPE timestamp
|
||||
USING published;
|
||||
|
||||
ALTER TABLE person_post_aggregates
|
||||
ALTER COLUMN published TYPE timestamp
|
||||
USING published;
|
||||
|
||||
ALTER TABLE private_message_report
|
||||
ALTER COLUMN published TYPE timestamp
|
||||
USING published;
|
||||
|
||||
ALTER TABLE private_message_report
|
||||
ALTER COLUMN updated TYPE timestamp
|
||||
USING updated;
|
||||
|
||||
ALTER TABLE local_site
|
||||
ALTER COLUMN published TYPE timestamp
|
||||
USING published;
|
||||
|
||||
ALTER TABLE local_site
|
||||
ALTER COLUMN updated TYPE timestamp
|
||||
USING updated;
|
||||
|
||||
ALTER TABLE federation_allowlist
|
||||
ALTER COLUMN published TYPE timestamp
|
||||
USING published;
|
||||
|
||||
ALTER TABLE federation_allowlist
|
||||
ALTER COLUMN updated TYPE timestamp
|
||||
USING updated;
|
||||
|
||||
ALTER TABLE federation_blocklist
|
||||
ALTER COLUMN published TYPE timestamp
|
||||
USING published;
|
||||
|
||||
ALTER TABLE federation_blocklist
|
||||
ALTER COLUMN updated TYPE timestamp
|
||||
USING updated;
|
||||
|
||||
ALTER TABLE local_site_rate_limit
|
||||
ALTER COLUMN published TYPE timestamp
|
||||
USING published;
|
||||
|
||||
ALTER TABLE local_site_rate_limit
|
||||
ALTER COLUMN updated TYPE timestamp
|
||||
USING updated;
|
||||
|
||||
ALTER TABLE person_follower
|
||||
ALTER COLUMN published TYPE timestamp
|
||||
USING published;
|
||||
|
||||
ALTER TABLE tagline
|
||||
ALTER COLUMN published TYPE timestamp
|
||||
USING published;
|
||||
|
||||
ALTER TABLE tagline
|
||||
ALTER COLUMN updated TYPE timestamp
|
||||
USING updated;
|
||||
|
||||
ALTER TABLE custom_emoji
|
||||
ALTER COLUMN published TYPE timestamp
|
||||
USING published;
|
||||
|
||||
ALTER TABLE custom_emoji
|
||||
ALTER COLUMN updated TYPE timestamp
|
||||
USING updated;
|
||||
|
||||
ALTER TABLE instance
|
||||
ALTER COLUMN published TYPE timestamp
|
||||
USING published;
|
||||
|
||||
ALTER TABLE instance
|
||||
ALTER COLUMN updated TYPE timestamp
|
||||
USING updated;
|
||||
|
||||
ALTER TABLE captcha_answer
|
||||
ALTER COLUMN published TYPE timestamp
|
||||
USING published;
|
||||
|
||||
CREATE OR REPLACE FUNCTION hot_rank (score numeric, published timestamp without time zone)
|
||||
RETURNS integer
|
||||
AS $$
|
||||
DECLARE
|
||||
hours_diff numeric := EXTRACT(EPOCH FROM (timezone('utc', now()) - published)) / 3600;
|
||||
BEGIN
|
||||
IF (hours_diff > 0) THEN
|
||||
RETURN floor(10000 * log(greatest (1, score + 3)) / power((hours_diff + 2), 1.8))::integer;
|
||||
ELSE
|
||||
RETURN 0;
|
||||
END IF;
|
||||
END;
|
||||
$$
|
||||
LANGUAGE plpgsql
|
||||
IMMUTABLE PARALLEL SAFE;
|
||||
|
351
migrations/2023-08-02-174444_fix-timezones/up.sql
Normal file
351
migrations/2023-08-02-174444_fix-timezones/up.sql
Normal file
|
@ -0,0 +1,351 @@
|
|||
SET timezone = 'UTC';
|
||||
|
||||
-- Allow ALTER TABLE ... SET DATA TYPE changing between timestamp and timestamptz to avoid a table rewrite when the session time zone is UTC (Noah Misch)
|
||||
-- In the UTC time zone, these two data types are binary compatible.
|
||||
ALTER TABLE community_moderator
|
||||
ALTER COLUMN published TYPE timestamptz
|
||||
USING published;
|
||||
|
||||
ALTER TABLE community_follower
|
||||
ALTER COLUMN published TYPE timestamptz
|
||||
USING published;
|
||||
|
||||
ALTER TABLE person_ban
|
||||
ALTER COLUMN published TYPE timestamptz
|
||||
USING published;
|
||||
|
||||
ALTER TABLE community_person_ban
|
||||
ALTER COLUMN published TYPE timestamptz
|
||||
USING published;
|
||||
|
||||
ALTER TABLE community_person_ban
|
||||
ALTER COLUMN expires TYPE timestamptz
|
||||
USING expires;
|
||||
|
||||
ALTER TABLE person
|
||||
ALTER COLUMN published TYPE timestamptz
|
||||
USING published;
|
||||
|
||||
ALTER TABLE person
|
||||
ALTER COLUMN updated TYPE timestamptz
|
||||
USING updated;
|
||||
|
||||
ALTER TABLE person
|
||||
ALTER COLUMN last_refreshed_at TYPE timestamptz
|
||||
USING last_refreshed_at;
|
||||
|
||||
ALTER TABLE person
|
||||
ALTER COLUMN ban_expires TYPE timestamptz
|
||||
USING ban_expires;
|
||||
|
||||
ALTER TABLE post_like
|
||||
ALTER COLUMN published TYPE timestamptz
|
||||
USING published;
|
||||
|
||||
ALTER TABLE post_saved
|
||||
ALTER COLUMN published TYPE timestamptz
|
||||
USING published;
|
||||
|
||||
ALTER TABLE post_read
|
||||
ALTER COLUMN published TYPE timestamptz
|
||||
USING published;
|
||||
|
||||
ALTER TABLE comment_like
|
||||
ALTER COLUMN published TYPE timestamptz
|
||||
USING published;
|
||||
|
||||
ALTER TABLE comment_saved
|
||||
ALTER COLUMN published TYPE timestamptz
|
||||
USING published;
|
||||
|
||||
ALTER TABLE comment
|
||||
ALTER COLUMN published TYPE timestamptz
|
||||
USING published;
|
||||
|
||||
ALTER TABLE comment
|
||||
ALTER COLUMN updated TYPE timestamptz
|
||||
USING updated;
|
||||
|
||||
ALTER TABLE mod_remove_post
|
||||
ALTER COLUMN when_ TYPE timestamptz
|
||||
USING when_;
|
||||
|
||||
ALTER TABLE mod_lock_post
|
||||
ALTER COLUMN when_ TYPE timestamptz
|
||||
USING when_;
|
||||
|
||||
ALTER TABLE mod_remove_comment
|
||||
ALTER COLUMN when_ TYPE timestamptz
|
||||
USING when_;
|
||||
|
||||
ALTER TABLE mod_remove_community
|
||||
ALTER COLUMN expires TYPE timestamptz
|
||||
USING expires;
|
||||
|
||||
ALTER TABLE mod_remove_community
|
||||
ALTER COLUMN when_ TYPE timestamptz
|
||||
USING when_;
|
||||
|
||||
ALTER TABLE mod_ban_from_community
|
||||
ALTER COLUMN expires TYPE timestamptz
|
||||
USING expires;
|
||||
|
||||
ALTER TABLE mod_ban_from_community
|
||||
ALTER COLUMN when_ TYPE timestamptz
|
||||
USING when_;
|
||||
|
||||
ALTER TABLE mod_ban
|
||||
ALTER COLUMN expires TYPE timestamptz
|
||||
USING expires;
|
||||
|
||||
ALTER TABLE mod_ban
|
||||
ALTER COLUMN when_ TYPE timestamptz
|
||||
USING when_;
|
||||
|
||||
ALTER TABLE mod_add_community
|
||||
ALTER COLUMN when_ TYPE timestamptz
|
||||
USING when_;
|
||||
|
||||
ALTER TABLE mod_add
|
||||
ALTER COLUMN when_ TYPE timestamptz
|
||||
USING when_;
|
||||
|
||||
ALTER TABLE person_mention
|
||||
ALTER COLUMN published TYPE timestamptz
|
||||
USING published;
|
||||
|
||||
ALTER TABLE mod_feature_post
|
||||
ALTER COLUMN when_ TYPE timestamptz
|
||||
USING when_;
|
||||
|
||||
ALTER TABLE password_reset_request
|
||||
ALTER COLUMN published TYPE timestamptz
|
||||
USING published;
|
||||
|
||||
ALTER TABLE private_message
|
||||
ALTER COLUMN published TYPE timestamptz
|
||||
USING published;
|
||||
|
||||
ALTER TABLE private_message
|
||||
ALTER COLUMN updated TYPE timestamptz
|
||||
USING updated;
|
||||
|
||||
ALTER TABLE sent_activity
|
||||
ALTER COLUMN published TYPE timestamptz
|
||||
USING published;
|
||||
|
||||
ALTER TABLE received_activity
|
||||
ALTER COLUMN published TYPE timestamptz
|
||||
USING published;
|
||||
|
||||
ALTER TABLE community
|
||||
ALTER COLUMN published TYPE timestamptz
|
||||
USING published;
|
||||
|
||||
ALTER TABLE community
|
||||
ALTER COLUMN updated TYPE timestamptz
|
||||
USING updated;
|
||||
|
||||
ALTER TABLE community
|
||||
ALTER COLUMN last_refreshed_at TYPE timestamptz
|
||||
USING last_refreshed_at;
|
||||
|
||||
ALTER TABLE post
|
||||
ALTER COLUMN published TYPE timestamptz
|
||||
USING published;
|
||||
|
||||
ALTER TABLE post
|
||||
ALTER COLUMN updated TYPE timestamptz
|
||||
USING updated;
|
||||
|
||||
ALTER TABLE comment_report
|
||||
ALTER COLUMN published TYPE timestamptz
|
||||
USING published;
|
||||
|
||||
ALTER TABLE comment_report
|
||||
ALTER COLUMN updated TYPE timestamptz
|
||||
USING updated;
|
||||
|
||||
ALTER TABLE post_report
|
||||
ALTER COLUMN published TYPE timestamptz
|
||||
USING published;
|
||||
|
||||
ALTER TABLE post_report
|
||||
ALTER COLUMN updated TYPE timestamptz
|
||||
USING updated;
|
||||
|
||||
ALTER TABLE post_aggregates
|
||||
ALTER COLUMN published TYPE timestamptz
|
||||
USING published;
|
||||
|
||||
ALTER TABLE post_aggregates
|
||||
ALTER COLUMN newest_comment_time_necro TYPE timestamptz
|
||||
USING newest_comment_time_necro;
|
||||
|
||||
ALTER TABLE post_aggregates
|
||||
ALTER COLUMN newest_comment_time TYPE timestamptz
|
||||
USING newest_comment_time;
|
||||
|
||||
ALTER TABLE comment_aggregates
|
||||
ALTER COLUMN published TYPE timestamptz
|
||||
USING published;
|
||||
|
||||
ALTER TABLE community_block
|
||||
ALTER COLUMN published TYPE timestamptz
|
||||
USING published;
|
||||
|
||||
ALTER TABLE community_aggregates
|
||||
ALTER COLUMN published TYPE timestamptz
|
||||
USING published;
|
||||
|
||||
ALTER TABLE mod_transfer_community
|
||||
ALTER COLUMN when_ TYPE timestamptz
|
||||
USING when_;
|
||||
|
||||
ALTER TABLE person_block
|
||||
ALTER COLUMN published TYPE timestamptz
|
||||
USING published;
|
||||
|
||||
ALTER TABLE local_user
|
||||
ALTER COLUMN validator_time TYPE timestamptz
|
||||
USING validator_time;
|
||||
|
||||
ALTER TABLE admin_purge_person
|
||||
ALTER COLUMN when_ TYPE timestamptz
|
||||
USING when_;
|
||||
|
||||
ALTER TABLE email_verification
|
||||
ALTER COLUMN published TYPE timestamptz
|
||||
USING published;
|
||||
|
||||
ALTER TABLE admin_purge_community
|
||||
ALTER COLUMN when_ TYPE timestamptz
|
||||
USING when_;
|
||||
|
||||
ALTER TABLE admin_purge_post
|
||||
ALTER COLUMN when_ TYPE timestamptz
|
||||
USING when_;
|
||||
|
||||
ALTER TABLE admin_purge_comment
|
||||
ALTER COLUMN when_ TYPE timestamptz
|
||||
USING when_;
|
||||
|
||||
ALTER TABLE registration_application
|
||||
ALTER COLUMN published TYPE timestamptz
|
||||
USING published;
|
||||
|
||||
ALTER TABLE mod_hide_community
|
||||
ALTER COLUMN when_ TYPE timestamptz
|
||||
USING when_;
|
||||
|
||||
ALTER TABLE site
|
||||
ALTER COLUMN published TYPE timestamptz
|
||||
USING published;
|
||||
|
||||
ALTER TABLE site
|
||||
ALTER COLUMN updated TYPE timestamptz
|
||||
USING updated;
|
||||
|
||||
ALTER TABLE site
|
||||
ALTER COLUMN last_refreshed_at TYPE timestamptz
|
||||
USING last_refreshed_at;
|
||||
|
||||
ALTER TABLE comment_reply
|
||||
ALTER COLUMN published TYPE timestamptz
|
||||
USING published;
|
||||
|
||||
ALTER TABLE person_post_aggregates
|
||||
ALTER COLUMN published TYPE timestamptz
|
||||
USING published;
|
||||
|
||||
ALTER TABLE private_message_report
|
||||
ALTER COLUMN published TYPE timestamptz
|
||||
USING published;
|
||||
|
||||
ALTER TABLE private_message_report
|
||||
ALTER COLUMN updated TYPE timestamptz
|
||||
USING updated;
|
||||
|
||||
ALTER TABLE local_site
|
||||
ALTER COLUMN published TYPE timestamptz
|
||||
USING published;
|
||||
|
||||
ALTER TABLE local_site
|
||||
ALTER COLUMN updated TYPE timestamptz
|
||||
USING updated;
|
||||
|
||||
ALTER TABLE federation_allowlist
|
||||
ALTER COLUMN published TYPE timestamptz
|
||||
USING published;
|
||||
|
||||
ALTER TABLE federation_allowlist
|
||||
ALTER COLUMN updated TYPE timestamptz
|
||||
USING updated;
|
||||
|
||||
ALTER TABLE federation_blocklist
|
||||
ALTER COLUMN published TYPE timestamptz
|
||||
USING published;
|
||||
|
||||
ALTER TABLE federation_blocklist
|
||||
ALTER COLUMN updated TYPE timestamptz
|
||||
USING updated;
|
||||
|
||||
ALTER TABLE local_site_rate_limit
|
||||
ALTER COLUMN published TYPE timestamptz
|
||||
USING published;
|
||||
|
||||
ALTER TABLE local_site_rate_limit
|
||||
ALTER COLUMN updated TYPE timestamptz
|
||||
USING updated;
|
||||
|
||||
ALTER TABLE person_follower
|
||||
ALTER COLUMN published TYPE timestamptz
|
||||
USING published;
|
||||
|
||||
ALTER TABLE tagline
|
||||
ALTER COLUMN published TYPE timestamptz
|
||||
USING published;
|
||||
|
||||
ALTER TABLE tagline
|
||||
ALTER COLUMN updated TYPE timestamptz
|
||||
USING updated;
|
||||
|
||||
ALTER TABLE custom_emoji
|
||||
ALTER COLUMN published TYPE timestamptz
|
||||
USING published;
|
||||
|
||||
ALTER TABLE custom_emoji
|
||||
ALTER COLUMN updated TYPE timestamptz
|
||||
USING updated;
|
||||
|
||||
ALTER TABLE instance
|
||||
ALTER COLUMN published TYPE timestamptz
|
||||
USING published;
|
||||
|
||||
ALTER TABLE instance
|
||||
ALTER COLUMN updated TYPE timestamptz
|
||||
USING updated;
|
||||
|
||||
ALTER TABLE captcha_answer
|
||||
ALTER COLUMN published TYPE timestamptz
|
||||
USING published;
|
||||
|
||||
-- same as before just with time zone argument
|
||||
CREATE OR REPLACE FUNCTION hot_rank (score numeric, published timestamp with time zone)
|
||||
RETURNS integer
|
||||
AS $$
|
||||
DECLARE
|
||||
hours_diff numeric := EXTRACT(EPOCH FROM (now() - published)) / 3600;
|
||||
BEGIN
|
||||
IF (hours_diff > 0) THEN
|
||||
RETURN floor(10000 * log(greatest (1, score + 3)) / power((hours_diff + 2), 1.8))::integer;
|
||||
ELSE
|
||||
-- if the post is from the future, set hot score to 0. otherwise you can game the post to
|
||||
-- always be on top even with only 1 vote by setting it to the future
|
||||
RETURN 0;
|
||||
END IF;
|
||||
END;
|
||||
$$
|
||||
LANGUAGE plpgsql
|
||||
IMMUTABLE PARALLEL SAFE;
|
||||
|
|
@ -1,8 +1,8 @@
|
|||
use chrono::NaiveDateTime;
|
||||
use chrono::{DateTime, TimeZone, Utc};
|
||||
use clokwerk::{Scheduler, TimeUnits as CTimeUnits};
|
||||
use diesel::{
|
||||
dsl::{now, IntervalDsl},
|
||||
sql_types::{Integer, Timestamp},
|
||||
dsl::IntervalDsl,
|
||||
sql_types::{Integer, Timestamptz},
|
||||
Connection,
|
||||
ExpressionMethods,
|
||||
NullableExpressionMethods,
|
||||
|
@ -24,7 +24,7 @@ use lemmy_db_schema::{
|
|||
sent_activity,
|
||||
},
|
||||
source::instance::{Instance, InstanceForm},
|
||||
utils::{naive_now, DELETED_REPLACEMENT_TEXT},
|
||||
utils::{naive_now, now, DELETED_REPLACEMENT_TEXT},
|
||||
};
|
||||
use lemmy_routes::nodeinfo::NodeInfo;
|
||||
use lemmy_utils::{
|
||||
|
@ -181,8 +181,8 @@ fn update_hot_ranks(conn: &mut PgConnection) {
|
|||
|
||||
#[derive(QueryableByName)]
|
||||
struct HotRanksUpdateResult {
|
||||
#[diesel(sql_type = Timestamp)]
|
||||
published: NaiveDateTime,
|
||||
#[diesel(sql_type = Timestamptz)]
|
||||
published: DateTime<Utc>,
|
||||
}
|
||||
|
||||
/// Runs the hot rank update query in batches until all rows have been processed.
|
||||
|
@ -195,7 +195,10 @@ fn process_hot_ranks_in_batches(
|
|||
where_clause: &str,
|
||||
set_clause: &str,
|
||||
) {
|
||||
let process_start_time = NaiveDateTime::from_timestamp_opt(0, 0).expect("0 timestamp creation");
|
||||
let process_start_time: DateTime<Utc> = Utc
|
||||
.timestamp_opt(0, 0)
|
||||
.single()
|
||||
.expect("0 timestamp creation");
|
||||
|
||||
let update_batch_size = 1000; // Bigger batches than this tend to cause seq scans
|
||||
let mut processed_rows_count = 0;
|
||||
|
@ -217,7 +220,7 @@ fn process_hot_ranks_in_batches(
|
|||
set_clause = set_clause,
|
||||
where_clause = where_clause
|
||||
))
|
||||
.bind::<Timestamp, _>(previous_batch_last_published)
|
||||
.bind::<Timestamptz, _>(previous_batch_last_published)
|
||||
.bind::<Integer, _>(update_batch_size)
|
||||
.get_results::<HotRanksUpdateResult>(conn);
|
||||
|
||||
|
@ -240,7 +243,7 @@ fn process_hot_ranks_in_batches(
|
|||
|
||||
fn delete_expired_captcha_answers(conn: &mut PgConnection) {
|
||||
diesel::delete(
|
||||
captcha_answer::table.filter(captcha_answer::published.lt(now - IntervalDsl::minutes(10))),
|
||||
captcha_answer::table.filter(captcha_answer::published.lt(now() - IntervalDsl::minutes(10))),
|
||||
)
|
||||
.execute(conn)
|
||||
.map(|_| {
|
||||
|
@ -253,13 +256,13 @@ fn delete_expired_captcha_answers(conn: &mut PgConnection) {
|
|||
/// Clear old activities (this table gets very large)
|
||||
fn clear_old_activities(conn: &mut PgConnection) {
|
||||
info!("Clearing old activities...");
|
||||
diesel::delete(sent_activity::table.filter(sent_activity::published.lt(now - 3.months())))
|
||||
diesel::delete(sent_activity::table.filter(sent_activity::published.lt(now() - 3.months())))
|
||||
.execute(conn)
|
||||
.map_err(|e| error!("Failed to clear old sent activities: {e}"))
|
||||
.ok();
|
||||
|
||||
diesel::delete(
|
||||
received_activity::table.filter(received_activity::published.lt(now - 3.months())),
|
||||
received_activity::table.filter(received_activity::published.lt(now() - 3.months())),
|
||||
)
|
||||
.execute(conn)
|
||||
.map(|_| info!("Done."))
|
||||
|
@ -273,7 +276,7 @@ fn overwrite_deleted_posts_and_comments(conn: &mut PgConnection) {
|
|||
diesel::update(
|
||||
post::table
|
||||
.filter(post::deleted.eq(true))
|
||||
.filter(post::updated.lt(now.nullable() - 1.months()))
|
||||
.filter(post::updated.lt(now().nullable() - 1.months()))
|
||||
.filter(post::body.ne(DELETED_REPLACEMENT_TEXT)),
|
||||
)
|
||||
.set((
|
||||
|
@ -291,7 +294,7 @@ fn overwrite_deleted_posts_and_comments(conn: &mut PgConnection) {
|
|||
diesel::update(
|
||||
comment::table
|
||||
.filter(comment::deleted.eq(true))
|
||||
.filter(comment::updated.lt(now.nullable() - 1.months()))
|
||||
.filter(comment::updated.lt(now().nullable() - 1.months()))
|
||||
.filter(comment::content.ne(DELETED_REPLACEMENT_TEXT)),
|
||||
)
|
||||
.set(comment::content.eq(DELETED_REPLACEMENT_TEXT))
|
||||
|
@ -341,17 +344,19 @@ fn update_banned_when_expired(conn: &mut PgConnection) {
|
|||
diesel::update(
|
||||
person::table
|
||||
.filter(person::banned.eq(true))
|
||||
.filter(person::ban_expires.lt(now)),
|
||||
.filter(person::ban_expires.lt(now().nullable())),
|
||||
)
|
||||
.set(person::banned.eq(false))
|
||||
.execute(conn)
|
||||
.map_err(|e| error!("Failed to update person.banned when expires: {e}"))
|
||||
.ok();
|
||||
|
||||
diesel::delete(community_person_ban::table.filter(community_person_ban::expires.lt(now)))
|
||||
.execute(conn)
|
||||
.map_err(|e| error!("Failed to remove community_ban expired rows: {e}"))
|
||||
.ok();
|
||||
diesel::delete(
|
||||
community_person_ban::table.filter(community_person_ban::expires.lt(now().nullable())),
|
||||
)
|
||||
.execute(conn)
|
||||
.map_err(|e| error!("Failed to remove community_ban expired rows: {e}"))
|
||||
.ok();
|
||||
}
|
||||
|
||||
/// Updates the instance software and version
|
||||
|
|
Loading…
Reference in a new issue