Skip to content

Commit

Permalink
[FIX]compose&reply_all: Remove Selected Email or Sender Email from Re…
Browse files Browse the repository at this point in the history
…cipients List While Using 'Reply All'
  • Loading branch information
Baraka24 committed Jul 19, 2024
1 parent 4095dad commit 9a146dd
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 2 deletions.
4 changes: 2 additions & 2 deletions modules/smtp/modules.php
Original file line number Diff line number Diff line change
Expand Up @@ -1524,7 +1524,7 @@ function smtp_server_dropdown($data, $output_mod, $recip, $selected_id=false) {
$smtp_profiles = profiles_by_smtp_id($profiles, $vals['id']);
if (count($smtp_profiles) > 0) {
foreach ($smtp_profiles as $index => $profile) {
$res .= '<option ';
$res .= '<option data-email="'.$profile['address'].'"';
if ((string) $selected === sprintf('%s.%s', $vals['id'], ($index + 1)) || (! mb_strstr(strval($selected), '.') && strval($selected) === strval($vals['id']))) {
$res .= 'selected="selected" ';
}
Expand All @@ -1534,7 +1534,7 @@ function smtp_server_dropdown($data, $output_mod, $recip, $selected_id=false) {
}
}
else {
$res .= '<option ';
$res .= '<option data-email="'.$vals['user'].'"';
if ($selected === $id) {
$res .= 'selected="selected" ';
}
Expand Down
32 changes: 32 additions & 0 deletions modules/smtp/site.js
Original file line number Diff line number Diff line change
Expand Up @@ -611,5 +611,37 @@ $(function () {
$(".bubble_dropdown-content").remove();
$(this).parent().remove();
});

var selectedOption = $('#compose_smtp_id option[selected]');
var selectedEmail = selectedOption.data('email');
var selectedVal = selectedOption.val();

var recipientsInput = $('#compose_cc');
var excludedEmail = null;

const excludeEmail = function () {
var newRecipients = recipientsInput.val().split(',').filter(function(email) {
if (email.includes(selectedEmail)) {
excludedEmail = email;
return false;
}
return true;
}).join(', ');
recipientsInput.val(newRecipients);
};

if (recipientsInput.val().includes(selectedEmail)) {
excludeEmail();
$(document).on('change', '#compose_smtp_id', function() {
if ($(this).val() !== selectedVal) {
if (!recipientsInput.val().includes(selectedEmail)) {
recipientsInput.val(recipientsInput.val() + ', ' + excludedEmail);
}
} else {
excludeEmail();
}
});
}

}
});

0 comments on commit 9a146dd

Please sign in to comment.