Merge branch 'main' into add_post_view_mode

This commit is contained in:
Dessalines 2023-08-24 11:47:53 -04:00
commit 9b21c62a39
137 changed files with 1692 additions and 661 deletions

View file

@ -29,7 +29,7 @@ variables:
# recursive: true
# submodule_update_remote: true
pipeline:
steps:
prepare_repo:
image: alpine:3
commands:

32
Cargo.lock generated
View file

@ -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",
@ -1603,6 +1603,15 @@ version = "1.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "90e5c1c8368803113bf0c9584fc495a58b86dc8a29edbf8fe877d21d9507e797"
[[package]]
name = "elementtree"
version = "1.2.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3efd4742acf458718a6456e0adf0b4d734d6b783e452bbf1ac36bf31f4085cb3"
dependencies = [
"string_cache",
]
[[package]]
name = "email-encoding"
version = "0.2.0"
@ -2581,6 +2590,7 @@ dependencies = [
"bcrypt",
"captcha",
"chrono",
"elementtree",
"lemmy_api_common",
"lemmy_db_schema",
"lemmy_db_views",
@ -2589,8 +2599,10 @@ dependencies = [
"lemmy_utils",
"serde",
"serial_test",
"sitemap-rs",
"tokio",
"tracing",
"url",
"uuid",
"wav",
]
@ -4745,6 +4757,16 @@ version = "0.3.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7bd3e3206899af3f8b12af284fafc038cc1dc2b41d1b89dd17297221c5d225de"
[[package]]
name = "sitemap-rs"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "95b58125f0ab4317b5ba3cdc1f60696e47958760e356874c759334fa56ae1596"
dependencies = [
"chrono",
"xml-builder",
]
[[package]]
name = "skeptic"
version = "0.13.7"
@ -6132,6 +6154,12 @@ dependencies = [
"winapi",
]
[[package]]
name = "xml-builder"
version = "0.5.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "efc4f1a86af7800dfc4056c7833648ea4515ae21502060b5c98114d828f5333b"
[[package]]
name = "xml5ever"
version = "0.17.0"

View file

@ -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"

View file

@ -21,6 +21,7 @@ import {
registerUser,
API,
getPosts,
getCommunityByName,
} from "./shared";
beforeAll(async () => {
@ -279,3 +280,20 @@ test("moderator view", async () => {
expect(postIds).toContain(alphaPost.post.id);
expect(postIds).toContain(otherAlphaPost.post.id);
});
test("Get community for different casing on domain", async () => {
let communityRes = await createCommunity(alpha);
expect(communityRes.community_view.community.name).toBeDefined();
// A dupe check
let prevName = communityRes.community_view.community.name;
await expect(createCommunity(alpha, prevName)).rejects.toBe(
"community_already_exists",
);
// Cache the community on beta, make sure it has the other fields
let communityName = `${communityRes.community_view.community.name}@LEMMY-ALPHA:8541`;
let betaCommunity = (await getCommunityByName(beta, communityName))
.community_view;
assertCommunityFederation(betaCommunity, communityRes.community_view);
});

View file

@ -557,6 +557,17 @@ export async function getCommunity(
return api.client.getCommunity(form);
}
export async function getCommunityByName(
api: API,
name: string,
): Promise<CommunityResponse> {
let form: GetCommunity = {
name,
auth: api.auth,
};
return api.client.getCommunity(form);
}
export async function deleteCommunity(
api: API,
deleted: boolean,

View file

@ -31,8 +31,11 @@ captcha = { workspace = true }
anyhow = { workspace = true }
tracing = { workspace = true }
chrono = { workspace = true }
url = { workspace = true }
wav = "1.0.0"
sitemap-rs = "0.2.0"
[dev-dependencies]
serial_test = { workspace = true }
tokio = { workspace = true }
elementtree = "1.2.3"

View file

@ -17,7 +17,7 @@ pub async fn list_comment_reports(
let local_user_view = local_user_view_from_jwt(&data.auth, &context).await?;
let community_id = data.community_id;
let unresolved_only = data.unresolved_only;
let unresolved_only = data.unresolved_only.unwrap_or_default();
let page = data.page;
let limit = data.limit;
@ -27,7 +27,7 @@ pub async fn list_comment_reports(
page,
limit,
}
.list(&mut context.pool(), &local_user_view.person)
.list(&mut context.pool(), &local_user_view)
.await?;
Ok(Json(ListCommentReportsResponse { comment_reports }))

View file

@ -28,7 +28,7 @@ pub async fn add_mod_to_community(
// Verify that only mods or admins can add mod
is_mod_or_admin(&mut context.pool(), local_user_view.person.id, community_id).await?;
let community = Community::read(&mut context.pool(), community_id).await?;
if local_user_view.person.admin && !community.local {
if local_user_view.local_user.admin && !community.local {
return Err(LemmyErrorType::NotAModerator)?;
}

View file

@ -52,7 +52,7 @@ pub async fn block_community(
}
let community_view =
CommunityView::read(&mut context.pool(), community_id, Some(person_id), None).await?;
CommunityView::read(&mut context.pool(), community_id, Some(person_id), false).await?;
ActivityChannel::submit_activity(
SendActivityData::FollowCommunity(

View file

@ -61,7 +61,7 @@ pub async fn follow_community(
let community_id = data.community_id;
let person_id = local_user_view.person.id;
let community_view =
CommunityView::read(&mut context.pool(), community_id, Some(person_id), None).await?;
CommunityView::read(&mut context.pool(), community_id, Some(person_id), false).await?;
let discussion_languages = CommunityLanguage::read(&mut context.pool(), community_id).await?;
Ok(Json(CommunityResponse {

View file

@ -84,7 +84,7 @@ impl Perform for TransferCommunity {
let community_id = data.community_id;
let person_id = local_user_view.person.id;
let community_view =
CommunityView::read(&mut context.pool(), community_id, Some(person_id), None)
CommunityView::read(&mut context.pool(), community_id, Some(person_id), false)
.await
.with_lemmy_type(LemmyErrorType::CouldntFindCommunity)?;

View file

@ -18,6 +18,7 @@ pub mod post_report;
pub mod private_message;
pub mod private_message_report;
pub mod site;
pub mod sitemap;
#[async_trait::async_trait(?Send)]
pub trait Perform {

View file

@ -7,8 +7,8 @@ use lemmy_api_common::{
};
use lemmy_db_schema::{
source::{
local_user::{LocalUser, LocalUserUpdateForm},
moderator::{ModAdd, ModAddForm},
person::{Person, PersonUpdateForm},
},
traits::Crud,
};
@ -27,13 +27,11 @@ impl Perform for AddAdmin {
// Make sure user is an admin
is_admin(&local_user_view)?;
let added = data.added;
let added_person_id = data.person_id;
let added_admin = Person::update(
let added_admin = LocalUser::update(
&mut context.pool(),
added_person_id,
&PersonUpdateForm {
admin: Some(added),
data.local_user_id,
&LocalUserUpdateForm {
admin: Some(data.added),
..Default::default()
},
)
@ -43,7 +41,7 @@ impl Perform for AddAdmin {
// Mod tables
let form = ModAddForm {
mod_person_id: local_user_view.person.id,
other_person_id: added_admin.id,
other_person_id: added_admin.person_id,
removed: Some(!data.added),
};

View file

@ -9,6 +9,7 @@ use lemmy_db_schema::{
source::person_block::{PersonBlock, PersonBlockForm},
traits::Blockable,
};
use lemmy_db_views::structs::LocalUserView;
use lemmy_db_views_actor::structs::PersonView;
use lemmy_utils::error::{LemmyError, LemmyErrorExt, LemmyErrorType};
@ -34,9 +35,8 @@ impl Perform for BlockPerson {
target_id,
};
let target_person_view = PersonView::read(&mut context.pool(), target_id).await?;
if target_person_view.person.admin {
let target_user = LocalUserView::read_person(&mut context.pool(), target_id).await;
if target_user.map(|t| t.local_user.admin) == Ok(true) {
return Err(LemmyErrorType::CantBlockAdmin)?;
}
@ -50,8 +50,9 @@ impl Perform for BlockPerson {
.with_lemmy_type(LemmyErrorType::PersonBlockAlreadyExists)?;
}
let person_view = PersonView::read(&mut context.pool(), target_id).await?;
Ok(BlockPersonResponse {
person_view: target_person_view,
person_view,
blocked: data.block,
})
}

View file

@ -47,7 +47,7 @@ impl Perform for Login {
// Check if the user's email is verified if email verification is turned on
// However, skip checking verification if the user is an admin
if !local_user_view.person.admin
if !local_user_view.local_user.admin
&& site_view.local_site.require_email_verification
&& !local_user_view.local_user.email_verified
{

View file

@ -23,9 +23,9 @@ impl Perform for GetPersonMentions {
let sort = data.sort;
let page = data.page;
let limit = data.limit;
let unread_only = data.unread_only;
let unread_only = data.unread_only.unwrap_or_default();
let person_id = Some(local_user_view.person.id);
let show_bot_accounts = Some(local_user_view.local_user.show_bot_accounts);
let show_bot_accounts = local_user_view.local_user.show_bot_accounts;
let mentions = PersonMentionQuery {
recipient_id: person_id,

View file

@ -20,9 +20,9 @@ impl Perform for GetReplies {
let sort = data.sort;
let page = data.page;
let limit = data.limit;
let unread_only = data.unread_only;
let unread_only = data.unread_only.unwrap_or_default();
let person_id = Some(local_user_view.person.id);
let show_bot_accounts = Some(local_user_view.local_user.show_bot_accounts);
let show_bot_accounts = local_user_view.local_user.show_bot_accounts;
let replies = CommentReplyQuery {
recipient_id: person_id,

View file

@ -21,7 +21,7 @@ impl Perform for GetReportCount {
let local_user_view = local_user_view_from_jwt(&data.auth, context).await?;
let person_id = local_user_view.person.id;
let admin = local_user_view.person.admin;
let admin = local_user_view.local_user.admin;
let community_id = data.community_id;
let comment_reports =

View file

@ -28,7 +28,7 @@ impl Perform for MarkPostAsRead {
}
// Fetch it
let post_view = PostView::read(&mut context.pool(), post_id, Some(person_id), None).await?;
let post_view = PostView::read(&mut context.pool(), post_id, Some(person_id), false).await?;
Ok(Self::Response { post_view })
}

View file

@ -38,7 +38,7 @@ impl Perform for SavePost {
let post_id = data.post_id;
let person_id = local_user_view.person.id;
let post_view = PostView::read(&mut context.pool(), post_id, Some(person_id), None).await?;
let post_view = PostView::read(&mut context.pool(), post_id, Some(person_id), false).await?;
// Mark the post as read
mark_post_as_read(person_id, post_id, &mut context.pool()).await?;

View file

@ -36,7 +36,7 @@ pub async fn create_post_report(
let person_id = local_user_view.person.id;
let post_id = data.post_id;
let post_view = PostView::read(&mut context.pool(), post_id, None, None).await?;
let post_view = PostView::read(&mut context.pool(), post_id, None, false).await?;
check_community_ban(person_id, post_view.community.id, &mut context.pool()).await?;

View file

@ -23,7 +23,7 @@ impl Perform for ListPostReports {
let local_user_view = local_user_view_from_jwt(&data.auth, context).await?;
let community_id = data.community_id;
let unresolved_only = data.unresolved_only;
let unresolved_only = data.unresolved_only.unwrap_or_default();
let page = data.page;
let limit = data.limit;
@ -33,7 +33,7 @@ impl Perform for ListPostReports {
page,
limit,
}
.list(&mut context.pool(), &local_user_view.person)
.list(&mut context.pool(), &local_user_view)
.await?;
Ok(ListPostReportsResponse { post_reports })

View file

@ -18,7 +18,7 @@ impl Perform for ListPrivateMessageReports {
is_admin(&local_user_view)?;
let unresolved_only = self.unresolved_only;
let unresolved_only = self.unresolved_only.unwrap_or_default();
let page = self.page;
let limit = self.limit;
let private_message_reports = PrivateMessageReportQuery {

View file

@ -9,8 +9,8 @@ use lemmy_db_schema::{
source::{
actor_language::SiteLanguage,
language::Language,
local_user::{LocalUser, LocalUserUpdateForm},
moderator::{ModAdd, ModAddForm},
person::{Person, PersonUpdateForm},
tagline::Tagline,
},
traits::Crud,
@ -39,11 +39,10 @@ impl Perform for LeaveAdmin {
return Err(LemmyErrorType::CannotLeaveAdmin)?;
}
let person_id = local_user_view.person.id;
Person::update(
LocalUser::update(
&mut context.pool(),
person_id,
&PersonUpdateForm {
local_user_view.local_user.id,
&LocalUserUpdateForm {
admin: Some(false),
..Default::default()
},
@ -51,6 +50,7 @@ impl Perform for LeaveAdmin {
.await?;
// Mod tables
let person_id = local_user_view.person.id;
let form = ModAddForm {
mod_person_id: person_id,
other_person_id: person_id,

View file

@ -22,8 +22,8 @@ impl Perform for ListRegistrationApplications {
// Make sure user is an admin
is_admin(&local_user_view)?;
let unread_only = data.unread_only;
let verified_email_only = Some(local_site.require_email_verification);
let unread_only = data.unread_only.unwrap_or_default();
let verified_email_only = local_site.require_email_verification;
let page = data.page;
let limit = data.limit;

142
crates/api/src/sitemap.rs Normal file
View file

@ -0,0 +1,142 @@
use actix_web::{
http::header::{self, CacheDirective},
web::Data,
HttpResponse,
};
use chrono::{DateTime, FixedOffset};
use lemmy_api_common::context::LemmyContext;
use lemmy_db_schema::{newtypes::DbUrl, source::post::Post};
use lemmy_utils::error::LemmyResult;
use sitemap_rs::{url::Url, url_set::UrlSet};
use tracing::info;
async fn generate_urlset(posts: Vec<(DbUrl, chrono::NaiveDateTime)>) -> LemmyResult<UrlSet> {
let urls = posts
.into_iter()
.map_while(|post| {
Url::builder(post.0.to_string())
.last_modified(DateTime::from_utc(
post.1,
FixedOffset::east_opt(0).expect("Error setting timezone offset"), // TODO what is the proper timezone offset here?
))
.build()
.ok()
})
.collect();
Ok(UrlSet::new(urls)?)
}
pub async fn get_sitemap(context: Data<LemmyContext>) -> LemmyResult<HttpResponse> {
info!("Generating sitemap with posts from last {} hours...", 24);
let posts = Post::list_for_sitemap(&mut context.pool()).await?;
info!("Loaded latest {} posts", posts.len());
let mut buf = Vec::<u8>::new();
generate_urlset(posts).await?.write(&mut buf)?;
Ok(
HttpResponse::Ok()
.content_type("application/xml")
.insert_header(header::CacheControl(vec![CacheDirective::MaxAge(86_400)])) // 24 h
.body(buf),
)
}
#[cfg(test)]
pub(crate) mod tests {
#![allow(clippy::unwrap_used)]
use crate::sitemap::generate_urlset;
use chrono::{NaiveDate, NaiveDateTime};
use elementtree::Element;
use lemmy_db_schema::newtypes::DbUrl;
use url::Url;
#[tokio::test]
async fn test_generate_urlset() {
let posts: Vec<(DbUrl, NaiveDateTime)> = vec![
(
Url::parse("https://example.com").unwrap().into(),
NaiveDate::from_ymd_opt(2022, 12, 1)
.unwrap()
.and_hms_opt(9, 10, 11)
.unwrap(),
),
(
Url::parse("https://lemmy.ml").unwrap().into(),
NaiveDate::from_ymd_opt(2023, 1, 1)
.unwrap()
.and_hms_opt(1, 2, 3)
.unwrap(),
),
];
let mut buf = Vec::<u8>::new();
generate_urlset(posts)
.await
.unwrap()
.write(&mut buf)
.unwrap();
let root = Element::from_reader(buf.as_slice()).unwrap();
assert_eq!(root.tag().name(), "urlset");
assert_eq!(root.child_count(), 2);
assert!(root.children().all(|url| url.tag().name() == "url"));
assert!(root.children().all(|url| url.child_count() == 2));
assert!(root.children().all(|url| url
.children()
.next()
.is_some_and(|element| element.tag().name() == "loc")));
assert!(root.children().all(|url| url
.children()
.nth(1)
.is_some_and(|element| element.tag().name() == "lastmod")));
assert_eq!(
root
.children()
.next()
.unwrap()
.children()
.find(|element| element.tag().name() == "loc")
.unwrap()
.text(),
"https://example.com/"
);
assert_eq!(
root
.children()
.next()
.unwrap()
.children()
.find(|element| element.tag().name() == "lastmod")
.unwrap()
.text(),
"2022-12-01T09:10:11+00:00"
);
assert_eq!(
root
.children()
.nth(1)
.unwrap()
.children()
.find(|element| element.tag().name() == "loc")
.unwrap()
.text(),
"https://lemmy.ml/"
);
assert_eq!(
root
.children()
.nth(1)
.unwrap()
.children()
.find(|element| element.tag().name() == "lastmod")
.unwrap()
.text(),
"2023-01-01T01:02:03+00:00"
);
}
}

View file

@ -50,7 +50,7 @@ pub async fn build_community_response(
&mut context.pool(),
community_id,
Some(person_id),
Some(is_mod_or_admin),
is_mod_or_admin,
)
.await?;
let discussion_languages = CommunityLanguage::read(&mut context.pool(), community_id).await?;
@ -74,7 +74,7 @@ pub async fn build_post_response(
&mut context.pool(),
post_id,
Some(person_id),
Some(is_mod_or_admin),
is_mod_or_admin,
)
.await?;
Ok(Json(PostResponse { post_view }))

View file

@ -1,6 +1,6 @@
use crate::sensitive::Sensitive;
use lemmy_db_schema::{
newtypes::{CommentReplyId, CommunityId, LanguageId, PersonId, PersonMentionId},
newtypes::{CommentReplyId, CommunityId, LanguageId, LocalUserId, PersonId, PersonMentionId},
CommentSortType,
ListingType,
SortType,
@ -207,7 +207,7 @@ pub struct MarkAllAsRead {
#[cfg_attr(feature = "full", ts(export))]
/// Adds an admin to a site.
pub struct AddAdmin {
pub person_id: PersonId,
pub local_user_id: LocalUserId,
pub added: bool,
pub auth: Sensitive<String>,
}

View file

@ -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},
@ -78,8 +78,8 @@ pub async fn is_mod_or_admin_opt(
}
pub fn is_admin(local_user_view: &LocalUserView) -> Result<(), LemmyError> {
if !local_user_view.person.admin {
Err(LemmyErrorType::NotAnAdmin)?;
if !local_user_view.local_user.admin {
return Err(LemmyErrorType::NotAnAdmin)?;
}
Ok(())
}
@ -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
@ -500,7 +500,7 @@ pub async fn check_registration_application(
if (local_site.registration_mode == RegistrationMode::RequireApplication
|| local_site.registration_mode == RegistrationMode::Closed)
&& !local_user_view.local_user.accepted_application
&& !local_user_view.person.admin
&& !local_user_view.local_user.admin
{
// Fetch the registration, see if its denied
let local_user_id = local_user_view.local_user.id;

View file

@ -15,13 +15,16 @@ pub async fn list_communities(
) -> Result<Json<ListCommunitiesResponse>, LemmyError> {
let local_user_view = local_user_view_from_jwt_opt(data.auth.as_ref(), &context).await;
let local_site = LocalSite::read(&mut context.pool()).await?;
let is_admin = local_user_view.as_ref().map(|luv| is_admin(luv).is_ok());
let is_admin = local_user_view
.as_ref()
.map(|luv| is_admin(luv).is_ok())
.unwrap_or_default();
check_private_instance(&local_user_view, &local_site)?;
let sort = data.sort;
let listing_type = data.type_;
let show_nsfw = data.show_nsfw;
let show_nsfw = data.show_nsfw.unwrap_or_default();
let page = data.page;
let limit = data.limit;
let local_user = local_user_view.map(|l| l.local_user);

View file

@ -52,14 +52,9 @@ pub async fn get_post(
.await
.is_ok();
let post_view = PostView::read(
&mut context.pool(),
post_id,
person_id,
Some(is_mod_or_admin),
)
.await
.with_lemmy_type(LemmyErrorType::CouldntFindPost)?;
let post_view = PostView::read(&mut context.pool(), post_id, person_id, is_mod_or_admin)
.await
.with_lemmy_type(LemmyErrorType::CouldntFindPost)?;
// Mark the post as read
let post_id = post_view.post.id;
@ -72,7 +67,7 @@ pub async fn get_post(
&mut context.pool(),
community_id,
person_id,
Some(is_mod_or_admin),
is_mod_or_admin,
)
.await
.with_lemmy_type(LemmyErrorType::CouldntFindCommunity)?;

View file

@ -17,7 +17,7 @@ pub async fn get_private_message(
let page = data.page;
let limit = data.limit;
let unread_only = data.unread_only;
let unread_only = data.unread_only.unwrap_or_default();
let creator_id = data.creator_id;
let mut messages = PrivateMessageQuery {
page,

View file

@ -115,8 +115,6 @@ pub async fn register(
.public_key(actor_keypair.public_key)
.inbox_url(Some(generate_inbox_url(&actor_id)?))
.shared_inbox_url(Some(generate_shared_inbox_url(&actor_id)?))
// If its the initial site setup, they are an admin
.admin(Some(!local_site.site_setup))
.instance_id(site_view.site.instance_id)
.build();
@ -137,6 +135,8 @@ pub async fn register(
.show_nsfw(Some(data.show_nsfw))
.accepted_application(accepted_application)
.default_listing_type(Some(local_site.default_post_listing_type))
// If its the initial site setup, they are an admin
.admin(Some(!local_site.site_setup))
.build();
let inserted_local_user = LocalUser::create(&mut context.pool(), &local_user_form).await?;

View file

@ -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"
}

View file

@ -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"],

View file

@ -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",

View file

@ -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",

View file

@ -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",

View file

@ -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",

View file

@ -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"
}

View file

@ -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",

View file

@ -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"

View file

@ -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"],

View file

@ -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"
}

View file

@ -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"
}

View file

@ -26,5 +26,5 @@
"name": "Español"
}
],
"published": "2022-01-19T21:52:11.110741+00:00"
"published": "2022-01-19T21:52:11.110741Z"
}

View file

@ -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"
}

View file

@ -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"
}

View file

@ -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",

View file

@ -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?;

View file

@ -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,

View file

@ -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? {

View file

@ -97,7 +97,9 @@ pub(crate) async fn verify_person_in_community(
) -> Result<(), LemmyError> {
let person = person_id.dereference(context).await?;
if person.banned {
return Err(LemmyErrorType::PersonIsBannedFromSite)?;
return Err(LemmyErrorType::PersonIsBannedFromSite(
person.actor_id.to_string(),
))?;
}
let person_id = person.id;
let community_id = community.id;

View file

@ -34,11 +34,11 @@ pub async fn list_comments(
};
let sort = data.sort;
let max_depth = data.max_depth;
let saved_only = data.saved_only;
let saved_only = data.saved_only.unwrap_or_default();
let liked_only = data.liked_only;
let disliked_only = data.disliked_only;
if liked_only.unwrap_or_default() && disliked_only.unwrap_or_default() {
let liked_only = data.liked_only.unwrap_or_default();
let disliked_only = data.disliked_only.unwrap_or_default();
if liked_only && disliked_only {
return Err(LemmyError::from(LemmyErrorType::ContradictingFilters));
}

View file

@ -34,15 +34,15 @@ pub async fn list_posts(
} else {
data.community_id
};
let saved_only = data.saved_only;
let saved_only = data.saved_only.unwrap_or_default();
let liked_only = data.liked_only;
let disliked_only = data.disliked_only;
if liked_only.unwrap_or_default() && disliked_only.unwrap_or_default() {
let liked_only = data.liked_only.unwrap_or_default();
let disliked_only = data.disliked_only.unwrap_or_default();
if liked_only && disliked_only {
return Err(LemmyError::from(LemmyErrorType::ContradictingFilters));
}
let moderator_view = data.moderator_view;
let moderator_view = data.moderator_view.unwrap_or_default();
let listing_type = Some(listing_type_with_default(
data.type_,

View file

@ -54,7 +54,7 @@ pub async fn get_community(
&mut context.pool(),
community_id,
person_id,
Some(is_mod_or_admin),
is_mod_or_admin,
)
.await
.with_lemmy_type(LemmyErrorType::CouldntFindCommunity)?;

View file

@ -50,11 +50,11 @@ pub async fn read_person(
let sort = data.sort;
let page = data.page;
let limit = data.limit;
let saved_only = data.saved_only;
let saved_only = data.saved_only.unwrap_or_default();
let community_id = data.community_id;
// If its saved only, you don't care what creator it was
// Or, if its not saved, then you only want it for that specific creator
let creator_id = if !saved_only.unwrap_or(false) {
let creator_id = if !saved_only {
Some(person_details_id)
} else {
None

View file

@ -58,11 +58,11 @@ async fn convert_response(
}
Community(c) => {
removed_or_deleted = c.deleted || c.removed;
res.community = Some(CommunityView::read(pool, c.id, user_id, None).await?)
res.community = Some(CommunityView::read(pool, c.id, user_id, false).await?)
}
Post(p) => {
removed_or_deleted = p.deleted || p.removed;
res.post = Some(PostView::read(pool, p.id, user_id, None).await?)
res.post = Some(PostView::read(pool, p.id, user_id, false).await?)
}
Comment(c) => {
removed_or_deleted = c.deleted || c.removed;

View file

@ -25,7 +25,10 @@ pub async fn search(
check_private_instance(&local_user_view, &local_site)?;
let is_admin = local_user_view.as_ref().map(|luv| is_admin(luv).is_ok());
let is_admin = local_user_view
.as_ref()
.map(|luv| is_admin(luv).is_ok())
.unwrap_or_default();
let mut posts = Vec::new();
let mut comments = Vec::new();

View file

@ -46,7 +46,7 @@ where
Ok(actor?.into())
} else if local_user_view.is_some() {
// Fetch the actor from its home instance using webfinger
let actor: ActorType = webfinger_resolve_actor(identifier, context).await?;
let actor: ActorType = webfinger_resolve_actor(&identifier.to_lowercase(), context).await?;
Ok(actor)
} else {
Err(NotFound.into())

View file

@ -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
}

View file

@ -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(),

View file

@ -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,

View file

@ -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(())
}
@ -84,7 +85,7 @@ fn check_apub_id_valid(apub_id: &Url, local_site_data: &LocalSiteData) -> Result
if local_site_data
.blocked_instances
.iter()
.any(|i| domain.eq(&i.domain))
.any(|i| domain.to_lowercase().eq(&i.domain.to_lowercase()))
{
Err(LemmyErrorType::DomainBlocked(domain.clone()))?;
}
@ -94,7 +95,7 @@ fn check_apub_id_valid(apub_id: &Url, local_site_data: &LocalSiteData) -> Result
&& !local_site_data
.allowed_instances
.iter()
.any(|i| domain.eq(&i.domain))
.any(|i| domain.to_lowercase().eq(&i.domain.to_lowercase()))
{
Err(LemmyErrorType::DomainNotInAllowList(domain))?;
}

View file

@ -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,

View file

@ -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)
}

View file

@ -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,

View file

@ -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,12 +158,11 @@ 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),
admin: Some(false),
bot_account: Some(person.kind == UserTypes::Service),
private_key: None,
public_key: person.public_key.public_key_pem,

View file

@ -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()
};

View file

@ -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
}
@ -107,7 +107,9 @@ impl Object for ApubPrivateMessage {
check_apub_id_valid_with_strictness(note.id.inner(), false, context).await?;
let person = note.attributed_to.dereference(context).await?;
if person.banned {
return Err(LemmyErrorType::PersonIsBannedFromSite)?;
return Err(LemmyErrorType::PersonIsBannedFromSite(
person.actor_id.to_string(),
))?;
}
Ok(())
}
@ -128,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()),

View file

@ -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]

View file

@ -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

View file

@ -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()),

View file

@ -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>>,
}

View file

@ -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

View file

@ -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>>,
}

View file

@ -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>>,
}

View file

@ -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)]

View file

@ -3,7 +3,7 @@ index 255c6422..f2ccf5e2 100644
--- a/crates/db_schema/src/schema.rs
+++ b/crates/db_schema/src/schema.rs
@@ -76,13 +76,13 @@ diesel::table! {
published -> Timestamp,
published -> Timestamptz,
}
}

View file

@ -334,7 +334,7 @@ impl ApubActor for Community {
community::table
.inner_join(instance::table)
.filter(lower(community::name).eq(community_name.to_lowercase()))
.filter(instance::domain.eq(for_domain))
.filter(lower(instance::domain).eq(for_domain.to_lowercase()))
.select(community::all_columns)
.first::<Self>(conn)
.await

View file

@ -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
}

View file

@ -3,12 +3,12 @@ use crate::{
newtypes::InstanceId,
schema::{federation_allowlist, federation_blocklist, instance, local_site, site},
source::instance::{Instance, InstanceForm},
utils::{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,
};
@ -23,7 +23,7 @@ impl Instance {
// First try to read the instance row and return directly if found
let instance = instance::table
.filter(domain.eq(&domain_))
.filter(lower(domain).eq(&domain_.to_lowercase()))
.first::<Self>(conn)
.await;
match instance {
@ -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; }

View file

@ -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

View file

@ -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 {
@ -141,7 +142,7 @@ impl ApubActor for Person {
person::table
.inner_join(instance::table)
.filter(lower(person::name).eq(person_name.to_lowercase()))
.filter(instance::domain.eq(for_domain))
.filter(lower(instance::domain).eq(for_domain.to_lowercase()))
.select(person::all_columns)
.first::<Self>(conn)
.await
@ -240,7 +241,6 @@ mod tests {
bio: None,
local: true,
bot_account: false,
admin: false,
private_key: None,
public_key: "nada".to_owned(),
last_refreshed_at: inserted_person.published,

View file

@ -1,3 +1,4 @@
use super::instance::coalesce;
use crate::{
newtypes::{CommunityId, DbUrl, PersonId, PostId},
schema::post::dsl::{
@ -7,6 +8,7 @@ use crate::{
creator_id,
deleted,
featured_community,
local,
name,
post,
published,
@ -30,6 +32,7 @@ use crate::{
utils::{get_conn, naive_now, DbPool, DELETED_REPLACEMENT_TEXT, FETCH_LIMIT_MAX},
};
use ::url::Url;
use chrono::{Duration, Utc};
use diesel::{dsl::insert_into, result::Error, ExpressionMethods, QueryDsl, TextExpressionMethods};
use diesel_async::RunQueryDsl;
@ -96,6 +99,21 @@ impl Post {
.await
}
pub async fn list_for_sitemap(
pool: &mut DbPool<'_>,
) -> Result<Vec<(DbUrl, chrono::NaiveDateTime)>, Error> {
let conn = &mut get_conn(pool).await?;
post
.select((ap_id, coalesce(updated, published)))
.filter(local)
.filter(deleted.eq(false))
.filter(removed.eq(false))
.filter(published.ge(Utc::now().naive_utc() - Duration::days(1)))
.order(published.desc())
.load::<(DbUrl, chrono::NaiveDateTime)>(conn)
.await
}
pub async fn permadelete_for_creator(
pool: &mut DbPool<'_>,
for_creator_id: PersonId,

View file

@ -1,25 +1,25 @@
// @generated automatically by Diesel CLI.
pub mod sql_types {
#[derive(diesel::sql_types::SqlType)]
#[diesel(postgres_type(name = "listing_type_enum"))]
pub struct ListingTypeEnum;
#[derive(diesel::sql_types::SqlType)]
#[diesel(postgres_type(name = "listing_type_enum"))]
pub struct ListingTypeEnum;
#[derive(diesel::sql_types::SqlType)]
#[diesel(postgres_type(name = "ltree"))]
pub struct Ltree;
#[derive(diesel::sql_types::SqlType)]
#[diesel(postgres_type(name = "ltree"))]
pub struct Ltree;
#[derive(diesel::sql_types::SqlType)]
#[diesel(postgres_type(name = "post_listing_mode_enum"))]
pub struct PostListingModeEnum;
#[derive(diesel::sql_types::SqlType)]
#[diesel(postgres_type(name = "post_listing_mode_enum"))]
pub struct PostListingModeEnum;
#[derive(diesel::sql_types::SqlType)]
#[diesel(postgres_type(name = "registration_mode_enum"))]
pub struct RegistrationModeEnum;
#[derive(diesel::sql_types::SqlType)]
#[diesel(postgres_type(name = "registration_mode_enum"))]
pub struct RegistrationModeEnum;
#[derive(diesel::sql_types::SqlType)]
#[diesel(postgres_type(name = "sort_type_enum"))]
pub struct SortTypeEnum;
#[derive(diesel::sql_types::SqlType)]
#[diesel(postgres_type(name = "sort_type_enum"))]
pub struct SortTypeEnum;
}
diesel::table! {
@ -28,7 +28,7 @@ diesel::table! {
admin_person_id -> Int4,
post_id -> Int4,
reason -> Nullable<Text>,
when_ -> Timestamp,
when_ -> Timestamptz,
}
}
@ -37,7 +37,7 @@ diesel::table! {
id -> Int4,
admin_person_id -> Int4,
reason -> Nullable<Text>,
when_ -> Timestamp,
when_ -> Timestamptz,
}
}
@ -46,7 +46,7 @@ diesel::table! {
id -> Int4,
admin_person_id -> Int4,
reason -> Nullable<Text>,
when_ -> Timestamp,
when_ -> Timestamptz,
}
}
@ -56,7 +56,7 @@ diesel::table! {
admin_person_id -> Int4,
community_id -> Int4,
reason -> Nullable<Text>,
when_ -> Timestamp,
when_ -> Timestamptz,
}
}
@ -65,7 +65,7 @@ diesel::table! {
id -> Int4,
uuid -> Uuid,
answer -> Text,
published -> Timestamp,
published -> Timestamptz,
}
}
@ -79,8 +79,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,
@ -98,7 +98,7 @@ diesel::table! {
score -> Int8,
upvotes -> Int8,
downvotes -> Int8,
published -> Timestamp,
published -> Timestamptz,
child_count -> Int4,
hot_rank -> Int4,
controversy_rank -> Float8,
@ -112,7 +112,7 @@ diesel::table! {
comment_id -> Int4,
post_id -> Int4,
score -> Int2,
published -> Timestamp,
published -> Timestamptz,
}
}
@ -122,7 +122,7 @@ diesel::table! {
recipient_id -> Int4,
comment_id -> Int4,
read -> Bool,
published -> Timestamp,
published -> Timestamptz,
}
}
@ -135,8 +135,8 @@ diesel::table! {
reason -> Text,
resolved -> Bool,
resolver_id -> Nullable<Int4>,
published -> Timestamp,
updated -> Nullable<Timestamp>,
published -> Timestamptz,
updated -> Nullable<Timestamptz>,
}
}
@ -145,7 +145,7 @@ diesel::table! {
id -> Int4,
comment_id -> Int4,
person_id -> Int4,
published -> Timestamp,
published -> Timestamptz,
}
}
@ -158,8 +158,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]
@ -167,7 +167,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]
@ -193,7 +193,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,
@ -207,7 +207,7 @@ diesel::table! {
id -> Int4,
person_id -> Int4,
community_id -> Int4,
published -> Timestamp,
published -> Timestamptz,
}
}
@ -216,7 +216,7 @@ diesel::table! {
id -> Int4,
community_id -> Int4,
person_id -> Int4,
published -> Timestamp,
published -> Timestamptz,
pending -> Bool,
}
}
@ -234,7 +234,7 @@ diesel::table! {
id -> Int4,
community_id -> Int4,
person_id -> Int4,
published -> Timestamp,
published -> Timestamptz,
}
}
@ -243,8 +243,8 @@ diesel::table! {
id -> Int4,
community_id -> Int4,
person_id -> Int4,
published -> Timestamp,
expires -> Nullable<Timestamp>,
published -> Timestamptz,
expires -> Nullable<Timestamptz>,
}
}
@ -257,8 +257,8 @@ diesel::table! {
image_url -> Text,
alt_text -> Text,
category -> Text,
published -> Timestamp,
updated -> Nullable<Timestamp>,
published -> Timestamptz,
updated -> Nullable<Timestamptz>,
}
}
@ -277,7 +277,7 @@ diesel::table! {
local_user_id -> Int4,
email -> Text,
verification_token -> Text,
published -> Timestamp,
published -> Timestamptz,
}
}
@ -285,8 +285,8 @@ diesel::table! {
federation_allowlist (id) {
id -> Int4,
instance_id -> Int4,
published -> Timestamp,
updated -> Nullable<Timestamp>,
published -> Timestamptz,
updated -> Nullable<Timestamptz>,
}
}
@ -294,8 +294,8 @@ diesel::table! {
federation_blocklist (id) {
id -> Int4,
instance_id -> Int4,
published -> Timestamp,
updated -> Nullable<Timestamp>,
published -> Timestamptz,
updated -> Nullable<Timestamptz>,
}
}
@ -304,8 +304,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]
@ -348,8 +348,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,
}
@ -371,8 +371,8 @@ diesel::table! {
comment_per_second -> Int4,
search -> Int4,
search_per_second -> Int4,
published -> Timestamp,
updated -> Nullable<Timestamp>,
published -> Timestamptz,
updated -> Nullable<Timestamptz>,
}
}
@ -395,7 +395,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,
@ -409,6 +409,7 @@ diesel::table! {
auto_expand -> Bool,
infinite_scroll_enabled -> Bool,
post_listing_mode -> PostListingModeEnum,
admin -> Bool,
}
}
@ -426,7 +427,7 @@ diesel::table! {
mod_person_id -> Int4,
other_person_id -> Int4,
removed -> Bool,
when_ -> Timestamp,
when_ -> Timestamptz,
}
}
@ -437,7 +438,7 @@ diesel::table! {
other_person_id -> Int4,
community_id -> Int4,
removed -> Bool,
when_ -> Timestamp,
when_ -> Timestamptz,
}
}
@ -448,8 +449,8 @@ diesel::table! {
other_person_id -> Int4,
reason -> Nullable<Text>,
banned -> Bool,
expires -> Nullable<Timestamp>,
when_ -> Timestamp,
expires -> Nullable<Timestamptz>,
when_ -> Timestamptz,
}
}
@ -461,8 +462,8 @@ diesel::table! {
community_id -> Int4,
reason -> Nullable<Text>,
banned -> Bool,
expires -> Nullable<Timestamp>,
when_ -> Timestamp,
expires -> Nullable<Timestamptz>,
when_ -> Timestamptz,
}
}
@ -472,7 +473,7 @@ diesel::table! {
mod_person_id -> Int4,
post_id -> Int4,
featured -> Bool,
when_ -> Timestamp,
when_ -> Timestamptz,
is_featured_community -> Bool,
}
}
@ -482,7 +483,7 @@ diesel::table! {
id -> Int4,
community_id -> Int4,
mod_person_id -> Int4,
when_ -> Timestamp,
when_ -> Timestamptz,
reason -> Nullable<Text>,
hidden -> Bool,
}
@ -494,7 +495,7 @@ diesel::table! {
mod_person_id -> Int4,
post_id -> Int4,
locked -> Bool,
when_ -> Timestamp,
when_ -> Timestamptz,
}
}
@ -505,7 +506,7 @@ diesel::table! {
comment_id -> Int4,
reason -> Nullable<Text>,
removed -> Bool,
when_ -> Timestamp,
when_ -> Timestamptz,
}
}
@ -516,8 +517,8 @@ diesel::table! {
community_id -> Int4,
reason -> Nullable<Text>,
removed -> Bool,
expires -> Nullable<Timestamp>,
when_ -> Timestamp,
expires -> Nullable<Timestamptz>,
when_ -> Timestamptz,
}
}
@ -528,7 +529,7 @@ diesel::table! {
post_id -> Int4,
reason -> Nullable<Text>,
removed -> Bool,
when_ -> Timestamp,
when_ -> Timestamptz,
}
}
@ -538,7 +539,7 @@ diesel::table! {
mod_person_id -> Int4,
other_person_id -> Int4,
community_id -> Int4,
when_ -> Timestamp,
when_ -> Timestamptz,
}
}
@ -546,7 +547,7 @@ diesel::table! {
password_reset_request (id) {
id -> Int4,
token -> Text,
published -> Timestamp,
published -> Timestamptz,
local_user_id -> Int4,
}
}
@ -560,15 +561,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]
@ -576,9 +577,8 @@ diesel::table! {
#[max_length = 255]
shared_inbox_url -> Nullable<Varchar>,
matrix_user_id -> Nullable<Text>,
admin -> Bool,
bot_account -> Bool,
ban_expires -> Nullable<Timestamp>,
ban_expires -> Nullable<Timestamptz>,
instance_id -> Int4,
}
}
@ -598,7 +598,7 @@ diesel::table! {
person_ban (id) {
id -> Int4,
person_id -> Int4,
published -> Timestamp,
published -> Timestamptz,
}
}
@ -607,7 +607,7 @@ diesel::table! {
id -> Int4,
person_id -> Int4,
target_id -> Int4,
published -> Timestamp,
published -> Timestamptz,
}
}
@ -616,7 +616,7 @@ diesel::table! {
id -> Int4,
person_id -> Int4,
follower_id -> Int4,
published -> Timestamp,
published -> Timestamptz,
pending -> Bool,
}
}
@ -627,7 +627,7 @@ diesel::table! {
recipient_id -> Int4,
comment_id -> Int4,
read -> Bool,
published -> Timestamp,
published -> Timestamptz,
}
}
@ -637,7 +637,7 @@ diesel::table! {
person_id -> Int4,
post_id -> Int4,
read_comments -> Int8,
published -> Timestamp,
published -> Timestamptz,
}
}
@ -653,8 +653,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>,
@ -678,9 +678,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,
@ -697,7 +697,7 @@ diesel::table! {
post_id -> Int4,
person_id -> Int4,
score -> Int2,
published -> Timestamp,
published -> Timestamptz,
}
}
@ -706,7 +706,7 @@ diesel::table! {
id -> Int4,
post_id -> Int4,
person_id -> Int4,
published -> Timestamp,
published -> Timestamptz,
}
}
@ -722,8 +722,8 @@ diesel::table! {
reason -> Text,
resolved -> Bool,
resolver_id -> Nullable<Int4>,
published -> Timestamp,
updated -> Nullable<Timestamp>,
published -> Timestamptz,
updated -> Nullable<Timestamptz>,
}
}
@ -732,7 +732,7 @@ diesel::table! {
id -> Int4,
post_id -> Int4,
person_id -> Int4,
published -> Timestamp,
published -> Timestamptz,
}
}
@ -744,8 +744,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,
@ -761,8 +761,8 @@ diesel::table! {
reason -> Text,
resolved -> Bool,
resolver_id -> Nullable<Int4>,
published -> Timestamp,
updated -> Nullable<Timestamp>,
published -> Timestamptz,
updated -> Nullable<Timestamptz>,
}
}
@ -770,7 +770,7 @@ diesel::table! {
received_activity (id) {
id -> Int8,
ap_id -> Text,
published -> Timestamp,
published -> Timestamptz,
}
}
@ -781,7 +781,7 @@ diesel::table! {
answer -> Text,
admin_id -> Nullable<Int4>,
deny_reason -> Nullable<Text>,
published -> Timestamp,
published -> Timestamptz,
}
}
@ -798,7 +798,7 @@ diesel::table! {
ap_id -> Text,
data -> Json,
sensitive -> Bool,
published -> Timestamp,
published -> Timestamptz,
}
}
@ -808,15 +808,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>,
@ -853,8 +853,8 @@ diesel::table! {
id -> Int4,
local_site_id -> Int4,
content -> Text,
published -> Timestamp,
updated -> Nullable<Timestamp>,
published -> Timestamptz,
updated -> Nullable<Timestamptz>,
}
}
@ -944,68 +944,68 @@ diesel::joinable!(site_language -> site (site_id));
diesel::joinable!(tagline -> local_site (local_site_id));
diesel::allow_tables_to_appear_in_same_query!(
admin_purge_comment,
admin_purge_community,
admin_purge_person,
admin_purge_post,
captcha_answer,
comment,
comment_aggregates,
comment_like,
comment_reply,
comment_report,
comment_saved,
community,
community_aggregates,
community_block,
community_follower,
community_language,
community_moderator,
community_person_ban,
custom_emoji,
custom_emoji_keyword,
email_verification,
federation_allowlist,
federation_blocklist,
instance,
language,
local_site,
local_site_rate_limit,
local_user,
local_user_language,
mod_add,
mod_add_community,
mod_ban,
mod_ban_from_community,
mod_feature_post,
mod_hide_community,
mod_lock_post,
mod_remove_comment,
mod_remove_community,
mod_remove_post,
mod_transfer_community,
password_reset_request,
person,
person_aggregates,
person_ban,
person_block,
person_follower,
person_mention,
person_post_aggregates,
post,
post_aggregates,
post_like,
post_read,
post_report,
post_saved,
private_message,
private_message_report,
received_activity,
registration_application,
secret,
sent_activity,
site,
site_aggregates,
site_language,
tagline,
admin_purge_comment,
admin_purge_community,
admin_purge_person,
admin_purge_post,
captcha_answer,
comment,
comment_aggregates,
comment_like,
comment_reply,
comment_report,
comment_saved,
community,
community_aggregates,
community_block,
community_follower,
community_language,
community_moderator,
community_person_ban,
custom_emoji,
custom_emoji_keyword,
email_verification,
federation_allowlist,
federation_blocklist,
instance,
language,
local_site,
local_site_rate_limit,
local_user,
local_user_language,
mod_add,
mod_add_community,
mod_ban,
mod_ban_from_community,
mod_feature_post,
mod_hide_community,
mod_lock_post,
mod_remove_comment,
mod_remove_community,
mod_remove_post,
mod_transfer_community,
password_reset_request,
person,
person_aggregates,
person_ban,
person_block,
person_follower,
person_mention,
person_post_aggregates,
post,
post_aggregates,
post_like,
post_read,
post_report,
post_saved,
private_message,
private_message_report,
received_activity,
registration_application,
secret,
sent_activity,
site,
site_aggregates,
site_language,
tagline,
);

View file

@ -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>,
}

View file

@ -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]

View file

@ -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))]

View file

@ -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))]

View file

@ -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)]

View file

@ -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,
}

View file

@ -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))]

View file

@ -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)]

View file

@ -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))]

View file

@ -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>>,
}

View file

@ -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>>,
}

View file

@ -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>>,
}

View file

@ -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>>>,
}

View file

@ -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>>>,
}

Some files were not shown because too many files have changed in this diff Show more