mirror of
https://github.com/inverse-inc/sogo.git
synced 2026-05-31 08:04:54 +00:00
feat(notification): add enotify sieve script
This commit is contained in:
@@ -12,6 +12,7 @@
|
||||
var vm = this,
|
||||
sieveCapabilities = $window.sieveCapabilities,
|
||||
forwardEnabled = $window.forwardEnabled,
|
||||
notificationEnabled = $window.notificationEnabled,
|
||||
vacationEnabled = $window.vacationEnabled;
|
||||
|
||||
this.filter = filter;
|
||||
@@ -40,6 +41,9 @@
|
||||
if (forwardEnabled)
|
||||
this.methodLabels.redirect = l("Forward the message to");
|
||||
|
||||
if (notificationEnabled)
|
||||
this.methodLabels.notify = l("Notify the message to");
|
||||
|
||||
//if (vacationEnabled)
|
||||
// this.methodLabels.vacation = l("Send a vacation message");
|
||||
|
||||
@@ -59,6 +63,7 @@
|
||||
"keep",
|
||||
"discard",
|
||||
"redirect",
|
||||
"notify",
|
||||
"reject"
|
||||
];
|
||||
this.methods = _.intersection(this.methods, _.keys(this.methodLabels));
|
||||
@@ -112,6 +117,15 @@
|
||||
this.invalid = err.message;
|
||||
return false;
|
||||
}
|
||||
try {
|
||||
_.forEach(_.filter(this.filter.actions, { 'method': 'notify' }), function (action) {
|
||||
validateForwardAddress(action.argument);
|
||||
});
|
||||
} catch (err) {
|
||||
//Dialog.alert(l('Error'), err);
|
||||
this.invalid = err.message;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
$mdDialog.hide();
|
||||
};
|
||||
|
||||
@@ -150,6 +150,13 @@
|
||||
data.Forward.forwardAddress = [];
|
||||
}
|
||||
|
||||
if (data.Notification) {
|
||||
if (angular.isString(data.Notification.notificationAddress))
|
||||
data.Notification.notificationAddress = data.Notification.notificationAddress.split(/, */);
|
||||
else if (!angular.isArray(data.Notification.notificationAddress))
|
||||
data.Notification.notificationAddress = [];
|
||||
}
|
||||
|
||||
// Split calendar categories colors keys and values
|
||||
if (angular.isUndefined(data.SOGoCalendarCategories))
|
||||
data.SOGoCalendarCategories = [];
|
||||
@@ -865,6 +872,9 @@
|
||||
if (preferences.defaults.Forward && preferences.defaults.Forward.forwardAddress)
|
||||
preferences.defaults.Forward.forwardAddress = _.compact(preferences.defaults.Forward.forwardAddress);
|
||||
|
||||
if (preferences.defaults.Notification && preferences.defaults.Notification.notificationAddress)
|
||||
preferences.defaults.Notification.notificationAddress = _.compact(preferences.defaults.Notification.notificationAddress);
|
||||
|
||||
// Merge back calendar categories colors keys and values
|
||||
preferences.defaults.SOGoCalendarCategoriesColors = {};
|
||||
_.forEach(preferences.defaults.SOGoCalendarCategories, function(key, i) {
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
this.timeZonesList = $window.timeZonesList;
|
||||
this.timeZonesSearchText = '';
|
||||
this.addressesSearchText = '';
|
||||
this.autocompleteForward = {};
|
||||
this.autocomplete = {forward: [], notification: []};
|
||||
this.mailLabelKeyRE = new RegExp(/^(?!^_\$)[^(){} %*\"\\\\]*?$/);
|
||||
this.emailSeparatorKeys = Preferences.defaults.emailSeparatorKeys;
|
||||
if (Preferences.defaults.SOGoMailAutoMarkAsReadMode == 'delay')
|
||||
@@ -415,6 +415,20 @@
|
||||
}
|
||||
}
|
||||
|
||||
// We check if we're allowed or not to notify based on the domain defaults
|
||||
if (this.preferences.defaults.Notification && this.preferences.defaults.Notification.enabled &&
|
||||
this.preferences.defaults.Notification.notificationAddress) {
|
||||
addresses = this.preferences.defaults.Notification.notificationAddress;
|
||||
try {
|
||||
for (i = 0; i < addresses.length; i++) {
|
||||
validateForwardAddress(addresses[i]);
|
||||
}
|
||||
} catch (err) {
|
||||
Dialog.alert(l('Error'), err);
|
||||
sendForm = false;
|
||||
}
|
||||
}
|
||||
|
||||
// IMAP labels must be unique
|
||||
if (this.preferences.defaults.SOGoMailLabelsColorsKeys.length !=
|
||||
this.preferences.defaults.SOGoMailLabelsColorsValues.length ||
|
||||
@@ -650,10 +664,10 @@
|
||||
}
|
||||
};
|
||||
|
||||
this.addRecipient = function (contact) {
|
||||
this.addRecipient = function (contact, element) {
|
||||
var recipients, recipient, list, i, address;
|
||||
|
||||
recipients = this.preferences.defaults.Forward.forwardAddress;
|
||||
recipients = this.autocomplete[element];
|
||||
|
||||
if (angular.isString(contact)) {
|
||||
// Examples that are handled:
|
||||
@@ -678,7 +692,7 @@
|
||||
if (address && recipients.indexOf(address) < 0)
|
||||
recipients.push(address);
|
||||
|
||||
return null;
|
||||
return address;
|
||||
}
|
||||
|
||||
if (contact.$isList({expandable: true})) {
|
||||
@@ -712,7 +726,7 @@
|
||||
else {
|
||||
recipient = contact.$shortFormat();
|
||||
}
|
||||
|
||||
|
||||
if (recipient)
|
||||
return recipient;
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user