Skip to content

Commit

Permalink
fix: set telegram as source with /pr
Browse files Browse the repository at this point in the history
  • Loading branch information
jiegec committed Mar 11, 2024
1 parent c10d9da commit c7a0bb0
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 4 deletions.
3 changes: 2 additions & 1 deletion server/src/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ pub async fn pipeline_new_pr(
pool: DbPool,
pr: u64,
archs: Option<&str>,
source: &JobSource
) -> anyhow::Result<Pipeline> {
match octocrab::instance()
.pulls("AOSC-Dev", "aosc-os-abbs")
Expand Down Expand Up @@ -194,7 +195,7 @@ pub async fn pipeline_new_pr(
Some(pr.number),
&packages.join(","),
&archs,
&JobSource::Github(pr.number),
&source,
)
.await
} else {
Expand Down
9 changes: 8 additions & 1 deletion server/src/bot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,14 @@ pub async fn answer(bot: Bot, msg: Message, cmd: Command, pool: DbPool) -> Respo
Some(parts[1])
};
for pr_number in pr_numbers {
match pipeline_new_pr(pool.clone(), pr_number, archs).await {
match pipeline_new_pr(
pool.clone(),
pr_number,
archs,
&JobSource::Telegram(msg.chat.id.0 as i64),
)
.await
{
Ok(pipeline) => {
bot.send_message(
msg.chat.id,
Expand Down
9 changes: 7 additions & 2 deletions server/src/routes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,13 @@ pub async fn pipeline_new_pr(
State(AppState { pool, .. }): State<AppState>,
Json(payload): Json<PipelineNewPRRequest>,
) -> Result<Json<PipelineNewResponse>, AnyhowError> {
let pipeline =
api::pipeline_new_pr(pool, payload.pr, payload.archs.as_ref().map(|s| s.as_str())).await?;
let pipeline = api::pipeline_new_pr(
pool,
payload.pr,
payload.archs.as_ref().map(|s| s.as_str()),
&JobSource::Manual,
)
.await?;
Ok(Json(PipelineNewResponse { id: pipeline.id }))
}

Expand Down

0 comments on commit c7a0bb0

Please sign in to comment.