Compare commits

..

No commits in common. "85f16311fa440e3ad4be343978c86e79ceed856f" and "0c71fd379635815e6d00db81a48800b904afd445" have entirely different histories.

3 changed files with 8 additions and 34 deletions

View File

@ -1,9 +1,6 @@
use crate::query_call_consume;
use crate::CallDB;
use bson::oid::ObjectId;
use chrono::DateTime;
use chrono::FixedOffset;
use chrono::Local;
use serde::{Deserialize, Serialize};
use super::DbResult;
@ -15,7 +12,6 @@ where
C: Serialize,
{
pub _id: bson::oid::ObjectId,
pub created_at: DateTime<FixedOffset>,
#[serde(flatten)]
pub callback: C,
}
@ -27,7 +23,6 @@ where
pub fn new(callback: C) -> Self {
Self {
_id: Default::default(),
created_at: Local::now().into(),
callback,
}
}

View File

@ -1,7 +1,5 @@
pub mod callback_info;
use std::time::Duration;
use async_trait::async_trait;
use chrono::{DateTime, Utc};
use enum_stringify::EnumStringify;
@ -131,25 +129,6 @@ impl DB {
.build(),
)
.await?;
// clear callbacks after a day because otherwise database will contain so much data
// for just button clicks
let callback_info = self
.get_database()
.await
.collection::<Event>("callback_info");
callback_info
.create_index(
IndexModel::builder()
.keys(doc! {"created_at": 1})
.options(
IndexOptions::builder()
.expire_after(Duration::from_secs(60 * 60 * 24 /* 1 day */))
.build(),
)
.build(),
)
.await?;
Ok(())
}

View File

@ -75,7 +75,7 @@ pub enum State {
#[derive(Serialize, Deserialize)]
#[serde(tag = "type")]
#[serde(rename_all = "snake_case")]
#[serde(rename = "snake_case")]
pub enum Callback {
MoreInfo,
ProjectPage { id: u32 },
@ -611,14 +611,14 @@ async fn make_start_buttons(db: &mut DB) -> BotResult<InlineKeyboardMarkup> {
)]
})
.collect();
buttons.push(vec![InlineKeyboardButton::callback(
"More info",
CallbackStore::new(Callback::MoreInfo)
.store(db)
.await?
.get_id(),
)]);
buttons.push(vec![
InlineKeyboardButton::callback(
"More info",
CallbackStore::new(Callback::MoreInfo)
.store(db)
.await?
.get_id(),
),
create_callback_button(
"show_projects",
CallbackStore::new(Callback::ProjectPage { id: 1 }),