matrix-google-calendar

Bot to manage meetings, pushrules, matrix status as well as showing daily agenda and allowing to shedule stuff.
git clone git://archive.git.mtrnord.blog/MTRNord/matrix-google-calendar.git
Log | Files | Refs

types.rs (2639B)


      1 use std::path::PathBuf;
      2 
      3 use serde::Deserialize;
      4 
      5 #[derive(Debug, Clone, Deserialize)]
      6 pub struct ClientSecrets {
      7     pub web: ClientSecretsInner,
      8 }
      9 
     10 #[derive(Debug, Clone, Deserialize)]
     11 pub struct ClientSecretsInner {
     12     pub client_id: String,
     13     pub project_id: String,
     14     pub auth_uri: String,
     15     pub token_uri: String,
     16     pub auth_provider_x509_cert_url: String,
     17     pub client_secret: String,
     18     pub redirect_uris: Vec<String>,
     19 }
     20 
     21 impl ClientSecrets {
     22     pub fn load_clientsecrets() -> Option<Self> {
     23         let path: PathBuf = "clientsecret.json".into();
     24         let file = std::fs::File::open(path);
     25         match file {
     26             Ok(file) => {
     27                 let clientsecrets: Result<Self, serde_json::Error> = serde_json::from_reader(&file);
     28                 match clientsecrets {
     29                     Ok(clientsecrets) => Some(clientsecrets),
     30                     Err(_) => None,
     31                 }
     32             }
     33             Err(_) => None,
     34         }
     35     }
     36 }
     37 
     38 #[derive(Deserialize, Debug, Clone)]
     39 #[serde(rename_all = "camelCase")]
     40 pub struct Calendars {
     41     pub kind: String,
     42     pub etag: String,
     43     pub next_page_token: Option<String>,
     44     pub next_sync_token: Option<String>,
     45     pub items: Vec<CalendarListEntry>,
     46 }
     47 
     48 #[derive(Deserialize, Debug, Clone)]
     49 #[serde(rename_all = "camelCase")]
     50 pub struct CalendarListEntry {
     51     pub kind: String,
     52     pub etag: String,
     53     pub id: String,
     54     pub summary: String,
     55     pub description: Option<String>,
     56     pub location: Option<String>,
     57     pub time_zone: Option<String>,
     58     pub summary_override: Option<String>,
     59     pub color_id: Option<String>,
     60     pub background_color: Option<String>,
     61     pub foreground_color: Option<String>,
     62     pub hidden: Option<bool>,
     63     pub selected: Option<bool>,
     64     pub access_role: String,
     65     pub primary: Option<bool>,
     66     pub deleted: Option<bool>,
     67     pub default_reminders: Vec<CalendarDefaultReminders>,
     68     pub notification_settings: Option<CalendarNotificationSettings>,
     69     pub conference_properties: Option<CalendarConferenceParties>,
     70 }
     71 
     72 #[derive(Deserialize, Debug, Clone)]
     73 pub struct CalendarDefaultReminders {
     74     pub method: String,
     75     pub minutes: i64,
     76 }
     77 
     78 #[derive(Deserialize, Debug, Clone)]
     79 #[serde(rename_all = "camelCase")]
     80 pub struct CalendarConferenceParties {
     81     pub allowed_conference_solution_types: Vec<String>,
     82 }
     83 
     84 #[derive(Deserialize, Debug, Clone)]
     85 pub struct CalendarNotificationSettings {
     86     pub notifications: Vec<CalendarNotifications>,
     87 }
     88 
     89 #[derive(Deserialize, Debug, Clone)]
     90 pub struct CalendarNotifications {
     91     #[serde(rename = "type")]
     92     pub notifications_type: String,
     93     pub method: String,
     94 }