Allow chats to choose a locale

This commit is contained in:
2023-01-25 23:28:15 +01:00
parent f3136bd319
commit 747353d544
6 changed files with 52 additions and 11 deletions

View File

@@ -12,6 +12,7 @@ pub struct DbChat {
next_appointment_end: Option<i64>,
last_reminder: Option<i64>,
pinned_message: Option<i32>,
locale: Option<String>,
}
pub struct ChatInfo<Tz: TimeZone> {
@@ -20,6 +21,7 @@ pub struct ChatInfo<Tz: TimeZone> {
pub next_appointment: Option<Appointment<Tz>>,
pub last_reminder: Option<DateTime<Tz>>,
pub pinned_message_id: Option<i32>,
pub locale: String,
}
impl From<DbChat> for ChatInfo<Utc> {
@@ -42,12 +44,15 @@ impl From<DbChat> for ChatInfo<Utc> {
.map(|timestamp| NaiveDateTime::from_timestamp(timestamp, 0))
.map(|date_time| DateTime::<Utc>::from_utc(date_time, Utc));
let locale = db_chat.locale.unwrap_or("de".into());
ChatInfo {
id: db_chat.telegram_id,
calendar: db_chat.calendar,
next_appointment: next_appointment,
last_reminder,
pinned_message_id: db_chat.pinned_message,
locale,
}
}
}