mirror of https://github.com/djcb/mu.git
mu-contacts: remove newlines from addresses
Seems gmime passes them on; and it causes havoc with our contacts cache. Bump database schema version to force an rebuild (since that's what's required.)
This commit is contained in:
parent
0dce3607d4
commit
8ec8ab5380
|
@ -182,7 +182,7 @@ AC_SUBST(XAPIAN_LIBS)
|
||||||
# note that MU_STORE_SCHEMA_VERSION does not necessarily follow MU
|
# note that MU_STORE_SCHEMA_VERSION does not necessarily follow MU
|
||||||
# versioning, as we hopefully don't have updates for each version;
|
# versioning, as we hopefully don't have updates for each version;
|
||||||
# also, this has nothing to do with Xapian's software version
|
# also, this has nothing to do with Xapian's software version
|
||||||
AC_DEFINE(MU_STORE_SCHEMA_VERSION,["0.999"], ['Schema' version of the database])
|
AC_DEFINE(MU_STORE_SCHEMA_VERSION,["1.3"], ['Schema' version of the database])
|
||||||
###############################################################################
|
###############################################################################
|
||||||
|
|
||||||
###############################################################################
|
###############################################################################
|
||||||
|
|
|
@ -24,6 +24,7 @@
|
||||||
#include <set>
|
#include <set>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <functional>
|
#include <functional>
|
||||||
|
#include <algorithm>
|
||||||
|
|
||||||
#include <parser/utils.hh>
|
#include <parser/utils.hh>
|
||||||
#include <glib.h>
|
#include <glib.h>
|
||||||
|
@ -168,6 +169,15 @@ Contacts::serialize() const
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// for now, we only care about _not_ having newlines.
|
||||||
|
static void
|
||||||
|
wash (std::string& str)
|
||||||
|
{
|
||||||
|
str.erase(std::remove(str.begin(), str.end(), '\n'), str.end());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
Contacts::add (ContactInfo&& ci)
|
Contacts::add (ContactInfo&& ci)
|
||||||
{
|
{
|
||||||
|
@ -183,12 +193,20 @@ Contacts::add (ContactInfo&& ci)
|
||||||
++ci2.freq;
|
++ci2.freq;
|
||||||
if (ci.last_seen > ci2.last_seen) {
|
if (ci.last_seen > ci2.last_seen) {
|
||||||
ci2.last_seen = ci.last_seen;
|
ci2.last_seen = ci.last_seen;
|
||||||
|
wash(ci.email);
|
||||||
ci2.email = std::move(ci.email);
|
ci2.email = std::move(ci.email);
|
||||||
if (!ci.name.empty())
|
if (!ci.name.empty()) {
|
||||||
|
wash(ci.name);
|
||||||
ci2.name = std::move(ci.name);
|
ci2.name = std::move(ci.name);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else
|
}
|
||||||
priv_->contacts_.emplace(
|
|
||||||
|
wash(ci.name);
|
||||||
|
wash(ci.email);
|
||||||
|
wash(ci.full_address);
|
||||||
|
|
||||||
|
priv_->contacts_.emplace(
|
||||||
ContactUMap::value_type(std::move(email), std::move(ci)));
|
ContactUMap::value_type(std::move(email), std::move(ci)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue