~ubuntu-branches/ubuntu/vivid/phabricator/vivid-proposed

« back to all changes in this revision

Viewing changes to phabricator/src/applications/metamta/receiver/PhabricatorMailReceiver.php

  • Committer: Package Import Robot
  • Author(s): Richard Sellam
  • Date: 2015-01-29 00:15:58 UTC
  • mfrom: (0.16.1) (0.15.1) (0.12.2) (2.1.4 sid)
  • Revision ID: package-import@ubuntu.com-20150129001558-na84707j70qqla7z
Tags: 0~git20150129-1
* New snapshot release
* restricted access to local config file (closes: #775479)
* moved local config file to /var/lib/phabricator (closes: #775478)
* switched mysql-server dependency to recommends (closes: #773536)
* use /run instead of /var/run (closes: #775803)
* prevent package reinstall from overwritting local changes (closes: #776288)

Show diffs side-by-side

added added

removed removed

Lines of Context:
2
2
 
3
3
abstract class PhabricatorMailReceiver {
4
4
 
 
5
  private $applicationEmail;
 
6
 
 
7
  public function setApplicationEmail(
 
8
    PhabricatorMetaMTAApplicationEmail $email) {
 
9
    $this->applicationEmail = $email;
 
10
    return $this;
 
11
  }
 
12
 
 
13
  public function getApplicationEmail() {
 
14
    return $this->applicationEmail;
 
15
  }
 
16
 
5
17
  abstract public function isEnabled();
6
18
  abstract public function canAcceptMail(PhabricatorMetaMTAReceivedMail $mail);
7
19
 
 
20
 
8
21
  abstract protected function processReceivedMail(
9
22
    PhabricatorMetaMTAReceivedMail $mail,
10
23
    PhabricatorUser $sender);
15
28
    $this->processReceivedMail($mail, $sender);
16
29
  }
17
30
 
 
31
  public function getViewer() {
 
32
    return PhabricatorUser::getOmnipotentUser();
 
33
  }
 
34
 
18
35
  public function validateSender(
19
36
    PhabricatorMetaMTAReceivedMail $mail,
20
37
    PhabricatorUser $sender) {
103
120
    if ($allow_email_users) {
104
121
      $from_obj = new PhutilEmailAddress($from);
105
122
      $xuser = id(new PhabricatorExternalAccountQuery())
106
 
        ->setViewer(PhabricatorUser::getOmnipotentUser())
 
123
        ->setViewer($this->getViewer())
107
124
        ->withAccountTypes(array('email'))
108
125
        ->withAccountDomains(array($from_obj->getDomainName(), 'self'))
109
126
        ->withAccountIDs(array($from_obj->getAddress()))
124
141
        $raw_from);
125
142
    }
126
143
 
 
144
    if ($this->getApplicationEmail()) {
 
145
      $application_email = $this->getApplicationEmail();
 
146
      $default_user_phid = $application_email->getConfigValue(
 
147
        PhabricatorMetaMTAApplicationEmail::CONFIG_DEFAULT_AUTHOR);
 
148
 
 
149
      if ($default_user_phid) {
 
150
        $user = id(new PhabricatorUser())->loadOneWhere(
 
151
          'phid = %s',
 
152
          $default_user_phid);
 
153
        if ($user) {
 
154
          return $user;
 
155
        }
 
156
      }
 
157
 
 
158
      $reasons[] = pht(
 
159
        "Phabricator is misconfigured, the application email ".
 
160
        "'%s' is set to user '%s' but that user does not exist.",
 
161
        $application_email->getAddress(),
 
162
        $default_user_phid);
 
163
    }
 
164
 
127
165
    $reasons = implode("\n\n", $reasons);
128
166
 
129
167
    throw new PhabricatorMetaMTAReceivedMailProcessingException(