Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 19 additions & 12 deletions oxa/oxa-work/src/board/queue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,19 +37,12 @@ impl NotificationTarget {
fn read(row: &Value) -> Option<Self> {
let author = &row["author"];
let login = author["login"].as_str()?;
let account = match author["__typename"].as_str()? {
"User" => login,
"Bot" => login.strip_suffix("[bot]").unwrap_or(login),
let is_bot = match author["__typename"].as_str()? {
"User" => false,
"Bot" => true,
_ => return None,
};
if account.len() > 100
|| !account.as_bytes().first().is_some_and(u8::is_ascii_alphanumeric)
|| !account
.bytes()
.all(|b| b.is_ascii_alphanumeric() || b"-_".contains(&b))
{
return None;
}
recipient_mention(login, is_bot)?;
Some(Self {
pull_request_id: node_id(&row["id"])?.to_owned(),
author_id: node_id(&author["id"])?.to_owned(),
Expand All @@ -58,6 +51,20 @@ impl NotificationTarget {
}
}

pub(crate) fn recipient_mention(login: &str, is_bot: bool) -> Option<&str> {
let account = if is_bot {
login.strip_suffix("[bot]").unwrap_or(login)
} else {
login
};
(account.len() <= 100
&& account.as_bytes().first().is_some_and(u8::is_ascii_alphanumeric)
&& account
.bytes()
.all(|b| b.is_ascii_alphanumeric() || b"-_".contains(&b)))
.then_some(account)
}

pub(crate) struct Removal<'a> {
pub number: u64,
pub event: &'a str,
Expand Down Expand Up @@ -183,7 +190,7 @@ fn node_id(value: &Value) -> Option<&str> {
value.as_str().filter(|id| is_node_id(id))
}

pub(super) fn is_node_id(id: &str) -> bool {
pub(crate) fn is_node_id(id: &str) -> bool {
(1..=128).contains(&id.len())
&& id
.bytes()
Expand Down
4 changes: 4 additions & 0 deletions oxa/oxa-work/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ pub use github::pull_request_task;
pub mod incidents;
pub mod situation;
pub mod standing;
pub use publish::{
Admission, AdmissionAcknowledgment, AdmissionReceipt, DeliveryReceipt, LandingPublisher, NoticeIntent,
RejectedLanding, RetryIntent,
};

#[derive(Clone, Debug, Deserialize, Serialize, PartialEq, Eq)]
#[serde(deny_unknown_fields)]
Expand Down
5 changes: 5 additions & 0 deletions oxa/oxa-work/src/publish.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
//! Explicit publishing of the accepted commit; existing queued PRs are never pushed.
use super::{checked, state, tree, CheckpointObserver, LockedTask, Outcome, Record, Result, RunPolicy, Task};
use state::Step;
mod landing;
pub use landing::{
Admission, AdmissionAcknowledgment, AdmissionReceipt, DeliveryReceipt, LandingPublisher, NoticeIntent,
RejectedLanding, RetryIntent,
};
use std::os::{fd::AsRawFd, unix::process::CommandExt};
use std::{
fs::File,
Expand Down
Loading
Loading