Commit 7d48e3c6 authored by darlaam's avatar darlaam
Browse files

Handle the hook token

parent 175e23b7
......@@ -653,17 +653,28 @@ impl Gitlab {
}
/// Add a project hook.
pub fn add_hook<U>(
pub fn add_hook<U, T>(
&self,
project: ProjectId,
url: U,
enable_ssl_verification: Option<bool>,
token: Option<T>,
events: WebhookEvents,
) -> GitlabResult<ProjectHook>
where
U: AsRef<str>,
T: AsRef<str>,
{
let mut flags = Self::event_flags(events);
flags.push(("url", url.as_ref()));
let s: String;
if let Some(ssl) = enable_ssl_verification {
s = ssl.to_string();
flags.push(("enable_ssl_verification", s.as_str()));
}
if let Some(tk) = token.as_ref() {
flags.push(("token", tk.as_ref()));
}
self.post_with_param(format!("projects/{}/hooks", project), &flags)
}
......@@ -833,17 +844,15 @@ impl Gitlab {
("name", branch.as_ref()),
(
"push_access_level",
&u64::from(push_access_level.map_or(AccessLevel::Maintainer, |al| al))
.to_string(),
&u64::from(push_access_level.unwrap_or(AccessLevel::Maintainer)).to_string(),
),
(
"merge_access_level",
&u64::from(merge_access_level.map_or(AccessLevel::Maintainer, |al| al))
.to_string(),
&u64::from(merge_access_level.unwrap_or(AccessLevel::Maintainer)).to_string(),
),
(
"unprotect_access_level",
&u64::from(unprotect_access_level.map_or(AccessLevel::Maintainer, |al| al))
&u64::from(unprotect_access_level.unwrap_or(AccessLevel::Maintainer))
.to_string(),
),
],
......
......@@ -344,6 +344,8 @@ pub struct ProjectHook {
pub pipeline_events: bool,
/// Whether the hook is contacted for wiki page events.
pub wiki_page_events: bool,
/// Secret token to validate received payloads
pub token: Option<String>,
}
impl From<ProjectHook> for Hook {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment