Compare commits
2 commits
1d3ade6bdd
...
c0d4269d61
Author | SHA1 | Date | |
---|---|---|---|
c0d4269d61 | |||
8b2deba6de |
7 changed files with 61 additions and 18 deletions
|
@ -38,7 +38,7 @@ impl From<config::webhook::Push> for Commit {
|
||||||
}
|
}
|
||||||
|
|
||||||
newtype!(Sha: String, Display, Hash,PartialOrd, Ord: "The unique SHA for a git commit.");
|
newtype!(Sha: String, Display, Hash,PartialOrd, Ord: "The unique SHA for a git commit.");
|
||||||
newtype!(Message: String, Hash, PartialOrd, Ord: "The commit message for a git commit.");
|
newtype!(Message: String, Display, Hash, PartialOrd, Ord: "The commit message for a git commit.");
|
||||||
|
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug)]
|
||||||
pub struct Histories {
|
pub struct Histories {
|
||||||
|
|
|
@ -26,4 +26,3 @@ pub use repo_details::RepoDetails;
|
||||||
pub use repository::OpenRepository;
|
pub use repository::OpenRepository;
|
||||||
pub use repository::Repository;
|
pub use repository::Repository;
|
||||||
pub use user_notification::UserNotification;
|
pub use user_notification::UserNotification;
|
||||||
|
|
||||||
|
|
|
@ -1,15 +1,27 @@
|
||||||
use crate::Commit;
|
use crate::Commit;
|
||||||
use git_next_config::{ForgeAlias, RepoAlias};
|
use git_next_config::{BranchName, ForgeAlias, RepoAlias};
|
||||||
|
|
||||||
#[derive(Clone, Debug, PartialEq, Eq)]
|
#[derive(Clone, Debug, PartialEq, Eq)]
|
||||||
pub enum UserNotification {
|
pub enum UserNotification {
|
||||||
CICheckFailed(ForgeAlias, RepoAlias, Commit),
|
CICheckFailed {
|
||||||
RepoConfigLoadFailure(ForgeAlias, RepoAlias, String),
|
forge_alias: ForgeAlias,
|
||||||
WebhookRegistration(ForgeAlias, RepoAlias, String),
|
repo_alias: RepoAlias,
|
||||||
|
commit: Commit,
|
||||||
|
},
|
||||||
|
RepoConfigLoadFailure {
|
||||||
|
forge_alias: ForgeAlias,
|
||||||
|
repo_alias: RepoAlias,
|
||||||
|
reason: String,
|
||||||
|
},
|
||||||
|
WebhookRegistration {
|
||||||
|
forge_alias: ForgeAlias,
|
||||||
|
repo_alias: RepoAlias,
|
||||||
|
reason: String,
|
||||||
|
},
|
||||||
DevNotBasedOnMain {
|
DevNotBasedOnMain {
|
||||||
forge_alias: git_next_config::ForgeAlias,
|
forge_alias: ForgeAlias,
|
||||||
repo_alias: git_next_config::RepoAlias,
|
repo_alias: RepoAlias,
|
||||||
dev_branch: git_next_config::BranchName,
|
dev_branch: BranchName,
|
||||||
main_branch: git_next_config::BranchName,
|
main_branch: BranchName,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,11 +33,11 @@ impl Handler<actor::messages::LoadConfigFromRepo> for actor::RepoActor {
|
||||||
),
|
),
|
||||||
Err(err) => actor::notify_user(
|
Err(err) => actor::notify_user(
|
||||||
notify_user_recipient.as_ref(),
|
notify_user_recipient.as_ref(),
|
||||||
UserNotification::RepoConfigLoadFailure(
|
UserNotification::RepoConfigLoadFailure {
|
||||||
forge_alias,
|
forge_alias,
|
||||||
repo_alias,
|
repo_alias,
|
||||||
err.to_string(),
|
reason: err.to_string(),
|
||||||
),
|
},
|
||||||
log.as_ref(),
|
log.as_ref(),
|
||||||
),
|
),
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,7 +42,11 @@ impl Handler<actor::messages::ReceiveCIStatus> for actor::RepoActor {
|
||||||
tracing::warn!("Checks have failed");
|
tracing::warn!("Checks have failed");
|
||||||
actor::notify_user(
|
actor::notify_user(
|
||||||
self.notify_user_recipient.as_ref(),
|
self.notify_user_recipient.as_ref(),
|
||||||
UserNotification::CICheckFailed(forge_alias, repo_alias, next),
|
UserNotification::CICheckFailed {
|
||||||
|
forge_alias,
|
||||||
|
repo_alias,
|
||||||
|
commit: next,
|
||||||
|
},
|
||||||
log.as_ref(),
|
log.as_ref(),
|
||||||
);
|
);
|
||||||
actor::delay_send(
|
actor::delay_send(
|
||||||
|
|
|
@ -32,11 +32,11 @@ impl Handler<RegisterWebhook> for RepoActor {
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
actor::notify_user(
|
actor::notify_user(
|
||||||
notify_user_recipient.as_ref(),
|
notify_user_recipient.as_ref(),
|
||||||
UserNotification::WebhookRegistration(
|
UserNotification::WebhookRegistration {
|
||||||
forge_alias,
|
forge_alias,
|
||||||
repo_alias,
|
repo_alias,
|
||||||
err.to_string(),
|
reason: err.to_string(),
|
||||||
),
|
},
|
||||||
log.as_ref(),
|
log.as_ref(),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
//
|
//
|
||||||
use actix::prelude::*;
|
use actix::prelude::*;
|
||||||
|
use derive_more::Deref;
|
||||||
|
use git_next_git::UserNotification;
|
||||||
use git_next_repo_actor::messages::NotifyUser;
|
use git_next_repo_actor::messages::NotifyUser;
|
||||||
|
|
||||||
use crate::ServerActor;
|
use crate::ServerActor;
|
||||||
|
@ -7,7 +9,33 @@ use crate::ServerActor;
|
||||||
impl Handler<NotifyUser> for ServerActor {
|
impl Handler<NotifyUser> for ServerActor {
|
||||||
type Result = ();
|
type Result = ();
|
||||||
|
|
||||||
fn handle(&mut self, _msg: NotifyUser, _ctx: &mut Self::Context) -> Self::Result {
|
fn handle(&mut self, msg: NotifyUser, _ctx: &mut Self::Context) -> Self::Result {
|
||||||
|
let _message = match msg.deref() {
|
||||||
|
UserNotification::CICheckFailed {
|
||||||
|
forge_alias,
|
||||||
|
repo_alias,
|
||||||
|
commit,
|
||||||
|
} => format!(
|
||||||
|
"HELP ME!: {forge_alias}/{repo_alias}: CI Checks failed for commit: [{}] {}",commit.sha(), commit.message()
|
||||||
|
),
|
||||||
|
UserNotification::RepoConfigLoadFailure {
|
||||||
|
forge_alias,
|
||||||
|
repo_alias,
|
||||||
|
reason,
|
||||||
|
} => format!("HELP ME!: {forge_alias}/{repo_alias}: Failed to load config: {reason}"),
|
||||||
|
UserNotification::WebhookRegistration {
|
||||||
|
forge_alias,
|
||||||
|
repo_alias,
|
||||||
|
reason,
|
||||||
|
} => format!("HELP ME!: {forge_alias}/{repo_alias}: Failed to register webhook: {reason}"),
|
||||||
|
UserNotification::DevNotBasedOnMain {
|
||||||
|
forge_alias,
|
||||||
|
repo_alias,
|
||||||
|
dev_branch,
|
||||||
|
main_branch,
|
||||||
|
} => format!("HELP ME!: {forge_alias}/{repo_alias}: Dev branch '{dev_branch}' is not based on main branch '{main_branch}'"),
|
||||||
|
};
|
||||||
|
tracing::info!(_message);
|
||||||
// TODO: (#95) should notify user
|
// TODO: (#95) should notify user
|
||||||
// send post to notification webhook url
|
// send post to notification webhook url
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue