Don't expand groups without id

Skipping redundant request for cases like ACL plugin where we may deal
with groups that may have no mail, id nor source assigned in acl identifier
autocompletion.
pull/6811/head
Aleksander Machniak 6 years ago
parent 0a0ad2c9b7
commit 7846505fa4

@ -5794,29 +5794,30 @@ function rcube_webmail()
if (id === null || !this.env.contacts[id] || !this.ksearch_input) if (id === null || !this.env.contacts[id] || !this.ksearch_input)
return; return;
var trigger = false, insert = '', delim = ', '; var trigger = false, insert = '', delim = ', ',
contact = this.env.contacts[id];
this.ksearch_destroy(); this.ksearch_destroy();
// insert all members of a group // insert all members of a group
if (typeof this.env.contacts[id] === 'object' && this.env.contacts[id].type == 'group' && !this.env.contacts[id].email) { if (typeof contact === 'object' && contact.type == 'group' && !contact.email && contact.id) {
insert += this.env.contacts[id].name + delim; insert = contact.name + delim;
this.group2expand[this.env.contacts[id].id] = $.extend({ input: this.ksearch_input }, this.env.contacts[id]); this.group2expand[contact.id] = $.extend({input: this.ksearch_input}, contact);
this.http_request('mail/group-expand', {_source: this.env.contacts[id].source, _gid: this.env.contacts[id].id}, false); this.http_request('mail/group-expand', {_source: contact.source, _gid: contact.id}, false);
} }
else if (typeof this.env.contacts[id] === 'object' && this.env.contacts[id].name) { else if (typeof contact === 'object' && contact.name) {
insert = this.env.contacts[id].name + delim; insert = contact.name + delim;
trigger = true; trigger = true;
} }
else if (typeof this.env.contacts[id] === 'string') { else if (typeof contact === 'string') {
insert = this.env.contacts[id] + delim; insert = contact + delim;
trigger = true; trigger = true;
} }
this.ksearch_input_replace(this.ksearch_value, insert); this.ksearch_input_replace(this.ksearch_value, insert);
if (trigger) { if (trigger) {
this.triggerEvent('autocomplete_insert', { field:this.ksearch_input, insert:insert, data:this.env.contacts[id], search:this.ksearch_value_last, result_type:'person' }); this.triggerEvent('autocomplete_insert', {field: this.ksearch_input, insert: insert, data: contact, search: this.ksearch_value_last, result_type: 'person'});
this.ksearch_value_last = null; this.ksearch_value_last = null;
this.compose_type_activity++; this.compose_type_activity++;
} }

Loading…
Cancel
Save