From c9a4996cefa55ed8fb4571f440bd81e74fc91167 Mon Sep 17 00:00:00 2001 From: Abyss777 Date: Mon, 11 Jul 2016 10:43:26 +0500 Subject: - "from" sometimes not handled by mail servers - better handle empty mail user attributes - fix deleting attribute in attribute editor - fix duplicating attribute if name changed --- src/org/traccar/notification/NotificationMail.java | 16 +++++++++++++--- web/app/view/AttributesController.js | 9 +++++++-- 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/src/org/traccar/notification/NotificationMail.java b/src/org/traccar/notification/NotificationMail.java index 443018221..944200f2f 100644 --- a/src/org/traccar/notification/NotificationMail.java +++ b/src/org/traccar/notification/NotificationMail.java @@ -87,9 +87,15 @@ public final class NotificationMail { boolean auth = Boolean.parseBoolean((String) object.getAttributes().get("mail.smtp.auth")); result.put("mail.smtp.auth", auth); - result.put("mail.smtp.username", object.getAttributes().get("mail.smtp.username")); - result.put("mail.smtp.password", object.getAttributes().get("mail.smtp.password")); - result.put("mail.smtp.from", object.getAttributes().get("mail.smtp.from")); + if (object.getAttributes().containsKey("mail.smtp.username")) { + result.put("mail.smtp.username", object.getAttributes().get("mail.smtp.username")); + } + if (object.getAttributes().containsKey("mail.smtp.password")) { + result.put("mail.smtp.password", object.getAttributes().get("mail.smtp.password")); + } + if (object.getAttributes().containsKey("mail.smtp.from")) { + result.put("mail.smtp.from", object.getAttributes().get("mail.smtp.from")); + } } return result; } @@ -115,6 +121,10 @@ public final class NotificationMail { mailMessage = new MimeMessage(mailSession); + if (mailServerProperties.getProperty("mail.smtp.from") != null) { + mailMessage.setFrom(new InternetAddress(mailServerProperties.getProperty("mail.smtp.from"))); + } + mailMessage.addRecipient(Message.RecipientType.TO, new InternetAddress( Context.getDataManager().getUser(userId).getEmail())); mailMessage.setSubject(NotificationFormatter.formatTitle(userId, event, position)); diff --git a/web/app/view/AttributesController.js b/web/app/view/AttributesController.js index 663b6eae3..3959c5a5c 100644 --- a/web/app/view/AttributesController.js +++ b/web/app/view/AttributesController.js @@ -37,17 +37,22 @@ Ext.define('Traccar.view.AttributesController', { store.addListener('add', function (store , records , index , eOpts) { for (var i = 0; i < records.length; i++) { this.getView().record.get('attributes')[records[i].get('name')] = records[i].get('value'); - this.getView().record.dirty = true; } + this.getView().record.dirty = true; }, this); store.addListener('update', function (store, record, operation , modifiedFieldNames , details , eOpts) { if (operation === Ext.data.Model.EDIT) { + if (record.modified.name !== record.get('name')) { + delete this.getView().record.get('attributes')[record.modified.name]; + } this.getView().record.get('attributes')[record.get('name')] = record.get('value'); this.getView().record.dirty = true; } }, this); store.addListener('remove', function (store , records , index , isMove , eOpts) { - delete this.getView().record.get('attributes')[records[index].get('name')]; + for (var i = 0; i < records.length; i++) { + delete this.getView().record.get('attributes')[records[i].get('name')]; + } this.getView().record.dirty = true; }, this); -- cgit v1.2.3