use of com.zimbra.cs.mime.ParsedAddress in project zm-mailbox by Zimbra.
the class SenderList method importAddress.
private static ParsedAddress importAddress(Metadata meta) {
if (meta == null)
return null;
ParsedAddress pa = new ParsedAddress(meta.get(FN_EMAIL, null), meta.get(FN_PERSONAL, null));
pa.firstName = meta.get(FN_DISPLAY, null);
return pa;
}
use of com.zimbra.cs.mime.ParsedAddress in project zm-mailbox by Zimbra.
the class SenderList method toString.
@Override
public String toString() {
Metadata meta = new Metadata();
meta.put(Metadata.FN_NODES, mSize);
meta.put(Metadata.FN_LAST_DATE, mLastDate);
meta.put(Metadata.FN_ELIDED, mIsElided);
if (mParticipants != null && !mParticipants.isEmpty()) {
MetadataList entries = new MetadataList();
for (ParsedAddress pa : mParticipants) entries.add(exportAddress(pa));
meta.put(Metadata.FN_ENTRIES, entries);
}
return meta.toString();
}
use of com.zimbra.cs.mime.ParsedAddress in project zm-mailbox by Zimbra.
the class SenderList method add.
public SenderList add(Message msg) throws RefreshException {
String sender = msg.getSender();
if (sender == null || sender.trim().equals("")) {
mSize++;
return this;
}
long date = msg.getDate();
if (date < mLastDate)
throw new RefreshException("appended message predates existing last message");
mLastDate = date;
mSize++;
ParsedAddress pa = new ParsedAddress(sender).parse();
if (mParticipants == null) {
(mParticipants = new ArrayList<ParsedAddress>(MAX_PARTICIPANT_COUNT)).add(pa);
} else {
mParticipants.remove(pa);
mParticipants.add(0, pa);
while (mParticipants.size() > MAX_PARTICIPANT_COUNT) {
mParticipants.remove(MAX_PARTICIPANT_COUNT);
mIsElided = true;
}
}
return this;
}
use of com.zimbra.cs.mime.ParsedAddress in project zm-mailbox by Zimbra.
the class SocialcastTest method executeBasic.
@Override
protected boolean executeBasic(MailAdapter mail, Arguments args, SieveContext ctx) throws SieveException {
if (mail instanceof DummyMailAdapter) {
return true;
}
if (!(mail instanceof ZimbraMailAdapter)) {
return false;
}
ZimbraMailAdapter adapter = (ZimbraMailAdapter) mail;
ParsedMessage pm = adapter.getParsedMessage();
ParsedAddress sender = pm.getParsedSender();
if (!Strings.isNullOrEmpty(sender.emailPart) && sender.emailPart.endsWith("@socialcast.com")) {
try {
if (pm.getMimeMessage().getHeader("Reply-To", null) != null) {
// test if Reply-To exists
return true;
}
} catch (MessagingException ignore) {
}
}
return false;
}
use of com.zimbra.cs.mime.ParsedAddress in project zm-mailbox by Zimbra.
the class TwitterTest method executeBasic.
@Override
protected boolean executeBasic(MailAdapter mail, Arguments args, SieveContext ctx) throws SieveException {
if (mail instanceof DummyMailAdapter) {
return true;
}
if (!(mail instanceof ZimbraMailAdapter)) {
return false;
}
ZimbraMailAdapter adapter = (ZimbraMailAdapter) mail;
ParsedAddress sender = adapter.getParsedMessage().getParsedSender();
if (!Strings.isNullOrEmpty(sender.emailPart)) {
String email = sender.emailPart.toLowerCase();
if (email.equals("notify@twitter.com")) {
return true;
}
}
return false;
}
Aggregations