Compare commits

..

No commits in common. "6bc4b7b1431c32db60d2ca5be729cdbc527dfb1b" and "7b056cb87923101a32828c95c847f333564893c1" have entirely different histories.

3 changed files with 12 additions and 51 deletions

View file

@ -118,33 +118,11 @@ The server should be able to notify the user when manual intervention is require
##### webhook
Will send a POST request for some events.
- **url** - the URL to POST the notification to and the
- **secret** - the sync key used to sign the webhook payload
See [Notifications](#notifications) for more details.
##### email
Will send an email for some events.
- **from** - the email address to send the email from
- **to** - the email address to send the email to
With just `from` and `to` specified, `git-next` will attempt to send emails
with `sendmail` if it is configured.
Alternativly, you can use an SMTP relay.
###### smtp
Will send emails using an SMTP relay.
- **hostname** - the SMTP relay server
- **username** - the account to authenticate as
- **password** - the password to authenticate with
#### storage
`git-next` will create a bare clone of each repo that you configure it to

View file

@ -8,7 +8,7 @@ use std::{
str::FromStr,
};
use derive_more::{Constructor, Display};
use derive_more::Display;
use kxio::fs::FileSystem;
use secrecy::Secret;
use serde::{Deserialize, Serialize};
@ -204,13 +204,19 @@ impl ServerStorage {
Ord,
derive_more::AsRef,
serde::Deserialize,
Constructor,
)]
pub struct Shout {
webhook: Option<OutboundWebhook>,
email: Option<EmailConfig>,
}
impl Shout {
pub const fn new_webhook(webhook: OutboundWebhook) -> Self {
Self {
webhook: Some(webhook),
email: None,
}
}
pub const fn webhook(&self) -> Option<&OutboundWebhook> {
self.webhook.as_ref()
}

View file

@ -475,13 +475,6 @@ mod server {
.webhook_secret()
.map(|secret| secret.expose_secret().clone())
.unwrap_or_default();
let_assert!(Some(shout_email) = shout.email());
let shout_email_from = shout_email.from();
let shout_email_to = shout_email.to();
let_assert!(Some(shout_email_smtp) = shout_email.smtp());
let shout_email_smtp_hostname = shout_email_smtp.hostname();
let shout_email_smtp_username = shout_email_smtp.username();
let shout_email_smtp_password = shout_email_smtp.password();
let forge_alias = server_config
.forges()
.next()
@ -528,15 +521,6 @@ url = "{listen_url}"
[shout]
webhook = {{ url = "{shout_webhook_url}", secret = "{shout_webhook_secret}" }}
[shout.email]
from = "{shout_email_from}"
to = "{shout_email_to}"
[shout.email.smtp]
hostname = "{shout_email_smtp_hostname}"
username = "{shout_email_smtp_username}"
password = "{shout_email_smtp_password}"
[storage]
path = {storage_path:?}
@ -708,7 +692,7 @@ mod push {
}
mod given {
use crate::server::{EmailConfig, Listen, ListenUrl, OutboundWebhook, Shout, SmtpConfig};
use crate::server::{Listen, ListenUrl, OutboundWebhook, Shout};
use super::*;
use rand::Rng as _;
@ -732,7 +716,7 @@ mod given {
pub fn a_server_config() -> ServerConfig {
ServerConfig::new(
a_listen(),
a_shout(),
a_notification_config(),
a_server_storage(),
some_forge_configs(),
)
@ -762,18 +746,11 @@ mod given {
pub fn an_outbound_webhook() -> OutboundWebhook {
OutboundWebhook::new(a_name(), a_name())
}
pub fn an_email_config() -> EmailConfig {
EmailConfig::new(
a_name(),
a_name(),
Some(SmtpConfig::new(a_name(), a_name(), a_name())),
)
}
pub fn a_server_storage() -> ServerStorage {
ServerStorage::new(a_name().into())
}
pub fn a_shout() -> Shout {
Shout::new(Some(an_outbound_webhook()), Some(an_email_config()))
pub fn a_notification_config() -> Shout {
Shout::new_webhook(an_outbound_webhook())
}
pub fn some_forge_configs() -> BTreeMap<String, ForgeConfig> {
[(a_name(), a_forge_config())].into()