mirror of
https://github.com/lennart-k/rustical.git
synced 2025-12-14 10:32:19 +00:00
store(Event): Keep plaintext ics string
This commit is contained in:
@@ -1,7 +1,6 @@
|
|||||||
use crate::timestamps::{parse_datetime, parse_duration};
|
use crate::timestamps::{parse_datetime, parse_duration};
|
||||||
use anyhow::{anyhow, Result};
|
use anyhow::{anyhow, Result};
|
||||||
use chrono::{Duration, NaiveDateTime, Timelike};
|
use chrono::{Duration, NaiveDateTime, Timelike};
|
||||||
use ical::generator::Emitter;
|
|
||||||
use ical::parser::{ical::component::IcalCalendar, Component};
|
use ical::parser::{ical::component::IcalCalendar, Component};
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use sha2::{Digest, Sha256};
|
use sha2::{Digest, Sha256};
|
||||||
@@ -10,6 +9,7 @@ use std::io::BufReader;
|
|||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
pub struct Event {
|
pub struct Event {
|
||||||
uid: String,
|
uid: String,
|
||||||
|
ics: String,
|
||||||
cal: IcalCalendar,
|
cal: IcalCalendar,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -60,7 +60,7 @@ impl Event {
|
|||||||
if cal.events.len() != 1 {
|
if cal.events.len() != 1 {
|
||||||
return Err(anyhow!("multiple or no events"));
|
return Err(anyhow!("multiple or no events"));
|
||||||
}
|
}
|
||||||
let event = Self { uid, cal };
|
let event = Self { uid, cal, ics };
|
||||||
// Run getters now to validate the input and ensure that they'll work later on
|
// Run getters now to validate the input and ensure that they'll work later on
|
||||||
event.get_first_occurence()?;
|
event.get_first_occurence()?;
|
||||||
event.get_last_occurence()?;
|
event.get_last_occurence()?;
|
||||||
@@ -76,8 +76,8 @@ impl Event {
|
|||||||
format!("{:x}", hasher.finalize())
|
format!("{:x}", hasher.finalize())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_ics(&self) -> String {
|
pub fn get_ics(&self) -> &str {
|
||||||
self.cal.generate()
|
&self.ics
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_first_occurence(&self) -> Result<NaiveDateTime> {
|
pub fn get_first_occurence(&self) -> Result<NaiveDateTime> {
|
||||||
|
|||||||
Reference in New Issue
Block a user