Add functions for other event lists.
This commit is contained in:
parent
e8c4fb16ff
commit
1811b60b06
@ -1,6 +1,3 @@
|
||||
use reqwest::header::HeaderValue;
|
||||
use reqwest::header::ETAG;
|
||||
use std::collections::HashMap;
|
||||
use tokio::sync::mpsc;
|
||||
|
||||
use super::github_endpoint_watcher::GithubEndpointWatcher;
|
||||
@ -45,6 +42,34 @@ impl<'a> GithubCtl<'a> {
|
||||
owner = owner.as_ref().trim(),
|
||||
repo = repo.as_ref().trim()
|
||||
);
|
||||
return Ok(self.watch_list(url).await);
|
||||
}
|
||||
|
||||
pub async fn watch_org<O>(&mut self, org: O) -> Result<(), Box<dyn std::error::Error>>
|
||||
where
|
||||
O: AsRef<str>,
|
||||
{
|
||||
let url = format!(
|
||||
"https://api.github.com/users/{username}/events/orgs/{org}",
|
||||
org = org.as_ref().trim(),
|
||||
username = self.username.trim()
|
||||
);
|
||||
return Ok(self.watch_list(url).await);
|
||||
}
|
||||
|
||||
pub async fn watch_self(&mut self) -> Result<(), Box<dyn std::error::Error>> {
|
||||
let url = format!(
|
||||
"https://api.github.com/users/{username}/received_events",
|
||||
username = self.username.trim()
|
||||
);
|
||||
return Ok(self.watch_list(url).await);
|
||||
}
|
||||
|
||||
async fn watch_list<U>(&mut self, url: U)
|
||||
where
|
||||
U: Into<String>,
|
||||
{
|
||||
let url = url.into();
|
||||
let username = self.username.to_string();
|
||||
let token = self.token.to_string();
|
||||
let event_stream = self.event_writer.clone();
|
||||
@ -72,6 +97,5 @@ impl<'a> GithubCtl<'a> {
|
||||
}
|
||||
}
|
||||
});
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user