feature: implement get_issue for notifications
https://github.com/PyGithub/PyGithub/blob/001970d4a828017f704f6744a5775b4207a6523c/github/Notification.py#L133
in python i use it like so
def get_gh_notif_dict() -> dict[str, str]:
"""get a dictionary of github notification titles and urls"""
g_h = Github(os.getenv("GITHUB_TOKEN"))
notifications = g_h.get_user().get_notifications()
notif_dict: dict[str, str] = {}
for notif in notifications:
issue = notif.get_issue()
title = issue.title
repo = issue.repository.full_name
html_url = issue.html_url
entry = f"{repo} | {title}"
notif_dict[entry] = html_url
return notif_dict
i ended up doing
async fn get_gh_notif_url() -> octocrab::Result<()> {
let token = std::env::var("GITHUB_TOKEN").expect("GITHUB_TOKEN env variable is required");
let octocrab = octocrab::Octocrab::builder()
.personal_token(token)
.build()?;
let notifications = octocrab.activity().notifications().list().send().await?;
for n in notifications {
let route = n.subject.url.as_ref().unwrap().path();
let url = match n.subject.type_.as_str() {
"Release" => {
let release: octocrab::models::repos::Release =
octocrab.get(route, None::<&()>).await?;
release.html_url.to_string()
}
"Issue" => {
let issue: octocrab::models::issues::Issue =
octocrab.get(route, None::<&()>).await?;
issue.html_url.to_string()
}
"PullRequest" => {
let pr: octocrab::models::pulls::PullRequest =
octocrab.get(route, None::<&()>).await?;
pr.html_url.unwrap().to_string()
}
_ => continue,
};
println!("{}", &url);
}
Ok(())
}
used https://github.com/sudormrfbin/octerm/blob/dec3ce97652db0dca95c02799a786eaa3b218578/src/network.rs#L111 as a reference
i decided to use @sudormrfbin octerm instead of implementing notifications myself https://github.com/sudormrfbin/octerm
A unified API for getting the target of the notification (issue, pr, release, etc) would still be nice to have.
Thank you for your issue! I agree, it would be nice, if someone would like to contribute it, it’s more than welcome.