Skip to content

Commit

Permalink
builds: Expose token name via API
Browse files Browse the repository at this point in the history
  • Loading branch information
barthalion committed Nov 2, 2023
1 parent ed4e0a0 commit aa7b6a4
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ALTER TABLE builds DROP COLUMN token_name;
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ALTER TABLE builds ADD token_name TEXT;
11 changes: 11 additions & 0 deletions src/api/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,12 +134,23 @@ async fn create_build_async(
.public_download
.unwrap_or_else(|| args.app_id.is_none());

let token_name = if let Some(ref claims) = req.get_claims() {
if let Some(ref name) = claims.name {
name.clone()
} else {
"-".to_string()
}
} else {
"-".to_string()
};

let build = db
.new_build(NewBuild {
repo: args.repo.clone(),
app_id: args.app_id.clone(),
public_download,
build_log_url: args.build_log_url.clone(),
token_name: Some(token_name),
})
.await?;
let build_repo_path = config.build_repo_base.join(build.id.to_string());
Expand Down
2 changes: 2 additions & 0 deletions src/models.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ pub struct NewBuild {
pub app_id: Option<String>,
pub public_download: bool,
pub build_log_url: Option<String>,
pub token_name: Option<String>,
}

#[derive(Identifiable, Serialize, Queryable, Debug, Eq, PartialEq)]
Expand All @@ -34,6 +35,7 @@ pub struct Build {
pub app_id: Option<String>,
pub public_download: bool,
pub build_log_url: Option<String>,
pub token_name: Option<String>,
}

#[derive(Deserialize, Debug, Eq, PartialEq)]
Expand Down
1 change: 1 addition & 0 deletions src/schema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ diesel::table! {
app_id -> Nullable<Text>,
public_download -> Bool,
build_log_url -> Nullable<Text>,
token_name -> Nullable<Text>,
}
}

Expand Down

0 comments on commit aa7b6a4

Please sign in to comment.