Skip to content

Commit

Permalink
fix(Felamimail/js): reply message using reply to header
Browse files Browse the repository at this point in the history
  • Loading branch information
ccheng-dev committed Nov 12, 2024
1 parent b3ad391 commit 70d7a22
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 12 deletions.
4 changes: 2 additions & 2 deletions tine20/Felamimail/css/Felamimail.css
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@
.preview-panel-felamimail-headers {
background-color: #dddddd;
overflow: auto;
padding: 5px;
padding: 10px;
}

.preview-panel-felamimail-header-row {
Expand All @@ -162,7 +162,7 @@

.preview-panel-felamimail-header-row-left {
font-weight: bold;
min-width: 50px;
min-width: 60px;
text-align: right;
}

Expand Down
19 changes: 12 additions & 7 deletions tine20/Felamimail/js/MailDetailsPanel.js
Original file line number Diff line number Diff line change
Expand Up @@ -224,8 +224,9 @@ Ext.extend(Tine.Felamimail.MailDetailsPanel, Ext.Panel, {
},
showInfo(values) {
const app = Tine.Tinebase.appMgr.get('Felamimail');
const items = ['subject', 'date', 'from', 'to', 'cc', 'bcc', 'extra'];
const items = ['subject', 'date', 'from', 'to', 'reply-to', 'cc', 'bcc', 'extra'];
const headerBlock = document.createElement('div');

headerBlock.className = 'preview-panel-felamimail-headers';
items.forEach((header) => {
let value = '';
Expand All @@ -235,9 +236,12 @@ Ext.extend(Tine.Felamimail.MailDetailsPanel, Ext.Panel, {
if (header === 'date') value = this.showDate(values.sent, values);
if (header === 'extra') headerValue = this.panel.showExtraHeaderButton();

if (['to', 'cc', 'bcc'].includes(header)) {
if (['to', 'reply-to', 'cc', 'bcc'].includes(header)) {
if (!values.headers.hasOwnProperty(header)) return;
const emails = this.panel.record.get(header);
let emails = this.panel.record.get(header) || values.headers[header];
if (typeof emails === 'string') {
emails = emails.split(/[,;]\s*/).map((email) => {return {email: email};});
}
if (emails.length === 0) return;
//TODO: bcc only store email in \Zend_Mail::addBcc($email), do we want to change it ?
emails.forEach((emailData, idx) => {
Expand Down Expand Up @@ -653,17 +657,18 @@ Ext.extend(Tine.Felamimail.MailDetailsPanel, Ext.Panel, {
renderHeaderRaw(header, value) {
const row = document.createElement('div');
row.style.display = 'flex';
row.style.margin = '5px';
row.style.flexDirection = 'row';
row.style.margin = '5px 0';
row.style.textAlign = 'left';
const rowLeft = document.createElement('div');
rowLeft.textContent = header;
rowLeft.style.minWidth = '60px';
rowLeft.style.minWidth = '100px';
const rowRight = document.createElement('div');
rowRight.innerHTML = value;

if (header.length > 10 || value.length > 50) {
if (header.length > 15) {
row.style.flexDirection = 'column';
rowRight.style.paddingLeft = '55px';
rowRight.style.paddingLeft = '100px';
}
row.appendChild(rowLeft);
row.appendChild(rowRight);
Expand Down
6 changes: 3 additions & 3 deletions tine20/Felamimail/js/MessageEditDialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -889,6 +889,8 @@ Tine.Felamimail.MessageEditDialog = Ext.extend(Tine.widgets.dialog.EditDialog, {
const replyToName = this.replyTo.get('from_name');
const replyToToken = this.replyTo.get('from')?.[0];

// reply-to header has the highest priority
if (replyToHeader) return replyToHeader;
// we might get the recipient token from server
if (replyToToken && replyToToken?.email) return this.replyTo.get('from');
if (replyToEmail) {
Expand All @@ -901,9 +903,7 @@ Tine.Felamimail.MessageEditDialog = Ext.extend(Tine.widgets.dialog.EditDialog, {
'contact_record': ''
}];
}
if (replyToHeader) {
return [replyToHeader];
}


return [];
},
Expand Down
11 changes: 11 additions & 0 deletions tine20/Felamimail/js/RecipientGrid.js
Original file line number Diff line number Diff line change
Expand Up @@ -724,6 +724,17 @@ Tine.Felamimail.RecipientGrid = Ext.extend(Ext.grid.EditorGridPanel, {
['to', 'cc', 'bcc'].forEach((type) => {
const promise = new Promise(async (resolve) => {
let contacts = this.record.data[type];

await Promise.all(contacts.map(async (contact) => {
if (_.isString(contact) && (contact.includes(',') || contact.includes(';'))) {
return await Tine.Tinebase.common.findContactsByEmailString(contact);
} else {
return contact;
}
})).then((result) => {
contacts = result.flat();
});

let emails = _.filter(contacts, (addressData) => {return _.isString(addressData)});
if (emails.length > 0) {
emails = _.join(emails, ', ');
Expand Down
3 changes: 3 additions & 0 deletions tine20/Felamimail/translations/de.po
Original file line number Diff line number Diff line change
Expand Up @@ -392,6 +392,9 @@ msgstr "Format beibehalten"
msgid "Reply-To"
msgstr "Antwortadresse"

msgid "Reply-to"
msgstr "Antwort an"

#: Model/Account.php:312
msgid "E-Mail"
msgstr "E-Mail"
Expand Down

0 comments on commit 70d7a22

Please sign in to comment.