summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJames Moger <james.moger@gitblit.com>2014-06-05 10:24:39 -0400
committerJames Moger <james.moger@gitblit.com>2014-06-05 10:24:39 -0400
commitafbaebde11093fae8b420aaaf71dcd56d8c0f9fd (patch)
treefe1d739b9e723ca0f95f12af2511e613412c8a2f
parent74221eb302e782ef23777d5c3f0a649ceb321c1e (diff)
downloadgitblit-afbaebde11093fae8b420aaaf71dcd56d8c0f9fd.tar.gz
gitblit-afbaebde11093fae8b420aaaf71dcd56d8c0f9fd.zip
Add "email me on my ticket changes" preference
-rw-r--r--src/main/java/com/gitblit/ConfigUserService.java4
-rw-r--r--src/main/java/com/gitblit/models/UserPreferences.java13
-rw-r--r--src/main/java/com/gitblit/tickets/TicketNotifier.java11
-rw-r--r--src/main/java/com/gitblit/wicket/GitBlitWebApp.properties2
-rw-r--r--src/main/java/com/gitblit/wicket/pages/UserPage.html3
-rw-r--r--src/main/java/com/gitblit/wicket/pages/UserPage.java9
6 files changed, 39 insertions, 3 deletions
diff --git a/src/main/java/com/gitblit/ConfigUserService.java b/src/main/java/com/gitblit/ConfigUserService.java
index b5dfde3b..9759eff7 100644
--- a/src/main/java/com/gitblit/ConfigUserService.java
+++ b/src/main/java/com/gitblit/ConfigUserService.java
@@ -96,6 +96,8 @@ public class ConfigUserService implements IUserService {
private static final String LOCALE = "locale";
+ private static final String EMAILONMYTICKETCHANGES = "emailMeOnMyTicketChanges";
+
private static final String ACCOUNTTYPE = "accountType";
private static final String DISABLED = "disabled";
@@ -711,6 +713,7 @@ public class ConfigUserService implements IUserService {
String val = model.getPreferences().getLocale().getLanguage() + "_" + model.getPreferences().getLocale().getCountry();
config.setString(USER, model.username, LOCALE, val);
}
+ config.setBoolean(USER, model.username, EMAILONMYTICKETCHANGES, model.getPreferences().isEmailMeOnMyTicketChanges());
}
// user roles
@@ -887,6 +890,7 @@ public class ConfigUserService implements IUserService {
// preferences
user.getPreferences().setLocale(config.getString(USER, username, LOCALE));
+ user.getPreferences().setEmailMeOnMyTicketChanges(config.getBoolean(USER, username, EMAILONMYTICKETCHANGES, true));
// user roles
Set<String> roles = new HashSet<String>(Arrays.asList(config.getStringList(
diff --git a/src/main/java/com/gitblit/models/UserPreferences.java b/src/main/java/com/gitblit/models/UserPreferences.java
index 61db353c..c95b0da5 100644
--- a/src/main/java/com/gitblit/models/UserPreferences.java
+++ b/src/main/java/com/gitblit/models/UserPreferences.java
@@ -39,6 +39,8 @@ public class UserPreferences implements Serializable {
private String locale;
+ private Boolean emailMeOnMyTicketChanges;
+
private final Map<String, UserRepositoryPreferences> repositoryPreferences = new TreeMap<String, UserRepositoryPreferences>();
public UserPreferences(String username) {
@@ -100,4 +102,15 @@ public class UserPreferences implements Serializable {
Collections.sort(list);
return list;
}
+
+ public boolean isEmailMeOnMyTicketChanges() {
+ if (emailMeOnMyTicketChanges == null) {
+ return true;
+ }
+ return emailMeOnMyTicketChanges;
+ }
+
+ public void setEmailMeOnMyTicketChanges(boolean value) {
+ this.emailMeOnMyTicketChanges = value;
+ }
}
diff --git a/src/main/java/com/gitblit/tickets/TicketNotifier.java b/src/main/java/com/gitblit/tickets/TicketNotifier.java
index 9a5e4e1d..07371b1b 100644
--- a/src/main/java/com/gitblit/tickets/TicketNotifier.java
+++ b/src/main/java/com/gitblit/tickets/TicketNotifier.java
@@ -545,7 +545,6 @@ public class TicketNotifier {
}
}
}
- mailing.setRecipients(toAddresses);
//
// CC recipients
@@ -554,7 +553,7 @@ public class TicketNotifier {
// repository owners
if (!ArrayUtils.isEmpty(repository.owners)) {
- tos.addAll(repository.owners);
+ ccs.addAll(repository.owners);
}
// cc users mentioned in last comment
@@ -595,6 +594,14 @@ public class TicketNotifier {
}
ccAddresses.addAll(settings.getStrings(Keys.mail.mailingLists));
+ // respect the author's email preference
+ UserModel lastAuthor = userManager.getUserModel(lastChange.author);
+ if (!lastAuthor.getPreferences().isEmailMeOnMyTicketChanges()) {
+ toAddresses.remove(lastAuthor.emailAddress);
+ ccAddresses.remove(lastAuthor.emailAddress);
+ }
+
+ mailing.setRecipients(toAddresses);
mailing.setCCs(ccAddresses);
}
diff --git a/src/main/java/com/gitblit/wicket/GitBlitWebApp.properties b/src/main/java/com/gitblit/wicket/GitBlitWebApp.properties
index 90d30f29..c80d45ce 100644
--- a/src/main/java/com/gitblit/wicket/GitBlitWebApp.properties
+++ b/src/main/java/com/gitblit/wicket/GitBlitWebApp.properties
@@ -728,6 +728,8 @@ gb.accountPreferences = Account Preferences
gb.accountPreferencesDescription = Specify your account preferences
gb.languagePreference = Language Preference
gb.languagePreferenceDescription = Select your preferred translation for Gitblit
+gb.emailMeOnMyTicketChanges = Email me on my ticket changes
+gb.emailMeOnMyTicketChangesDescription = Send me an email notification for changes that I make to a ticket
gb.displayNameDescription = The preferred name for display
gb.emailAddressDescription = The primary email address for receiving notifications
gb.sshKeys = SSH Keys
diff --git a/src/main/java/com/gitblit/wicket/pages/UserPage.html b/src/main/java/com/gitblit/wicket/pages/UserPage.html
index d71cb2b5..017fcb1f 100644
--- a/src/main/java/com/gitblit/wicket/pages/UserPage.html
+++ b/src/main/java/com/gitblit/wicket/pages/UserPage.html
@@ -64,7 +64,8 @@
<form wicket:id="prefsForm">
<div wicket:id="displayName"></div>
<div wicket:id="emailAddress"></div>
- <div wicket:id="language"></div>
+ <div wicket:id="language"></div>
+ <div wicket:id="emailMeOnMyTicketChanges"></div>
<div class="form-actions"><input class="btn btn-appmenu" type="submit" value="Save" wicket:message="value:gb.save" wicket:id="save" /></div>
</form>
diff --git a/src/main/java/com/gitblit/wicket/pages/UserPage.java b/src/main/java/com/gitblit/wicket/pages/UserPage.java
index 94048963..505f55d9 100644
--- a/src/main/java/com/gitblit/wicket/pages/UserPage.java
+++ b/src/main/java/com/gitblit/wicket/pages/UserPage.java
@@ -48,6 +48,7 @@ import com.gitblit.wicket.GitBlitWebApp;
import com.gitblit.wicket.GitBlitWebSession;
import com.gitblit.wicket.GitblitRedirectException;
import com.gitblit.wicket.WicketUtils;
+import com.gitblit.wicket.panels.BooleanOption;
import com.gitblit.wicket.panels.ChoiceOption;
import com.gitblit.wicket.panels.ProjectRepositoryPanel;
import com.gitblit.wicket.panels.SshKeysPanel;
@@ -219,6 +220,7 @@ public class UserPage extends RootPage {
final IModel<String> displayName = Model.of(user.getDisplayName());
final IModel<String> emailAddress = Model.of(user.emailAddress == null ? "" : user.emailAddress);
final IModel<Language> language = Model.of(preferredLanguage);
+ final IModel<Boolean> emailMeOnMyTicketChanges = Model.of(user.getPreferences().isEmailMeOnMyTicketChanges());
prefs.add(new TextOption("displayName",
getString("gb.displayName"),
@@ -236,6 +238,11 @@ public class UserPage extends RootPage {
language,
languages));
+ prefs.add(new BooleanOption("emailMeOnMyTicketChanges",
+ getString("gb.emailMeOnMyTicketChanges"),
+ getString("gb.emailMeOnMyTicketChangesDescription"),
+ emailMeOnMyTicketChanges).setVisible(app().notifier().isSendingMail()));
+
prefs.add(new AjaxButton("save") {
private static final long serialVersionUID = 1L;
@@ -253,6 +260,8 @@ public class UserPage extends RootPage {
user.getPreferences().setLocale(lang.code);
}
+ user.getPreferences().setEmailMeOnMyTicketChanges(emailMeOnMyTicketChanges.getObject());
+
try {
app().gitblit().reviseUser(user.username, user);