Ver código fonte

Use login name instead of `User` struct

kellda 5 anos atrás
pai
commit
19ef30f9fd
2 arquivos alterados com 5 adições e 5 exclusões
  1. 4 4
      src/github.rs
  2. 1 1
      src/handlers/assign.rs

+ 4 - 4
src/github.rs

@@ -330,14 +330,14 @@ impl Issue {
         &self.labels
     }
 
-    pub fn contain_assignee(&self, user: &User) -> bool {
-        self.assignees.contains(user)
+    pub fn contain_assignee(&self, user: &str) -> bool {
+        self.assignees.iter().any(|a| a.login == user)
     }
 
     pub async fn remove_assignees(
         &self,
         client: &GithubClient,
-        selection: Selection<'_, User>,
+        selection: Selection<'_, String>,
     ) -> Result<(), AssignmentError> {
         log::info!("remove {:?} assignees for {}", selection, self.global_id());
         let url = format!(
@@ -352,7 +352,7 @@ impl Issue {
                 .iter()
                 .map(|u| u.login.as_str())
                 .collect::<Vec<_>>(),
-            Selection::One(user) => vec![user.login.as_str()],
+            Selection::One(user) => vec![user.as_str()],
         };
 
         #[derive(serde::Serialize)]

+ 1 - 1
src/handlers/assign.rs

@@ -141,7 +141,7 @@ async fn handle_input(ctx: &Context, event: &Event, cmd: AssignCommand) -> anyho
                     anyhow::bail!("Cannot release another user's assignment");
                 }
             } else {
-                let current = &event.user();
+                let current = &event.user().login;
                 if issue.contain_assignee(current) {
                     issue
                         .remove_assignees(&ctx.github, Selection::One(&current))