mirror of https://github.com/djcb/mu.git
contacts-cache: handle 'personal' mail for groups
When passing a vec of _all_ contacts for some message, mark _all_ of them as personal if at least _one_ is a personal address.
This commit is contained in:
parent
d0619b1db2
commit
bb6d271a23
|
@ -194,10 +194,10 @@ ContactsCache::add(Contact&& contact)
|
||||||
|
|
||||||
if (it == priv_->contacts_.end()) { // completely new contact
|
if (it == priv_->contacts_.end()) { // completely new contact
|
||||||
|
|
||||||
contact.name = contact.name;
|
contact.name = contact.name;
|
||||||
if (!contact.personal)
|
if (!contact.personal)
|
||||||
contact.personal = is_personal(contact.email);
|
contact.personal = is_personal(contact.email);
|
||||||
contact.tstamp = g_get_monotonic_time();
|
contact.tstamp = g_get_monotonic_time();
|
||||||
|
|
||||||
auto email{contact.email};
|
auto email{contact.email};
|
||||||
// return priv_->contacts_.emplace(ContactUMap::value_type(email, std::move(contact)))
|
// return priv_->contacts_.emplace(ContactUMap::value_type(email, std::move(contact)))
|
||||||
|
@ -219,6 +219,20 @@ ContactsCache::add(Contact&& contact)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
ContactsCache::add(Contacts&& contacts)
|
||||||
|
{
|
||||||
|
const auto personal = seq_find_if(contacts,[&](auto&& c){
|
||||||
|
return is_personal(c.email); }) != contacts.cend();
|
||||||
|
|
||||||
|
for (auto&& contact: contacts) {
|
||||||
|
contact.personal = personal;
|
||||||
|
add(std::move(contact));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
const Contact*
|
const Contact*
|
||||||
ContactsCache::_find(const std::string& email) const
|
ContactsCache::_find(const std::string& email) const
|
||||||
{
|
{
|
||||||
|
|
|
@ -60,15 +60,14 @@ public:
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add a contacts sequemce
|
* Add a contacts sequence; this should be used for the contacts of a
|
||||||
|
* specific message, and determines if it is a "personal" message:
|
||||||
|
* if any of the contacts matches one of the personal addresses,
|
||||||
|
* any of the senders/recipients are considered "personal"
|
||||||
*
|
*
|
||||||
* @param contacts a Contact object sequence
|
* @param contacts a Contact object sequence
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
void add(Contacts&& contacts) {
|
void add(Contacts&& contacts);
|
||||||
for (auto&& contact: contacts)
|
|
||||||
add(std::move(contact));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Clear all contacts
|
* Clear all contacts
|
||||||
|
|
Loading…
Reference in New Issue