mirror of
https://github.com/gitbucket/gitbucket.git
synced 2025-11-08 14:35:52 +01:00
Merge branch 'issue-893' of https://github.com/McFoggy/gitbucket into McFoggy-issue-893
This commit is contained in:
@@ -24,7 +24,8 @@ trait SystemSettingsControllerBase extends ControllerBase {
|
|||||||
"activityLogLimit" -> trim(label("Limit of activity logs", optional(number()))),
|
"activityLogLimit" -> trim(label("Limit of activity logs", optional(number()))),
|
||||||
"ssh" -> trim(label("SSH access", boolean())),
|
"ssh" -> trim(label("SSH access", boolean())),
|
||||||
"sshPort" -> trim(label("SSH port", optional(number()))),
|
"sshPort" -> trim(label("SSH port", optional(number()))),
|
||||||
"smtp" -> optionalIfNotChecked("notification", mapping(
|
"useSMTP" -> trim(label("SMTP", boolean())),
|
||||||
|
"smtp" -> optionalIfNotChecked("useSMTP", mapping(
|
||||||
"host" -> trim(label("SMTP Host", text(required))),
|
"host" -> trim(label("SMTP Host", text(required))),
|
||||||
"port" -> trim(label("SMTP Port", optional(number()))),
|
"port" -> trim(label("SMTP Port", optional(number()))),
|
||||||
"user" -> trim(label("SMTP User", optional(text()))),
|
"user" -> trim(label("SMTP User", optional(text()))),
|
||||||
|
|||||||
@@ -22,7 +22,8 @@ trait SystemSettingsService {
|
|||||||
settings.activityLogLimit.foreach(x => props.setProperty(ActivityLogLimit, x.toString))
|
settings.activityLogLimit.foreach(x => props.setProperty(ActivityLogLimit, x.toString))
|
||||||
props.setProperty(Ssh, settings.ssh.toString)
|
props.setProperty(Ssh, settings.ssh.toString)
|
||||||
settings.sshPort.foreach(x => props.setProperty(SshPort, x.toString))
|
settings.sshPort.foreach(x => props.setProperty(SshPort, x.toString))
|
||||||
if(settings.notification) {
|
props.setProperty(UseSMTP, settings.useSMTP.toString)
|
||||||
|
if(settings.useSMTP) {
|
||||||
settings.smtp.foreach { smtp =>
|
settings.smtp.foreach { smtp =>
|
||||||
props.setProperty(SmtpHost, smtp.host)
|
props.setProperty(SmtpHost, smtp.host)
|
||||||
smtp.port.foreach(x => props.setProperty(SmtpPort, x.toString))
|
smtp.port.foreach(x => props.setProperty(SmtpPort, x.toString))
|
||||||
@@ -75,7 +76,8 @@ trait SystemSettingsService {
|
|||||||
getOptionValue[Int](props, ActivityLogLimit, None),
|
getOptionValue[Int](props, ActivityLogLimit, None),
|
||||||
getValue(props, Ssh, false),
|
getValue(props, Ssh, false),
|
||||||
getOptionValue(props, SshPort, Some(DefaultSshPort)),
|
getOptionValue(props, SshPort, Some(DefaultSshPort)),
|
||||||
if(getValue(props, Notification, false)){
|
getValue(props, UseSMTP, getValue(props, Notification, false)), // handle migration scenario from only notification to useSMTP
|
||||||
|
if(getValue(props, UseSMTP, getValue(props, Notification, false))){
|
||||||
Some(Smtp(
|
Some(Smtp(
|
||||||
getValue(props, SmtpHost, ""),
|
getValue(props, SmtpHost, ""),
|
||||||
getOptionValue(props, SmtpPort, Some(DefaultSmtpPort)),
|
getOptionValue(props, SmtpPort, Some(DefaultSmtpPort)),
|
||||||
@@ -125,6 +127,7 @@ object SystemSettingsService {
|
|||||||
activityLogLimit: Option[Int],
|
activityLogLimit: Option[Int],
|
||||||
ssh: Boolean,
|
ssh: Boolean,
|
||||||
sshPort: Option[Int],
|
sshPort: Option[Int],
|
||||||
|
useSMTP: Boolean,
|
||||||
smtp: Option[Smtp],
|
smtp: Option[Smtp],
|
||||||
ldapAuthentication: Boolean,
|
ldapAuthentication: Boolean,
|
||||||
ldap: Option[Ldap]){
|
ldap: Option[Ldap]){
|
||||||
@@ -172,6 +175,7 @@ object SystemSettingsService {
|
|||||||
private val ActivityLogLimit = "activity_log_limit"
|
private val ActivityLogLimit = "activity_log_limit"
|
||||||
private val Ssh = "ssh"
|
private val Ssh = "ssh"
|
||||||
private val SshPort = "ssh.port"
|
private val SshPort = "ssh.port"
|
||||||
|
private val UseSMTP = "useSMTP"
|
||||||
private val SmtpHost = "smtp.host"
|
private val SmtpHost = "smtp.host"
|
||||||
private val SmtpPort = "smtp.port"
|
private val SmtpPort = "smtp.port"
|
||||||
private val SmtpUser = "smtp.user"
|
private val SmtpUser = "smtp.user"
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ trait Notifier extends RepositoryService with AccountService with IssuesService
|
|||||||
object Notifier {
|
object Notifier {
|
||||||
// TODO We want to be able to switch to mock.
|
// TODO We want to be able to switch to mock.
|
||||||
def apply(): Notifier = new SystemSettingsService {}.loadSystemSettings match {
|
def apply(): Notifier = new SystemSettingsService {}.loadSystemSettings match {
|
||||||
case settings if settings.notification => new Mailer(settings.smtp.get)
|
case settings if (settings.notification && settings.useSMTP) => new Mailer(settings.smtp.get)
|
||||||
case _ => new MockMailer
|
case _ => new MockMailer
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -224,14 +224,25 @@
|
|||||||
<!-- Notification email -->
|
<!-- Notification email -->
|
||||||
<!--====================================================================-->
|
<!--====================================================================-->
|
||||||
<hr>
|
<hr>
|
||||||
<label class="strong">Notification email</label>
|
<label class="strong">Notifications</label>
|
||||||
<fieldset>
|
<fieldset>
|
||||||
<label class="checkbox">
|
<label class="checkbox">
|
||||||
<input type="checkbox" id="notification" name="notification"@if(settings.notification){ checked}/>
|
<input type="checkbox" id="notification" name="notification"@if(settings.notification){ checked}/>
|
||||||
Send notifications
|
Send notifications
|
||||||
</label>
|
</label>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
<div class="form-horizontal notification">
|
<!--====================================================================-->
|
||||||
|
<!-- Communication email -->
|
||||||
|
<!--====================================================================-->
|
||||||
|
<hr>
|
||||||
|
<label class="strong">Communication</label>
|
||||||
|
<fieldset>
|
||||||
|
<label class="checkbox">
|
||||||
|
<input type="checkbox" id="useSMTP" name="useSMTP" @if(settings.useSMTP){ checked}/>
|
||||||
|
use SMTP
|
||||||
|
</label>
|
||||||
|
</fieldset>
|
||||||
|
<div class="form-horizontal useSMTP">
|
||||||
<div class="control-group">
|
<div class="control-group">
|
||||||
<label class="control-label" for="smtpHost">SMTP Host</label>
|
<label class="control-label" for="smtpHost">SMTP Host</label>
|
||||||
<div class="controls">
|
<div class="controls">
|
||||||
@@ -292,8 +303,16 @@ $(function(){
|
|||||||
$('.ssh input').prop('disabled', !$(this).prop('checked'));
|
$('.ssh input').prop('disabled', !$(this).prop('checked'));
|
||||||
}).change();
|
}).change();
|
||||||
|
|
||||||
$('#notification').change(function(){
|
$('#useSMTP').change(function(){
|
||||||
$('.notification input').prop('disabled', !$(this).prop('checked'));
|
$('.useSMTP input').prop('disabled', !$(this).prop('checked'));
|
||||||
|
|
||||||
|
// With only SMTP in current version, notification cannot be enabled if no communication channel exists
|
||||||
|
$('#notification').prop('disabled', !$(this).prop('checked'));
|
||||||
|
|
||||||
|
if (!$(this).prop('checked')) {
|
||||||
|
// With only SMTP in current version, if SMTP is unchecked then we disable notification
|
||||||
|
$('#notification').prop('checked', false);
|
||||||
|
}
|
||||||
}).change();
|
}).change();
|
||||||
|
|
||||||
$('#ldapAuthentication').change(function(){
|
$('#ldapAuthentication').change(function(){
|
||||||
|
|||||||
@@ -103,6 +103,7 @@ class AvatarImageProviderSpec extends Specification with Mockito {
|
|||||||
activityLogLimit = None,
|
activityLogLimit = None,
|
||||||
ssh = false,
|
ssh = false,
|
||||||
sshPort = None,
|
sshPort = None,
|
||||||
|
useSMTP = false,
|
||||||
smtp = None,
|
smtp = None,
|
||||||
ldapAuthentication = false,
|
ldapAuthentication = false,
|
||||||
ldap = None)
|
ldap = None)
|
||||||
|
|||||||
Reference in New Issue
Block a user