forge_notify: detect review requests via requested_reviewers (closes #253)
This commit is contained in:
parent
845fafdf1b
commit
4a0d08154e
1 changed files with 20 additions and 0 deletions
|
|
@ -378,6 +378,26 @@ async fn format_notification(
|
||||||
other => format!("{label}{num}{repo}: {other}"),
|
other => format!("{label}{num}{repo}: {other}"),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Review-request detection (#253): Forgejo does not always set
|
||||||
|
// reason == "review_requested" (observed reason is null). Check
|
||||||
|
// requested_reviewers instead, which is reliable. If own_login is
|
||||||
|
// in the list, this is a review request -- override the kind.
|
||||||
|
// `subject` and `is_pr` are already fetched unconditionally above (#256).
|
||||||
|
let is_review_request = is_new
|
||||||
|
&& is_pr
|
||||||
|
&& !own_login.is_empty()
|
||||||
|
&& subject
|
||||||
|
.as_ref()
|
||||||
|
.and_then(|s| s["requested_reviewers"].as_array())
|
||||||
|
.map(|arr| arr.iter().any(|r| r["login"].as_str() == Some(own_login)))
|
||||||
|
.unwrap_or(false);
|
||||||
|
|
||||||
|
let kind = if is_review_request {
|
||||||
|
format!("review requested{num}{repo}")
|
||||||
|
} else {
|
||||||
|
kind
|
||||||
|
};
|
||||||
|
|
||||||
let mut out = format!("[{kind}] {title}\nurl: {html_url}");
|
let mut out = format!("[{kind}] {title}\nurl: {html_url}");
|
||||||
out.push_str(&meta_suffix);
|
out.push_str(&meta_suffix);
|
||||||
Some(out)
|
Some(out)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue