コード例 #1
0
ファイル: NewProviderSupport.java プロジェクト: phcd/TAB
 public boolean isMessageTooOld(Account account, Message message, String context)
     throws MessagingException {
   if (message.getSentDate() == null) {
     log.warn(
         String.format("we have a message with no sent date for %s, allowing message", context));
     return false;
   } else if (account.getRegister_time() == null) {
     log.warn(
         String.format(
             "we are process an account with no register time. this behavior is not understood yet %s, we will accept this message",
             context));
     return false;
   } else {
     boolean messageTooOld =
         (System.currentTimeMillis() - message.getSentDate().getTime())
             > 1000l * 60 * 60 * 24 * emailDaysCutoff;
     if (messageTooOld) {
       log.warn(
           String.format(
               "msgNum=%d, message is too old, sentDate=%s, discarding, for %s",
               message.getMessageNumber(), message.getSentDate(), context));
     }
     return messageTooOld;
   }
 }
コード例 #2
0
ファイル: NewProviderSupport.java プロジェクト: phcd/TAB
  /**
   * It so happens Gmail sends us sent messages as well as received once
   *
   * @param account
   * @param message
   * @return
   * @throws Exception
   */
  protected boolean isSentMessage(Account account, Message message) throws Exception {
    MessageParser parser = new MessageParser();

    if (EmailUtil.isFromSameAsAccount(account, message)) {
      String to = parser.parseMsgAddress(message, "TO", true);
      String cc = parser.parseMsgAddress(message, "CC", true);

      if (!to.contains(account.getName()) && !cc.contains(account.getName())) {
        log.warn(
            String.format(
                "msgNum=%d, message is 'sent' not 'received' discarding, for %s",
                message.getMessageNumber(), account.getName()));
        return true;
      }
    }

    return false;
  }