Merge pull request 'Update crates' (#1134) from update-crates into main

Reviewed-on: https://git.joinplu.me/Plume/Plume/pulls/1134
This commit is contained in:
KitaitiMakoto 2023-01-06 14:57:17 +00:00
commit ae7bf2e132
6 changed files with 603 additions and 471 deletions

1034
Cargo.lock generated

File diff suppressed because it is too large Load Diff

View File

@ -24,7 +24,7 @@ activitystreams-ext = "0.1.0-alpha.2"
url = "2.2.2" url = "2.2.2"
flume = "0.10.13" flume = "0.10.13"
tokio = { version = "1.19.2", features = ["full"] } tokio = { version = "1.19.2", features = ["full"] }
futures = "0.3.21" futures = "0.3.25"
[dependencies.chrono] [dependencies.chrono]
features = ["serde"] features = ["serde"]

View File

@ -10,7 +10,7 @@ bcrypt = "0.12.1"
guid-create = "0.2" guid-create = "0.2"
itertools = "0.10.3" itertools = "0.10.3"
lazy_static = "1.0" lazy_static = "1.0"
ldap3 = "0.10.5" ldap3 = "0.11.1"
migrations_internals= "1.4.0" migrations_internals= "1.4.0"
openssl = "0.10.40" openssl = "0.10.40"
rocket = "0.4.11" rocket = "0.4.11"
@ -24,7 +24,7 @@ tantivy = "0.13.3"
url = "2.1" url = "2.1"
walkdir = "2.2" walkdir = "2.2"
webfinger = "0.4.1" webfinger = "0.4.1"
whatlang = "0.16.0" whatlang = "0.16.2"
shrinkwraprs = "0.3.0" shrinkwraprs = "0.3.0"
diesel-derive-newtype = "1.0.0" diesel-derive-newtype = "1.0.0"
glob = "0.3.0" glob = "0.3.0"

View File

@ -756,7 +756,11 @@ impl FromId<DbConn> for Post {
let timestamp_secs = published.unix_timestamp(); let timestamp_secs = published.unix_timestamp();
let timestamp_nanos = published.unix_timestamp_nanos() let timestamp_nanos = published.unix_timestamp_nanos()
- (timestamp_secs as i128) * 1000i128 * 1000i128 * 1000i128; - (timestamp_secs as i128) * 1000i128 * 1000i128 * 1000i128;
NaiveDateTime::from_timestamp(timestamp_secs, timestamp_nanos as u32) NaiveDateTime::from_timestamp_opt(
timestamp_secs,
timestamp_nanos as u32,
)
.unwrap()
}), }),
subtitle: article subtitle: article
.summary() .summary()

View File

@ -94,7 +94,7 @@ macro_rules! gen_to_string {
)* )*
$( $(
for val in &$self.$date { for val in &$self.$date {
$result.push_str(&format!("{}:{} ", stringify!($date), NaiveDate::from_num_days_from_ce(*val as i32).format("%Y-%m-%d"))); $result.push_str(&format!("{}:{} ", stringify!($date), NaiveDate::from_num_days_from_ce_opt(*val as i32).unwrap().format("%Y-%m-%d")));
} }
)* )*
} }
@ -180,12 +180,16 @@ impl PlumeQuery {
if self.before.is_some() || self.after.is_some() { if self.before.is_some() || self.after.is_some() {
// if at least one range bound is provided // if at least one range bound is provided
let after = self let after = self.after.unwrap_or_else(|| {
.after i64::from(
.unwrap_or_else(|| i64::from(NaiveDate::from_ymd(2000, 1, 1).num_days_from_ce())); NaiveDate::from_ymd_opt(2000, 1, 1)
.unwrap()
.num_days_from_ce(),
)
});
let before = self let before = self
.before .before
.unwrap_or_else(|| i64::from(Utc::today().num_days_from_ce())); .unwrap_or_else(|| i64::from(Utc::now().date_naive().num_days_from_ce()));
let field = Searcher::schema().get_field("creation_date").unwrap(); let field = Searcher::schema().get_field("creation_date").unwrap();
let range = let range =
RangeQuery::new_i64_bounds(field, Bound::Included(after), Bound::Included(before)); RangeQuery::new_i64_bounds(field, Bound::Included(after), Bound::Included(before));
@ -202,16 +206,20 @@ impl PlumeQuery {
pub fn before<D: Datelike>(&mut self, date: &D) -> &mut Self { pub fn before<D: Datelike>(&mut self, date: &D) -> &mut Self {
let before = self let before = self
.before .before
.unwrap_or_else(|| i64::from(Utc::today().num_days_from_ce())); .unwrap_or_else(|| i64::from(Utc::now().date_naive().num_days_from_ce()));
self.before = Some(cmp::min(before, i64::from(date.num_days_from_ce()))); self.before = Some(cmp::min(before, i64::from(date.num_days_from_ce())));
self self
} }
// documents older than the provided date will be ignored // documents older than the provided date will be ignored
pub fn after<D: Datelike>(&mut self, date: &D) -> &mut Self { pub fn after<D: Datelike>(&mut self, date: &D) -> &mut Self {
let after = self let after = self.after.unwrap_or_else(|| {
.after i64::from(
.unwrap_or_else(|| i64::from(NaiveDate::from_ymd(2000, 1, 1).num_days_from_ce())); NaiveDate::from_ymd_opt(2000, 1, 1)
.unwrap()
.num_days_from_ce(),
)
});
self.after = Some(cmp::max(after, i64::from(date.num_days_from_ce()))); self.after = Some(cmp::max(after, i64::from(date.num_days_from_ce())));
self self
} }

View File

@ -65,7 +65,7 @@ pub fn search(query: Option<Form<SearchQuery>>, conn: DbConn, rockets: PlumeRock
if str_query.is_empty() { if str_query.is_empty() {
render!(search::index( render!(search::index(
&(&conn, &rockets).to_context(), &(&conn, &rockets).to_context(),
&format!("{}", Utc::today().format("%Y-%m-d")) &format!("{}", Utc::now().date_naive().format("%Y-%m-d"))
)) ))
} else { } else {
let res = rockets let res = rockets