public boolean isAccountBeingUsed(Account account) { if (log.isDebugEnabled()) log.debug( String.format( "Checking account %s, user_id %s for last registration with location service", account.getId(), account.getUser_id())); IPeekLocationService locationService = new PeekLocationService(); Date lastUpdated = null; try { lastUpdated = locationService.getLastUpdatedTimestamp(account.getUser_id()); } catch (DALException e) { log.error(UtilsTools.getExceptionStackTrace(e)); } if (lastUpdated == null) { log.debug("Last updated value not found, so we should still check this account"); return true; } Date now = new Date(); Long interval = dayMultiplier * mailcheckDisableIntervalInHours; Long sinceLastConnection = now.getTime() - lastUpdated.getTime(); if (sinceLastConnection > interval) { if (log.isDebugEnabled()) log.debug( String.format( "Last mail check was %s hours ago, > %s hour interval , we will not check this account", sinceLastConnection / dayMultiplier, interval / dayMultiplier)); return false; } return true; }
/** * Deliveres notification to the user that an email has been dropped. Typically due to size * restriction * * @param account * @param messageNumber * @param message * @throws Exception */ public void saveMessageDroppedNotification( Account account, int messageNumber, Message message, int reportedSize) throws Exception { MessageParser parser = new MessageParser(); Email email = new Email(); email.setSubject( "Your email"); // ReceiverUtilsTools.subSubject(parser.parseMsgSubject(message), // subjectSize)); email.setFrom(parser.parseMsgAddress(message, "FROM", false)); email.setTo(ReceiverUtilsTools.subAddress(parser.parseMsgAddress(message, "TO", true))); email.setCc(ReceiverUtilsTools.subAddress(parser.parseMsgAddress(message, "CC", true))); email.setBcc(ReceiverUtilsTools.subAddress(parser.parseMsgAddress(message, "BCC", true))); email.setMaildate(ReceiverUtilsTools.dateToStr(message.getSentDate())); email.setStatus("0"); email.setUserId(account.getUser_id()); email.setMessage_type("EMAIL"); Body body = new Body(); String droppedMessage = getEmailDroppedMessage(account, getMessageDate(message), reportedSize, email.getFrom()); body.setData(droppedMessage.getBytes()); email.setBodySize(droppedMessage.length()); int saveStatus = DALDominator.newSaveMail(account, email, body); if (log.isDebugEnabled()) log.debug( String.format( "[%s] msgNum=%d, saving completed for dropped message with status %s", account.getName(), messageNumber, saveStatus)); }
public void notifyAccountLock(Account account, String context) { PartnerCode partnerCode = account.getPartnerCode(); String lockedOutMessageBody = SysConfigManager.instance() .getValue("lockedOutMessageBody", LOCKED_OUT_MESSAGE_BODY, partnerCode); String lockedOutMessageSubject = SysConfigManager.instance() .getValue("lockedOutMessageSubject", LOCKED_OUT_MESSAGE_SUBJECT, partnerCode); String lockedOutMessageFrom = SysConfigManager.instance() .getValue("lockedOutMessageFrom", LOCKED_OUT_MESSAGE_FROM, partnerCode); String lockedOutMessageAlias = SysConfigManager.instance() .getValue("lockedOutMessageAlias", LOCKED_OUT_MESSAGE_ALIAS, partnerCode); try { Email email = new Email(); email.setSubject(lockedOutMessageSubject); email.setStatus("0"); email.setUserId(account.getUser_id()); email.setMessage_type("EMAIL"); email.setFrom(lockedOutMessageFrom); email.setFrom_alias(lockedOutMessageAlias); email.setTo(account.getLoginName()); email.setBodySize(lockedOutMessageBody.length()); DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); email.setMaildate(dateFormat.format(new Date(System.currentTimeMillis()))); // ugh! email.setOriginal_account(account.getLoginName()); // create the pojgo EmailPojo emailPojo = new EmailPojo(); emailPojo.setEmail(email); Body body = new Body(); body.setData(lockedOutMessageBody.getBytes()); // note, the email will be encoded to prevent sql-injection. since this email is destined // directly for the // device, we need to reverse the encoding after the call to newSaveEmail new EmailRecievedService().newSaveEmail(account, email, body); // Added by Dan so we stop checking accounts that have incorrect passwords account.setStatus("0"); } catch (Throwable t) { log.warn(String.format("failed to save locked out message for %s", context), t); } }