From c687b09ab0e1a9456a8e7974578d1b52297f4359 Mon Sep 17 00:00:00 2001 From: Maple Nebel Date: Fri, 19 Jun 2026 12:33:46 +0200 Subject: [PATCH] use new PRACTICALLY_NEVER instead of hardcoding raw time value --- rnex-core/src/kerberos/mod.rs | 25 ++++++++++++++----- rnex-core/src/nex/datastore.rs | 44 ++++++++++++++++------------------ 2 files changed, 40 insertions(+), 29 deletions(-) diff --git a/rnex-core/src/kerberos/mod.rs b/rnex-core/src/kerberos/mod.rs index 7991c7e..e12aecd 100644 --- a/rnex-core/src/kerberos/mod.rs +++ b/rnex-core/src/kerberos/mod.rs @@ -51,11 +51,9 @@ pub fn derive_key(pid: PID, password: &[u8]) -> [u8; 16] { pub struct KerberosDateTime(pub u64); impl KerberosDateTime { - #[deprecated] - pub fn from_i64(val: i64) -> Self { - Self(bytemuck::cast(val)) - } - + // this is the time which smm returned as the expriy date, we use it as a + // date so far into the future that it might as well just be never more generally + pub const PRACTICALLY_NEVER: Self = Self::new(0, 0, 0, 31, 12, 9999); pub fn from_naive(dt: chrono::NaiveDateTime) -> Self { use chrono::Datelike; use chrono::Timelike; @@ -93,7 +91,7 @@ impl KerberosDateTime { ((self.0 >> 6) & 0b111111) as u8 } pub const fn get_hours(&self) -> u8 { - ((self.0 >> 12) & 0b111111) as u8 + ((self.0 >> 12) & 0b11111) as u8 } pub const fn get_days(&self) -> u8 { ((self.0 >> 17) & 0b111111) as u8 @@ -217,5 +215,20 @@ mod test { let time = KerberosDateTime(135904948834); println!("{}", time.to_regular_time().to_rfc2822()); + + let time = KerberosDateTime(0x9C3F3E0000); + + println!( + "{}.{}.{} {}:{}:{}", + time.get_year(), + time.get_month(), + time.get_days(), + time.get_hours(), + time.get_minutes(), + time.get_seconds() + ); + println!("{}", time.to_regular_time().to_rfc2822()); + + assert_eq!(KerberosDateTime::PRACTICALLY_NEVER, time) } } diff --git a/rnex-core/src/nex/datastore.rs b/rnex-core/src/nex/datastore.rs index d6944a7..d427575 100644 --- a/rnex-core/src/nex/datastore.rs +++ b/rnex-core/src/nex/datastore.rs @@ -74,7 +74,7 @@ fn map_row_to_meta_info( refer_dat_id: row_refer_data_id as u32, flag: row_flag as u32, tags: row_tags, - expire_time: KerberosDateTime::from_i64(0x9C3F3E0000), + expire_time: KerberosDateTime::PRACTICALLY_NEVER, created_time: KerberosDateTime::from_naive(row_creation_date), updated_time: KerberosDateTime::from_naive(row_update_date), referred_time: KerberosDateTime::from_naive(row_creation_date), @@ -1414,8 +1414,8 @@ impl DataStore for User { async fn recommended_course_search_object( &self, - course_search_param: DataStoreSearchParam, - extra_data: Vec, + _course_search_param: DataStoreSearchParam, + _extra_data: Vec, ) -> Result, ErrorCode> { let mut courses = Vec::new(); @@ -1439,14 +1439,20 @@ impl DataStore for User { object.creation_date, object.update_date, ranking.value - FROM datastore.objects object - JOIN datastore.object_custom_rankings ranking + FROM ( + SELECT * FROM datastore.objects object + WHERE + object.upload_completed = TRUE AND + object.deleted = FALSE AND + object.under_review = FALSE + ) object + JOIN ( + SELECT data_id, value + FROM datastore.object_custom_rankings ranking + WHERE ranking.application_id = 0 + ) ranking ON - object.data_id = ranking.data_id AND - object.upload_completed = TRUE AND - object.deleted = FALSE AND - object.under_review = FALSE AND - ranking.application_id = 0 + object.data_id = ranking.data_id ORDER BY RANDOM() LIMIT 100 "# @@ -1467,10 +1473,7 @@ impl DataStore for User { recipient_ids: row.delete_permission_recipients.unwrap_or_default(), }; - let meta_binary = row - .meta_binary - .map(|bytes| QBuffer(bytes)) - .unwrap_or_default(); + let meta_binary = row.meta_binary.map(QBuffer).unwrap_or_default(); let created_time = row .creation_date @@ -1502,18 +1505,13 @@ impl DataStore for User { refer_dat_id: row.refer_data_id.unwrap_or(0) as u32, flag: row.flag.unwrap_or(0) as u32, tags: row.tags.unwrap_or_default(), - expire_time: KerberosDateTime::from_i64(0x9C3F3E0000), + expire_time: KerberosDateTime::PRACTICALLY_NEVER, created_time, updated_time, referred_time, - ratings: Vec::new(), + ratings: get_rating_with_slot_data_id(row.data_id).await?, }; - match get_rating_with_slot_data_id(row.data_id).await { - Ok(ratings) => meta_info.ratings = ratings, - Err(e) => return Err(e), - } - let course = DataStoreCustomRankingResult { order: 0, score: row.value.unwrap_or(0) as u32, @@ -1603,8 +1601,8 @@ impl DataStore for User { first_pid: row.first_pid as u32, best_pid: row.best_pid as u32, best_score: row.best_score, - created_time: KerberosDateTime::from_i64(0x9C3F3E0000), - updated_time: KerberosDateTime::from_i64(0x9C3F3E0000), + created_time: KerberosDateTime::PRACTICALLY_NEVER, + updated_time: KerberosDateTime::PRACTICALLY_NEVER, }) }