format
This commit is contained in:
parent
ab6ac96464
commit
bd6d92f6b6
146
src/admin.rs
146
src/admin.rs
|
@ -1,7 +1,7 @@
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
use std::fmt::Write;
|
|
||||||
use std::collections::BTreeMap;
|
use std::collections::BTreeMap;
|
||||||
|
use std::fmt::Write;
|
||||||
|
|
||||||
impl Forgejo {
|
impl Forgejo {
|
||||||
pub async fn admin_get_crons(&self, query: CronQuery) -> Result<Vec<Cron>, ForgejoError> {
|
pub async fn admin_get_crons(&self, query: CronQuery) -> Result<Vec<Cron>, ForgejoError> {
|
||||||
|
@ -12,11 +12,17 @@ impl Forgejo {
|
||||||
self.post(&format!("admin/cron/{name}"), &()).await
|
self.post(&format!("admin/cron/{name}"), &()).await
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn admin_get_emails(&self, query: EmailListQuery) -> Result<Vec<Email>, ForgejoError> {
|
pub async fn admin_get_emails(
|
||||||
|
&self,
|
||||||
|
query: EmailListQuery,
|
||||||
|
) -> Result<Vec<Email>, ForgejoError> {
|
||||||
self.get(&query.path()).await
|
self.get(&query.path()).await
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn admin_search_emails(&self, query: EmailSearchQuery) -> Result<Vec<Email>, ForgejoError> {
|
pub async fn admin_search_emails(
|
||||||
|
&self,
|
||||||
|
query: EmailSearchQuery,
|
||||||
|
) -> Result<Vec<Email>, ForgejoError> {
|
||||||
self.get(&query.path()).await
|
self.get(&query.path()).await
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -36,24 +42,40 @@ impl Forgejo {
|
||||||
self.delete(&format!("admin/hooks/{id}")).await
|
self.delete(&format!("admin/hooks/{id}")).await
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn admin_edit_hook(&self, id: u64, opt: EditHookOption) -> Result<Hook, ForgejoError> {
|
pub async fn admin_edit_hook(
|
||||||
|
&self,
|
||||||
|
id: u64,
|
||||||
|
opt: EditHookOption,
|
||||||
|
) -> Result<Hook, ForgejoError> {
|
||||||
self.patch(&format!("admin/hooks/{id}"), &opt).await
|
self.patch(&format!("admin/hooks/{id}"), &opt).await
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn admin_get_orgs(&self, query: AdminOrganizationQuery) -> Result<Vec<Organization>, ForgejoError> {
|
pub async fn admin_get_orgs(
|
||||||
|
&self,
|
||||||
|
query: AdminOrganizationQuery,
|
||||||
|
) -> Result<Vec<Organization>, ForgejoError> {
|
||||||
self.get(&query.path()).await
|
self.get(&query.path()).await
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn admin_unadopted_repos(&self, query: UnadoptedRepoQuery) -> Result<Vec<String>, ForgejoError> {
|
pub async fn admin_unadopted_repos(
|
||||||
|
&self,
|
||||||
|
query: UnadoptedRepoQuery,
|
||||||
|
) -> Result<Vec<String>, ForgejoError> {
|
||||||
self.get(&query.path()).await
|
self.get(&query.path()).await
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn admin_adopt(&self, owner: &str, repo: &str) -> Result<(), ForgejoError> {
|
pub async fn admin_adopt(&self, owner: &str, repo: &str) -> Result<(), ForgejoError> {
|
||||||
self.post(&format!("admin/unadopted/{owner}/{repo}"), &()).await
|
self.post(&format!("admin/unadopted/{owner}/{repo}"), &())
|
||||||
|
.await
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn admin_delete_unadopted(&self, owner: &str, repo: &str) -> Result<(), ForgejoError> {
|
pub async fn admin_delete_unadopted(
|
||||||
self.delete(&format!("admin/unadopted/{owner}/{repo}")).await
|
&self,
|
||||||
|
owner: &str,
|
||||||
|
repo: &str,
|
||||||
|
) -> Result<(), ForgejoError> {
|
||||||
|
self.delete(&format!("admin/unadopted/{owner}/{repo}"))
|
||||||
|
.await
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn admin_users(&self, query: AdminUserQuery) -> Result<Vec<User>, ForgejoError> {
|
pub async fn admin_users(&self, query: AdminUserQuery) -> Result<Vec<User>, ForgejoError> {
|
||||||
|
@ -65,14 +87,23 @@ impl Forgejo {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn admin_delete_user(&self, user: &str, purge: bool) -> Result<(), ForgejoError> {
|
pub async fn admin_delete_user(&self, user: &str, purge: bool) -> Result<(), ForgejoError> {
|
||||||
self.delete(&format!("admin/users/{user}?purge={purge}")).await
|
self.delete(&format!("admin/users/{user}?purge={purge}"))
|
||||||
|
.await
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn admin_edit_user(&self, user: &str, opt: CreateUserOption) -> Result<User, ForgejoError> {
|
pub async fn admin_edit_user(
|
||||||
|
&self,
|
||||||
|
user: &str,
|
||||||
|
opt: CreateUserOption,
|
||||||
|
) -> Result<User, ForgejoError> {
|
||||||
self.patch(&format!("admin/users/{user}"), &opt).await
|
self.patch(&format!("admin/users/{user}"), &opt).await
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn admin_add_key(&self, user: &str, opt: CreateKeyOption) -> Result<PublicKey, ForgejoError> {
|
pub async fn admin_add_key(
|
||||||
|
&self,
|
||||||
|
user: &str,
|
||||||
|
opt: CreateKeyOption,
|
||||||
|
) -> Result<PublicKey, ForgejoError> {
|
||||||
self.patch(&format!("admin/users/{user}/keys"), &opt).await
|
self.patch(&format!("admin/users/{user}/keys"), &opt).await
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -80,15 +111,27 @@ impl Forgejo {
|
||||||
self.delete(&format!("admin/users/{user}/keys/{id}")).await
|
self.delete(&format!("admin/users/{user}/keys/{id}")).await
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn admin_create_org(&self, owner: &str, opt: CreateOrgOption) -> Result<Organization, ForgejoError> {
|
pub async fn admin_create_org(
|
||||||
|
&self,
|
||||||
|
owner: &str,
|
||||||
|
opt: CreateOrgOption,
|
||||||
|
) -> Result<Organization, ForgejoError> {
|
||||||
self.post(&format!("admin/users/{owner}/orgs"), &opt).await
|
self.post(&format!("admin/users/{owner}/orgs"), &opt).await
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn admin_rename_user(&self, user: &str, opt: RenameUserOption) -> Result<(), ForgejoError> {
|
pub async fn admin_rename_user(
|
||||||
|
&self,
|
||||||
|
user: &str,
|
||||||
|
opt: RenameUserOption,
|
||||||
|
) -> Result<(), ForgejoError> {
|
||||||
self.post(&format!("admin/users/{user}/rename"), &opt).await
|
self.post(&format!("admin/users/{user}/rename"), &opt).await
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn admin_create_repo(&self, owner: &str, opt: CreateRepoOption) -> Result<Repository, ForgejoError> {
|
pub async fn admin_create_repo(
|
||||||
|
&self,
|
||||||
|
owner: &str,
|
||||||
|
opt: CreateRepoOption,
|
||||||
|
) -> Result<Repository, ForgejoError> {
|
||||||
self.post(&format!("admin/users/{owner}/repos"), &opt).await
|
self.post(&format!("admin/users/{owner}/repos"), &opt).await
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -115,12 +158,14 @@ impl CronQuery {
|
||||||
let mut s = String::from("admin/cron?");
|
let mut s = String::from("admin/cron?");
|
||||||
if let Some(page) = self.page {
|
if let Some(page) = self.page {
|
||||||
s.push_str("page=");
|
s.push_str("page=");
|
||||||
s.write_fmt(format_args!("{page}")).expect("writing to string can't fail");
|
s.write_fmt(format_args!("{page}"))
|
||||||
|
.expect("writing to string can't fail");
|
||||||
s.push('&');
|
s.push('&');
|
||||||
}
|
}
|
||||||
if let Some(limit) = self.limit {
|
if let Some(limit) = self.limit {
|
||||||
s.push_str("limit=");
|
s.push_str("limit=");
|
||||||
s.write_fmt(format_args!("{limit}")).expect("writing to string can't fail");
|
s.write_fmt(format_args!("{limit}"))
|
||||||
|
.expect("writing to string can't fail");
|
||||||
s.push('&');
|
s.push('&');
|
||||||
}
|
}
|
||||||
s
|
s
|
||||||
|
@ -147,12 +192,14 @@ impl EmailListQuery {
|
||||||
let mut s = String::from("admin/emails?");
|
let mut s = String::from("admin/emails?");
|
||||||
if let Some(page) = self.page {
|
if let Some(page) = self.page {
|
||||||
s.push_str("page=");
|
s.push_str("page=");
|
||||||
s.write_fmt(format_args!("{page}")).expect("writing to string can't fail");
|
s.write_fmt(format_args!("{page}"))
|
||||||
|
.expect("writing to string can't fail");
|
||||||
s.push('&');
|
s.push('&');
|
||||||
}
|
}
|
||||||
if let Some(limit) = self.limit {
|
if let Some(limit) = self.limit {
|
||||||
s.push_str("limit=");
|
s.push_str("limit=");
|
||||||
s.write_fmt(format_args!("{limit}")).expect("writing to string can't fail");
|
s.write_fmt(format_args!("{limit}"))
|
||||||
|
.expect("writing to string can't fail");
|
||||||
s.push('&');
|
s.push('&');
|
||||||
}
|
}
|
||||||
s
|
s
|
||||||
|
@ -176,12 +223,14 @@ impl EmailSearchQuery {
|
||||||
}
|
}
|
||||||
if let Some(page) = self.page {
|
if let Some(page) = self.page {
|
||||||
s.push_str("page=");
|
s.push_str("page=");
|
||||||
s.write_fmt(format_args!("{page}")).expect("writing to string can't fail");
|
s.write_fmt(format_args!("{page}"))
|
||||||
|
.expect("writing to string can't fail");
|
||||||
s.push('&');
|
s.push('&');
|
||||||
}
|
}
|
||||||
if let Some(limit) = self.limit {
|
if let Some(limit) = self.limit {
|
||||||
s.push_str("limit=");
|
s.push_str("limit=");
|
||||||
s.write_fmt(format_args!("{limit}")).expect("writing to string can't fail");
|
s.write_fmt(format_args!("{limit}"))
|
||||||
|
.expect("writing to string can't fail");
|
||||||
s.push('&');
|
s.push('&');
|
||||||
}
|
}
|
||||||
s
|
s
|
||||||
|
@ -208,17 +257,17 @@ pub struct Hook {
|
||||||
#[non_exhaustive]
|
#[non_exhaustive]
|
||||||
#[serde(rename_all = "lowercase")]
|
#[serde(rename_all = "lowercase")]
|
||||||
pub enum HookType {
|
pub enum HookType {
|
||||||
Forgejo,
|
Forgejo,
|
||||||
Dingtalk,
|
Dingtalk,
|
||||||
Discord,
|
Discord,
|
||||||
Gitea,
|
Gitea,
|
||||||
Gogs,
|
Gogs,
|
||||||
Msteams,
|
Msteams,
|
||||||
Slack,
|
Slack,
|
||||||
Telegram,
|
Telegram,
|
||||||
Feishu,
|
Feishu,
|
||||||
Wechatwork,
|
Wechatwork,
|
||||||
Packagist
|
Packagist,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Default, Debug)]
|
#[derive(Default, Debug)]
|
||||||
|
@ -232,12 +281,14 @@ impl HookQuery {
|
||||||
let mut s = String::from("admin/hooks?");
|
let mut s = String::from("admin/hooks?");
|
||||||
if let Some(page) = self.page {
|
if let Some(page) = self.page {
|
||||||
s.push_str("page=");
|
s.push_str("page=");
|
||||||
s.write_fmt(format_args!("{page}")).expect("writing to string can't fail");
|
s.write_fmt(format_args!("{page}"))
|
||||||
|
.expect("writing to string can't fail");
|
||||||
s.push('&');
|
s.push('&');
|
||||||
}
|
}
|
||||||
if let Some(limit) = self.limit {
|
if let Some(limit) = self.limit {
|
||||||
s.push_str("limit=");
|
s.push_str("limit=");
|
||||||
s.write_fmt(format_args!("{limit}")).expect("writing to string can't fail");
|
s.write_fmt(format_args!("{limit}"))
|
||||||
|
.expect("writing to string can't fail");
|
||||||
s.push('&');
|
s.push('&');
|
||||||
}
|
}
|
||||||
s
|
s
|
||||||
|
@ -283,12 +334,14 @@ impl AdminOrganizationQuery {
|
||||||
let mut s = String::from("admin/orgs?");
|
let mut s = String::from("admin/orgs?");
|
||||||
if let Some(page) = self.page {
|
if let Some(page) = self.page {
|
||||||
s.push_str("page=");
|
s.push_str("page=");
|
||||||
s.write_fmt(format_args!("{page}")).expect("writing to string can't fail");
|
s.write_fmt(format_args!("{page}"))
|
||||||
|
.expect("writing to string can't fail");
|
||||||
s.push('&');
|
s.push('&');
|
||||||
}
|
}
|
||||||
if let Some(limit) = self.limit {
|
if let Some(limit) = self.limit {
|
||||||
s.push_str("limit=");
|
s.push_str("limit=");
|
||||||
s.write_fmt(format_args!("{limit}")).expect("writing to string can't fail");
|
s.write_fmt(format_args!("{limit}"))
|
||||||
|
.expect("writing to string can't fail");
|
||||||
s.push('&');
|
s.push('&');
|
||||||
}
|
}
|
||||||
s
|
s
|
||||||
|
@ -307,12 +360,14 @@ impl UnadoptedRepoQuery {
|
||||||
let mut s = String::from("admin/unadopted?");
|
let mut s = String::from("admin/unadopted?");
|
||||||
if let Some(page) = self.page {
|
if let Some(page) = self.page {
|
||||||
s.push_str("page=");
|
s.push_str("page=");
|
||||||
s.write_fmt(format_args!("{page}")).expect("writing to string can't fail");
|
s.write_fmt(format_args!("{page}"))
|
||||||
|
.expect("writing to string can't fail");
|
||||||
s.push('&');
|
s.push('&');
|
||||||
}
|
}
|
||||||
if let Some(limit) = self.limit {
|
if let Some(limit) = self.limit {
|
||||||
s.push_str("limit=");
|
s.push_str("limit=");
|
||||||
s.write_fmt(format_args!("{limit}")).expect("writing to string can't fail");
|
s.write_fmt(format_args!("{limit}"))
|
||||||
|
.expect("writing to string can't fail");
|
||||||
s.push('&');
|
s.push('&');
|
||||||
}
|
}
|
||||||
if !self.pattern.is_empty() {
|
if !self.pattern.is_empty() {
|
||||||
|
@ -337,7 +392,8 @@ impl AdminUserQuery {
|
||||||
let mut s = String::from("admin/users?");
|
let mut s = String::from("admin/users?");
|
||||||
if let Some(source_id) = self.source_id {
|
if let Some(source_id) = self.source_id {
|
||||||
s.push_str("source_id=");
|
s.push_str("source_id=");
|
||||||
s.write_fmt(format_args!("{source_id}")).expect("writing to string can't fail");
|
s.write_fmt(format_args!("{source_id}"))
|
||||||
|
.expect("writing to string can't fail");
|
||||||
s.push('&');
|
s.push('&');
|
||||||
}
|
}
|
||||||
if !self.login_name.is_empty() {
|
if !self.login_name.is_empty() {
|
||||||
|
@ -347,12 +403,14 @@ impl AdminUserQuery {
|
||||||
}
|
}
|
||||||
if let Some(page) = self.page {
|
if let Some(page) = self.page {
|
||||||
s.push_str("page=");
|
s.push_str("page=");
|
||||||
s.write_fmt(format_args!("{page}")).expect("writing to string can't fail");
|
s.write_fmt(format_args!("{page}"))
|
||||||
|
.expect("writing to string can't fail");
|
||||||
s.push('&');
|
s.push('&');
|
||||||
}
|
}
|
||||||
if let Some(limit) = self.limit {
|
if let Some(limit) = self.limit {
|
||||||
s.push_str("limit=");
|
s.push_str("limit=");
|
||||||
s.write_fmt(format_args!("{limit}")).expect("writing to string can't fail");
|
s.write_fmt(format_args!("{limit}"))
|
||||||
|
.expect("writing to string can't fail");
|
||||||
s.push('&');
|
s.push('&');
|
||||||
}
|
}
|
||||||
s
|
s
|
||||||
|
|
|
@ -8,8 +8,8 @@ pub struct Forgejo {
|
||||||
client: Client,
|
client: Client,
|
||||||
}
|
}
|
||||||
|
|
||||||
mod issue;
|
|
||||||
mod admin;
|
mod admin;
|
||||||
|
mod issue;
|
||||||
mod misc;
|
mod misc;
|
||||||
mod notification;
|
mod notification;
|
||||||
mod organization;
|
mod organization;
|
||||||
|
@ -17,8 +17,8 @@ mod package;
|
||||||
mod repository;
|
mod repository;
|
||||||
mod user;
|
mod user;
|
||||||
|
|
||||||
pub use issue::*;
|
|
||||||
pub use admin::*;
|
pub use admin::*;
|
||||||
|
pub use issue::*;
|
||||||
pub use misc::*;
|
pub use misc::*;
|
||||||
pub use notification::*;
|
pub use notification::*;
|
||||||
pub use organization::*;
|
pub use organization::*;
|
||||||
|
|
|
@ -249,12 +249,30 @@ async fn admin(api: &forgejo_api::Forgejo) -> eyre::Result<()> {
|
||||||
username: "Pipis".into(),
|
username: "Pipis".into(),
|
||||||
visibility: "public".into(),
|
visibility: "public".into(),
|
||||||
};
|
};
|
||||||
let _ = api.admin_create_user(user_opt).await.wrap_err("failed to create user")?;
|
let _ = api
|
||||||
|
.admin_create_user(user_opt)
|
||||||
|
.await
|
||||||
|
.wrap_err("failed to create user")?;
|
||||||
|
|
||||||
let users = api.admin_users(forgejo_api::AdminUserQuery::default()).await.wrap_err("failed to search users")?;
|
let users = api
|
||||||
ensure!(users.iter().find(|u| u.login == "Pipis").is_some(), "could not find new user");
|
.admin_users(forgejo_api::AdminUserQuery::default())
|
||||||
let users = api.admin_get_emails(forgejo_api::EmailListQuery::default()).await.wrap_err("failed to search emails")?;
|
.await
|
||||||
ensure!(users.iter().find(|u| u.email == "user@noreply.example.org").is_some(), "could not find new user");
|
.wrap_err("failed to search users")?;
|
||||||
|
ensure!(
|
||||||
|
users.iter().find(|u| u.login == "Pipis").is_some(),
|
||||||
|
"could not find new user"
|
||||||
|
);
|
||||||
|
let users = api
|
||||||
|
.admin_get_emails(forgejo_api::EmailListQuery::default())
|
||||||
|
.await
|
||||||
|
.wrap_err("failed to search emails")?;
|
||||||
|
ensure!(
|
||||||
|
users
|
||||||
|
.iter()
|
||||||
|
.find(|u| u.email == "user@noreply.example.org")
|
||||||
|
.is_some(),
|
||||||
|
"could not find new user"
|
||||||
|
);
|
||||||
|
|
||||||
let org_opt = forgejo_api::CreateOrgOption {
|
let org_opt = forgejo_api::CreateOrgOption {
|
||||||
description: None,
|
description: None,
|
||||||
|
@ -265,8 +283,16 @@ async fn admin(api: &forgejo_api::Forgejo) -> eyre::Result<()> {
|
||||||
visibility: forgejo_api::OrgVisibility::Public,
|
visibility: forgejo_api::OrgVisibility::Public,
|
||||||
website: None,
|
website: None,
|
||||||
};
|
};
|
||||||
let _ = api.admin_create_org("Pipis", org_opt).await.wrap_err("failed to create org")?;
|
let _ = api
|
||||||
ensure!(!api.admin_get_orgs(forgejo_api::AdminOrganizationQuery::default()).await?.is_empty(), "org list empty");
|
.admin_create_org("Pipis", org_opt)
|
||||||
|
.await
|
||||||
|
.wrap_err("failed to create org")?;
|
||||||
|
ensure!(
|
||||||
|
!api.admin_get_orgs(forgejo_api::AdminOrganizationQuery::default())
|
||||||
|
.await?
|
||||||
|
.is_empty(),
|
||||||
|
"org list empty"
|
||||||
|
);
|
||||||
|
|
||||||
let key_opt = forgejo_api::CreateKeyOption {
|
let key_opt = forgejo_api::CreateKeyOption {
|
||||||
key: "ssh-ed25519 00000000000000000000000000000000000000000000000000000000000000000000 user@noreply.example.org".into(),
|
key: "ssh-ed25519 00000000000000000000000000000000000000000000000000000000000000000000 user@noreply.example.org".into(),
|
||||||
|
@ -279,12 +305,24 @@ async fn admin(api: &forgejo_api::Forgejo) -> eyre::Result<()> {
|
||||||
let rename_opt = forgejo_api::RenameUserOption {
|
let rename_opt = forgejo_api::RenameUserOption {
|
||||||
new_username: "Bepis".into(),
|
new_username: "Bepis".into(),
|
||||||
};
|
};
|
||||||
api.admin_rename_user("Pipis", rename_opt).await.wrap_err("failed to rename user")?;
|
api.admin_rename_user("Pipis", rename_opt)
|
||||||
api.admin_delete_user("Bepis", true).await.wrap_err("failed to delete user")?;
|
.await
|
||||||
ensure!(api.admin_delete_user("Ghost", true).await.is_err(), "deleting fake user should fail");
|
.wrap_err("failed to rename user")?;
|
||||||
|
api.admin_delete_user("Bepis", true)
|
||||||
|
.await
|
||||||
|
.wrap_err("failed to delete user")?;
|
||||||
|
ensure!(
|
||||||
|
api.admin_delete_user("Ghost", true).await.is_err(),
|
||||||
|
"deleting fake user should fail"
|
||||||
|
);
|
||||||
|
|
||||||
let crons = api.admin_get_crons(forgejo_api::CronQuery::default()).await.wrap_err("failed to get crons list")?;
|
let crons = api
|
||||||
api.admin_run_cron(&crons.get(0).ok_or_else(|| eyre!("no crons"))?.name).await.wrap_err("failed to run cron")?;
|
.admin_get_crons(forgejo_api::CronQuery::default())
|
||||||
|
.await
|
||||||
|
.wrap_err("failed to get crons list")?;
|
||||||
|
api.admin_run_cron(&crons.get(0).ok_or_else(|| eyre!("no crons"))?.name)
|
||||||
|
.await
|
||||||
|
.wrap_err("failed to run cron")?;
|
||||||
|
|
||||||
let hook_opt = forgejo_api::CreateHookOption {
|
let hook_opt = forgejo_api::CreateHookOption {
|
||||||
active: None,
|
active: None,
|
||||||
|
@ -299,14 +337,20 @@ async fn admin(api: &forgejo_api::Forgejo) -> eyre::Result<()> {
|
||||||
_type: forgejo_api::HookType::Forgejo,
|
_type: forgejo_api::HookType::Forgejo,
|
||||||
};
|
};
|
||||||
// yarr har har me matey this is me hook
|
// yarr har har me matey this is me hook
|
||||||
let hook = api.admin_create_hook(hook_opt).await.wrap_err("failed to create hook")?;
|
let hook = api
|
||||||
|
.admin_create_hook(hook_opt)
|
||||||
|
.await
|
||||||
|
.wrap_err("failed to create hook")?;
|
||||||
let edit_hook = forgejo_api::EditHookOption {
|
let edit_hook = forgejo_api::EditHookOption {
|
||||||
active: Some(true),
|
active: Some(true),
|
||||||
..Default::default()
|
..Default::default()
|
||||||
};
|
};
|
||||||
api.admin_edit_hook(hook.id, edit_hook).await.wrap_err("failed to edit hook")?;
|
api.admin_edit_hook(hook.id, edit_hook)
|
||||||
api.admin_delete_hook(hook.id).await.wrap_err("failed to delete hook")?;
|
.await
|
||||||
|
.wrap_err("failed to edit hook")?;
|
||||||
|
api.admin_delete_hook(hook.id)
|
||||||
|
.await
|
||||||
|
.wrap_err("failed to delete hook")?;
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue