Example #1
0
 public function process($raw_mail)
 {
     $incoming_message = $this->parser->parse($raw_mail);
     $user = $incoming_message->getRecipient()->getUser();
     $artifact = $incoming_message->getRecipient()->getArtifact();
     $this->logger->debug("Receiving new follow-up comment from " . $user->getUserName());
     if (!$artifact->userCanUpdate($user)) {
         $this->logger->info("User " . $user->getUnixName() . " has no right to update the artifact #" . $artifact->getId());
         return;
     }
     $body = $this->citation_stripper->stripText($incoming_message->getBody());
     $artifact->createNewChangeset(array(), $body, $user, true, Tracker_Artifact_Changeset_Comment::TEXT_COMMENT);
 }
Example #2
0
 public function process($raw_mail)
 {
     $raw_mail_parsed = $this->parser->parse($raw_mail);
     try {
         $incoming_message = $this->incoming_message_factory->build($raw_mail_parsed);
         $body = $this->citation_stripper->stripText($incoming_message->getBody());
         $tracker_artifactbyemail = new Tracker_ArtifactByEmailStatus($incoming_message->getTracker(), $this->tracker_plugin_config);
         if ($tracker_artifactbyemail->canCreateArtifact() || $tracker_artifactbyemail->canUpdateArtifact()) {
             $this->createChangeset($incoming_message, $body, $raw_mail);
         } else {
             $this->logger->info('An artifact for the tracker #' . $incoming_message->getTracker()->getId() . ' has been received but this tracker does not allow create/reply by mail or' . ' his configuration is not compatible with this feature');
             $this->notifier->sendErrorMailTrackerGeneric($raw_mail_parsed);
         }
     } catch (Tracker_Artifact_MailGateway_MultipleUsersExistException $e) {
         $this->logger->debug('Multiple users match with ' . $raw_mail_parsed['headers']['from']);
         $this->notifier->sendErrorMailMultipleUsers($raw_mail_parsed);
     } catch (Tracker_Artifact_MailGateway_RecipientUserDoesNotExistException $e) {
         $this->logger->debug('No user match with ' . $raw_mail_parsed['headers']['from']);
         $this->notifier->sendErrorMailNoUserMatch($raw_mail_parsed);
     } catch (Tracker_Exception $e) {
         $this->logger->error($e->getMessage());
         $this->notifier->sendErrorMailTrackerGeneric($raw_mail_parsed);
     }
 }
Example #3
0
 /**
  * @return Tracker_Artifact_Changeset|null
  */
 private function createChangeset(array $raw_mail_parsed)
 {
     $changeset = null;
     $incoming_message = $this->incoming_message_factory->build($raw_mail_parsed);
     $body = $this->citation_stripper->stripText($incoming_message->getBody());
     if ($incoming_message->isAFollowUp()) {
         if ($this->canUpdateArtifact($incoming_message->getTracker())) {
             $changeset = $this->addFollowUp($incoming_message->getUser(), $incoming_message->getArtifact(), $body);
         } else {
             $this->logNoSufficientRightsToCreateChangeset($incoming_message, $raw_mail_parsed);
         }
     } else {
         if ($this->canCreateArtifact($incoming_message->getTracker())) {
             $artifact = $this->createArtifact($incoming_message->getUser(), $incoming_message->getTracker(), $incoming_message->getSubject(), $body);
             if ($artifact) {
                 $this->logger->debug('New artifact created: ' . $artifact->getXRef());
                 $changeset = $artifact->getFirstChangeset();
             }
         } else {
             $this->logNoSufficientRightsToCreateChangeset($incoming_message, $raw_mail_parsed);
         }
     }
     return $changeset;
 }
 public function itStripsCitationFromEnglishOutlook()
 {
     $parsed_text_content = file_get_contents($this->fixtures_dir . '/outlook_quote_en.txt');
     $text_content_witout_citation = file_get_contents($this->fixtures_dir . '/expected_followup_outlook_quote_en.txt');
     $this->assertIdentical($this->citation_stripper->stripText($parsed_text_content), $text_content_witout_citation);
 }