Ejemplo n.º 1
0
 protected function createBounceActivity(ImapMessage $message)
 {
     $zurmoItemClass = null;
     $zurmoItemId = null;
     $zurmoPersonId = null;
     $headerTags = array('zurmoItemId', 'zurmoItemClass', 'zurmoPersonId');
     $headers = EmailBounceUtil::resolveCustomHeadersFromTextBody($headerTags, $message->textBody);
     $this->deleteMessage($message);
     if ($headers === false) {
         return false;
     }
     extract($headers);
     assert('$zurmoItemClass === "AutoresponderItem" || $zurmoItemClass === "CampaignItem"');
     assert('$zurmoItemId > 0');
     assert('$zurmoPersonId > 0');
     $activityClassName = EmailMessageActivityUtil::resolveModelClassNameByModelType($zurmoItemClass);
     $activityUtilClassName = $activityClassName . 'Util';
     $type = $activityClassName::TYPE_BOUNCE;
     $activityData = array('modelId' => $zurmoItemId, 'modelType' => $zurmoItemClass, 'personId' => $zurmoPersonId, 'url' => null, 'type' => $type);
     $activityCreatedOrUpdated = $activityUtilClassName::createOrUpdateActivity($activityData);
     try {
         if (!$activityCreatedOrUpdated) {
             throw new NotSupportedException();
         }
     } catch (NotSupportedException $e) {
         return false;
     }
     return true;
 }
Ejemplo n.º 2
0
 public function testResolveCustomHeadersFromTextBody()
 {
     $headerTags = array('From', 'zurmoItemId', 'zurmoPersonId', 'zurmoItemClass', 'X-Google-Sender-Auth');
     $headers = EmailBounceUtil::resolveCustomHeadersFromTextBody($headerTags, static::$textBody);
     $this->assertNotEmpty($headers);
     $this->assertEquals('postmaster', $headers['From']);
     $this->assertEquals(10, $headers['zurmoItemId']);
     $this->assertEquals(20, $headers['zurmoPersonId']);
     $this->assertEquals('AutoresponderItem', $headers['zurmoItemClass']);
     $this->assertEquals('KOGyLSQUS92LYi12duzB4F5GulU', $headers['X-Google-Sender-Auth']);
 }