Kaynağa Gözat

make event time optional

Pietro Albini 4 yıl önce
ebeveyn
işleme
d7710c5dbd
2 değiştirilmiş dosya ile 6 ekleme ve 6 silme
  1. 5 5
      src/github.rs
  2. 1 1
      src/handlers/notification.rs

+ 5 - 5
src/github.rs

@@ -932,12 +932,12 @@ impl Event {
         }
     }
 
-    pub fn time(&self) -> chrono::DateTime<FixedOffset> {
+    pub fn time(&self) -> Option<chrono::DateTime<FixedOffset>> {
         match self {
-            Event::Create(_) => todo!(),
-            Event::Issue(e) => e.issue.created_at.into(),
-            Event::IssueComment(e) => e.comment.updated_at.into(),
-            Event::Push(_) => todo!(),
+            Event::Create(_) => None,
+            Event::Issue(e) => Some(e.issue.created_at.into()),
+            Event::IssueComment(e) => Some(e.comment.updated_at.into()),
+            Event::Push(_) => None,
         }
     }
 }

+ 1 - 1
src/handlers/notification.rs

@@ -111,7 +111,7 @@ pub async fn handle(ctx: &Context, event: &Event) -> anyhow::Result<()> {
                     user_id: user.id.unwrap(),
                     origin_url: event.html_url().unwrap().to_owned(),
                     origin_html: body.to_owned(),
-                    time: event.time(),
+                    time: event.time().unwrap(),
                     short_description: Some(short_description.clone()),
                     team_name: team_name.clone(),
                 },