rust bertsio berritzea

This commit is contained in:
2026-09-26 16:05:44 +01:00
parent 2fb52dc594
commit 3aee14852a
9 changed files with 85 additions and 6 deletions
+1
View File
@@ -1,6 +1,7 @@
use crate::{schema::apps, Error, Result};
use chrono::NaiveDateTime;
use diesel::{self, ExpressionMethods, QueryDsl, RunQueryDsl};
use serde_derive::Serialize;
#[derive(Clone, Queryable, Serialize)]
pub struct App {
+2 -1
View File
@@ -136,7 +136,8 @@ impl Comment {
|id| Comment::get(conn, id).map(|comment| comment.ap_url.unwrap_or_default()),
)?);
note.set_published(
OffsetDateTime::from_unix_timestamp_nanos(self.creation_date.timestamp_nanos_opt().unwrap().into())
//EZABATU OffsetDateTime::from_unix_timestamp_nanos(self.creation_date.timestamp_nanos_opt().unwrap().into())
OffsetDateTime::from_unix_timestamp_nanos(self.creation_date.and_utc().timestamp_nanos_opt().unwrap().into())
.expect("OffsetDateTime"),
);
note.set_attributed_to(author.into_id().parse::<IriString>()?);
+1
View File
@@ -5,6 +5,7 @@ use rocket::config::Limits;
use rocket::Config as RocketConfig;
use std::collections::HashSet;
use std::env::{self, var};
use serde_derive::Serialize;
#[cfg(feature = "s3")]
use s3::{Bucket, Region, creds::Credentials};
+18 -2
View File
@@ -12,7 +12,7 @@ use activitystreams::{
prelude::*,
time::OffsetDateTime,
};
use chrono::{NaiveDateTime, Utc};
use chrono::{DateTime, NaiveDateTime, Utc};
use diesel::{self, BelongingToDsl, ExpressionMethods, QueryDsl, RunQueryDsl};
use once_cell::sync::Lazy;
use plume_common::{
@@ -373,7 +373,8 @@ impl Post {
}))?;
article.set_source(source);
article.set_published(
OffsetDateTime::from_unix_timestamp_nanos(self.creation_date.timestamp_nanos_opt().unwrap().into())
//EZABATU OffsetDateTime::from_unix_timestamp_nanos(self.creation_date.timestamp_nanos_opt().unwrap().into())
OffsetDateTime::from_unix_timestamp_nanos(self.creation_date.and_utc().timestamp_nanos_opt().unwrap().into())
.expect("OffsetDateTime"),
);
article.set_summary(&*self.subtitle);
@@ -752,6 +753,20 @@ impl FromId<Connection> for Post {
license,
// FIXME: This is wrong: with this logic, we may use the display URL as the AP ID. We need two different fields
ap_url,
creation_date: article.published().map(|published| {
let timestamp_secs = published.unix_timestamp();
let timestamp_nanos = published.unix_timestamp_nanos()
- (timestamp_secs as i128) * 1000i128 * 1000i128 * 1000i128;
DateTime::from_timestamp(
timestamp_secs,
timestamp_nanos as u32,
)
.unwrap()
.naive_utc()
}),
/*
EZABATU
creation_date: article.published().map(|published| {
let timestamp_secs = published.unix_timestamp();
let timestamp_nanos = published.unix_timestamp_nanos()
@@ -762,6 +777,7 @@ impl FromId<Connection> for Post {
)
.unwrap()
}),
*/
subtitle: article
.summary()
.and_then(|summary| summary.to_as_string())
+2 -1
View File
@@ -93,7 +93,8 @@ macro_rules! gen_to_string {
}
)*
$(
for val in &$self.$date {
//for val in &$self.$date {
if let Some(val) = &$self.$date {
$result.push_str(&format!("{}:{} ", stringify!($date), NaiveDate::from_num_days_from_ce_opt(*val as i32).unwrap().format("%Y-%m-%d")));
}
)*
-1
View File
@@ -6,7 +6,6 @@ use crate::{
};
use diesel::{self, BoolExpressionMethods, ExpressionMethods, QueryDsl, RunQueryDsl};
use std::cmp::Ordering;
use std::ops::Deref;
pub(crate) mod query;