X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=lib%2Fmailhandler.php;h=a71633519391120d445df9807ae9420763012179;hb=7220b3ddd4a32b947e851c946cb6ad6146bebf7d;hp=890f6d5b49fea9decfaf8476b0c3dbe5e28cb70c;hpb=94aca655ef4128859285b86a78f85537aa9848e8;p=quix0rs-gnu-social.git diff --git a/lib/mailhandler.php b/lib/mailhandler.php index 890f6d5b49..a716335193 100644 --- a/lib/mailhandler.php +++ b/lib/mailhandler.php @@ -18,11 +18,10 @@ */ require_once(INSTALLDIR . '/lib/mail.php'); -require_once(INSTALLDIR . '/lib/mediafile.php'); require_once('Mail/mimeDecode.php'); -# FIXME: we use both Mail_mimeDecode and mailparse -# Need to move everything to mailparse +// @todo FIXME: we use both Mail_mimeDecode and mailparse +// Need to move everything to mailparse class MailHandler { @@ -34,19 +33,23 @@ class MailHandler { list($from, $to, $msg, $attachments) = $this->parse_message($rawmessage); if (!$from || !$to || !$msg) { + // TRANS: Error message in incoming mail handler used when an incoming e-mail cannot be processed. $this->error(null, _('Could not parse message.')); } common_log(LOG_INFO, "Mail from $from to $to with ".count($attachments) .' attachment(s): ' .substr($msg, 0, 20)); $user = $this->user_from_header($from); if (!$user) { + // TRANS: Error message in incoming mail handler used when an incoming e-mail is not from a registered user. $this->error($from, _('Not a registered user.')); return false; } if (!$this->user_match_to($user, $to)) { + // TRANS: Error message in incoming mail handler used when an incoming e-mail is not from a user's incoming e-mail address. $this->error($from, _('Sorry, that is not your incoming email address.')); return false; } if (!$user->emailpost) { + // TRANS: Error message in incoming mail handler used when no incoming e-mail is allowed. $this->error($from, _('Sorry, no incoming email allowed.')); return false; } @@ -55,21 +58,22 @@ class MailHandler return true; } $msg = $this->cleanup_msg($msg); - $msg = common_shorten_links($msg); + $msg = $user->shortenLinks($msg); if (Notice::contentTooLong($msg)) { - $this->error($from, sprintf(_('That\'s too long. '. - 'Max notice size is %d chars.'), + // TRANS: Error message in incoming mail handler used when an incoming e-mail contains too many characters. + $this->error($from, sprintf(_m('That\'s too long. Maximum notice size is %d character.', + 'That\'s too long. Maximum notice size is %d characters.', + Notice::maxContent()), Notice::maxContent())); } $mediafiles = array(); foreach($attachments as $attachment){ - $mf = null; try { - $mf = MediaFile::fromFileHandle($attachment, $user); + $mf = MediaFile::fromFilehandle($attachment, $user->getProfile()); } catch(ClientException $ce) { $this->error($from, $ce->getMessage()); } @@ -104,9 +108,9 @@ class MailHandler } $from = $froms[0]; $addr = common_canonical_email($from['address']); - $user = User::staticGet('email', $addr); + $user = User::getKV('email', $addr); if (!$user) { - $user = User::staticGet('smsemail', $addr); + $user = User::getKV('smsemail', $addr); } return $user; } @@ -136,9 +140,9 @@ class MailHandler function respond($from, $to, $response) { - $headers['From'] = $to; $headers['To'] = $from; + // TRANS: E-mail subject for reply to an e-mail command. $headers['Subject'] = _('Command complete'); return mail_send(array($from), $headers, $response); @@ -225,7 +229,9 @@ class MailHandler function unsupported_type($type) { - $this->error(null, sprintf(_('Unsupported message type: %s'), $type)); + // TRANS: Error message in incoming mail handler used when an incoming e-mail is of an unsupported type. + // TRANS: %s is the unsupported type. + $this->error(null, sprintf(_('Unsupported message type: %s.'), $type)); } function cleanup_msg($msg) @@ -265,6 +271,10 @@ class MailHandler if (preg_match('/^\s*Begin\s+forward/', $line)) { break; } + // skip everything after a blank line if we already have content + if ($output !== '' && $line === '') { + break; + } $output .= ' ' . $line; }