mirror of
https://github.com/M66B/FairEmail.git
synced 2025-12-31 01:51:24 +01:00
Extend local contact info
This commit is contained in:
@@ -365,21 +365,24 @@ public class ServiceSend extends LifecycleService {
|
||||
for (Address recipient : message.to) {
|
||||
String email = ((InternetAddress) recipient).getAddress();
|
||||
String name = ((InternetAddress) recipient).getPersonal();
|
||||
List<EntityContact> contacts = db.contact().getContacts(EntityContact.TYPE_TO, email);
|
||||
if (contacts.size() == 0) {
|
||||
EntityContact contact = new EntityContact();
|
||||
EntityContact contact = db.contact().getContact(EntityContact.TYPE_TO, email);
|
||||
if (contact == null) {
|
||||
contact = new EntityContact();
|
||||
contact.type = EntityContact.TYPE_TO;
|
||||
contact.email = email;
|
||||
contact.name = name;
|
||||
db.contact().insertContact(contact);
|
||||
contact.avatar = message.avatar;
|
||||
contact.times_contacted = 1;
|
||||
contact.last_contacted = new Date().getTime();
|
||||
contact.id = db.contact().insertContact(contact);
|
||||
Log.i("Inserted recipient contact=" + contact);
|
||||
} else {
|
||||
EntityContact contact = contacts.get(0);
|
||||
if (name != null && !name.equals(contact.name)) {
|
||||
contact.name = name;
|
||||
db.contact().updateContact(contact);
|
||||
Log.i("Updated recipient contact=" + contact);
|
||||
}
|
||||
contact.name = name;
|
||||
contact.avatar = message.avatar;
|
||||
contact.times_contacted++;
|
||||
contact.last_contacted = new Date().getTime();
|
||||
db.contact().updateContact(contact);
|
||||
Log.i("Updated recipient contact=" + contact);
|
||||
}
|
||||
}
|
||||
} catch (MessagingException ex) {
|
||||
|
||||
Reference in New Issue
Block a user