function handle_message($rawmessage) { 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; } $response = $this->handle_command($user, $from, $msg); if ($response) { return true; } $msg = $this->cleanup_msg($msg); $msg = $user->shortenLinks($msg); if (Notice::contentTooLong($msg)) { // 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->getProfile()); } catch (ClientException $ce) { $this->error($from, $ce->getMessage()); } $msg .= ' ' . $mf->shortUrl(); array_push($mediafiles, $mf); fclose($attachment); } $err = $this->add_notice($user, $msg, $mediafiles); if (is_string($err)) { $this->error($from, $err); return false; } else { return true; } }