Commit f75b224a authored by Chris's avatar Chris

Fixing the timestamp issue

parent 42984989
......@@ -7,6 +7,7 @@ class FreeLunchLabs_MailGun_Model_Email extends Mage_Core_Model_Abstract {
}
public function saveInitialSend($message, $sendResponse) {
/** @var Mage_Customer_Model_Customer $customer */
$customer = Mage::getModel('customer/customer');
$customer->setWebsiteId($message->getStore()->getWebsite()->getId());
$customer->loadByEmail($message->getPrimaryRecipient());
......@@ -19,7 +20,7 @@ class FreeLunchLabs_MailGun_Model_Email extends Mage_Core_Model_Abstract {
$this->setMailgunId(str_replace(array("<", ">"), "", $sendResponse->id));
$this->setSubject($message->getSubject());
$this->setBody($message->getHtmlBody());
$this->setDateSent(Mage::getSingleton('core/date')->gmtTimestamp());
$this->setDateSent(date("Y-m-d H:i:s", Mage::getSingleton('core/date')->gmtTimestamp()));
$this->save();
Mage::getModel('freelunchlabs_mailgun/event')->logEmailEvent($this->getId(), FreeLunchLabs_MailGun_Model_Event::GENERATED, $this);
......
......@@ -21,7 +21,7 @@ class FreeLunchLabs_MailGun_Model_Event extends Mage_Core_Model_Abstract {
public function logEmailEvent($emailId, $eventType, $email = false) {
$this->setEmailId($emailId);
$this->setEventType($eventType);
$this->setTimestamp(Mage::getSingleton('core/date')->gmtTimestamp());
$this->setTimestamp(date("Y-m-d H:i:s", Mage::getSingleton('core/date')->gmtTimestamp()));
$this->save();
}
......
......@@ -118,12 +118,13 @@ class FreeLunchLabs_MailGun_Model_Mailgun extends Mage_Core_Model_Abstract {
$email = Mage::getModel('freelunchlabs_mailgun/email')->loadByMailgunIdAndRecipient($mailgunEvent->message->headers->{'message-id'}, $mailgunEvent->recipient);
if($email->getId()) {
$event = Mage::getModel('freelunchlabs_mailgun/event')->loadByTimestampAndEmailId($mailgunEvent->timestamp, $email->getId());
$timestamp = date("Y-m-d H:i:s", $mailgunEvent->timestamp);
$event = Mage::getModel('freelunchlabs_mailgun/event')->loadByTimestampAndEmailId($timestamp, $email->getId());
if(!$event->getId()) {
$event->setEmailId($email->getId());
$event->setEventType($mailgunEvent->event);
$event->setTimestamp($mailgunEvent->timestamp);
$event->setTimestamp($timestamp);
$event->save();
}
}
......
......@@ -8,7 +8,7 @@ class FreeLunchLabs_MailGun_Model_Resource_Email_V1 extends Mage_Core_Model_Reso
public function deleteEmailTrackingLogs($days = false) {
if ($days) {
$daysPrior = date("Y-m-d H:i:s", Mage::getModel('core/date')->timestamp(time() - (86400 * $days)));
$daysPrior = date("Y-m-d H:i:s", Mage::getModel('core/date')->gmtTimestamp(time() - (86400 * $days)));
$where = " WHERE date_sent < '{$daysPrior}'";
} else {
$where = "";
......
......@@ -8,7 +8,7 @@ class FreeLunchLabs_MailGun_Model_Resource_Email_V2 extends Mage_Core_Model_Mysq
public function deleteEmailTrackingLogs($days = false) {
if ($days) {
$daysPrior = date("Y-m-d H:i:s", Mage::getModel('core/date')->timestamp(time() - (86400 * $days)));
$daysPrior = date("Y-m-d H:i:s", Mage::getModel('core/date')->gmtTimestamp(time() - (86400 * $days)));
$where = " WHERE date_sent < '{$daysPrior}'";
} else {
$where = "";
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment