Skip to content

Commit

Permalink
Merge pull request #188 from Enraged-Dun-Cookie-Development-Team/feat…
Browse files Browse the repository at this point in the history
…-过于久远的不mob推送

👔 新饼推送添加时间戳字段,判断两天前的饼不弹出通知
  • Loading branch information
phidiaLam authored May 22, 2024
2 parents bbb2a6e + 843e994 commit 389c8c4
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
8 changes: 8 additions & 0 deletions logic/ceobe_cookie_logic/src/impletements/new_cookie.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ use persistence::{
datasource_combination::DatasourceCombinationOperate,
datasource_config::DatasourceOperate,
},
help_crates::chrono::Local,
mongodb::{mongodb::bson::oid::ObjectId, MongoDatabaseOperate},
mysql::SqlDatabaseOperate,
operate::{GetDatabaseConnect, GetMutDatabaseConnect},
Expand Down Expand Up @@ -91,7 +92,14 @@ impl CeobeCookieLogic {
.await;
match result {
Ok(user_list) => {
let now = Local::now().timestamp_millis();
for new_cookie in new_cookies {
// 如果饼时间超过2天,判断为补饼,不推送
if let Some(time) = new_cookie.timestamp {
if now - time > 2 * 24 * 60 * 60 * 1000 {
continue;
}
}
// mob推送新饼
let content = PushInfo::builder()
.content(new_cookie.content.text)
Expand Down
2 changes: 2 additions & 0 deletions logic/ceobe_cookie_logic/src/view.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ pub struct NewCookieReq {
pub source: CookieDatasourceReq,
pub content: CookieContentReq,
pub cookie_id: ObjectId,
#[serde(default)]
pub timestamp: Option<i64>,
}
#[derive(Debug, Clone, Serialize, Deserialize, TypedBuilder)]
pub struct CookieDatasourceReq {
Expand Down

0 comments on commit 389c8c4

Please sign in to comment.