| 1 | use std::future::Future; |
| 2 | use std::pin::Pin; |
| 3 | use std::sync::Arc; |
| 4 | |
| 5 | use chrono::{DateTime, Utc}; |
| 6 | use serde::Serialize; |
| 7 | use store::Store; |
| 8 | |
| 9 | pub type SourceFuture<'a, T> = Pin<Box<dyn Future<Output = Result<T, SourceError>> + Send + 'a>>; |
| 10 | |
| 11 | #[derive(Debug, thiserror::Error)] |
| 12 | pub enum SourceError { |
| 13 | #[error("rusty-teams is not connected to Teams")] |
| 14 | NotConnected, |
| 15 | #[error("{0} is not supported by this build")] |
| 16 | Unsupported(&'static str), |
| 17 | #[error("{0}")] |
| 18 | Failed(String), |
| 19 | } |
| 20 | |
| 21 | #[derive(Debug, Clone, PartialEq, Eq, Serialize)] |
| 22 | pub struct Meeting { |
| 23 | pub title: String, |
| 24 | pub start: DateTime<Utc>, |
| 25 | pub end: DateTime<Utc>, |
| 26 | pub all_day: bool, |
| 27 | pub organizer: Option<String>, |
| 28 | pub join_url: Option<String>, |
| 29 | pub meeting_chat_id: Option<String>, |
| 30 | } |
| 31 | |
| 32 | #[derive(Debug, Clone, PartialEq, Serialize)] |
| 33 | pub struct TranscriptTurn { |
| 34 | pub speaker: String, |
| 35 | pub start_seconds: f64, |
| 36 | pub end_seconds: f64, |
| 37 | pub text: String, |
| 38 | } |
| 39 | |
| 40 | #[derive(Debug, Clone, PartialEq, Serialize)] |
| 41 | pub struct Transcript { |
| 42 | pub recording_name: Option<String>, |
| 43 | pub created_at: Option<String>, |
| 44 | pub turns: Vec<TranscriptTurn>, |
| 45 | } |
| 46 | |
| 47 | pub trait TeamsSource: Send + Sync + 'static { |
| 48 | fn store(&self) -> Result<Arc<Store>, SourceError>; |
| 49 | |
| 50 | fn me_id(&self) -> Option<String>; |
| 51 | |
| 52 | fn calendar( |
| 53 | &self, |
| 54 | _start: DateTime<Utc>, |
| 55 | _end: DateTime<Utc>, |
| 56 | ) -> SourceFuture<'_, Vec<Meeting>> { |
| 57 | Box::pin(async { Err(SourceError::Unsupported("calendar")) }) |
| 58 | } |
| 59 | |
| 60 | fn transcript<'a>(&'a self, _meeting_chat_id: &'a str) -> SourceFuture<'a, Transcript> { |
| 61 | Box::pin(async { Err(SourceError::Unsupported("transcript")) }) |
| 62 | } |
| 63 | } |