mirror of
https://github.com/friendica/friendica
synced 2025-05-08 11:04:10 +02:00
Email to src
Create Email class and update/rename functions and function calls.
This commit is contained in:
parent
de4a2e6fd0
commit
6008e3df11
10 changed files with 370 additions and 355 deletions
|
@ -12,13 +12,13 @@ use Friendica\Database\DBM;
|
|||
use Friendica\Object\Contact;
|
||||
use Friendica\Protocol\Diaspora;
|
||||
use Friendica\Protocol\DFRN;
|
||||
use Friendica\Protocol\Email;
|
||||
|
||||
require_once 'include/queue_fn.php';
|
||||
require_once 'include/html2plain.php';
|
||||
require_once 'include/datetime.php';
|
||||
require_once 'include/items.php';
|
||||
require_once 'include/bbcode.php';
|
||||
require_once 'include/email.php';
|
||||
|
||||
/// @todo This is some ugly code that needs to be split into several methods
|
||||
|
||||
|
@ -418,36 +418,36 @@ class Delivery {
|
|||
if ($r1 && $r1[0]['reply_to'])
|
||||
$reply_to = $r1[0]['reply_to'];
|
||||
|
||||
$subject = (($it['title']) ? email_header_encode($it['title'],'UTF-8') : t("\x28no subject\x29")) ;
|
||||
$subject = (($it['title']) ? Email::emailHeaderEncode($it['title'],'UTF-8') : t("\x28no subject\x29")) ;
|
||||
|
||||
// only expose our real email address to true friends
|
||||
|
||||
if (($contact['rel'] == CONTACT_IS_FRIEND) && !$contact['blocked']) {
|
||||
if ($reply_to) {
|
||||
$headers = 'From: '.email_header_encode($local_user[0]['username'],'UTF-8').' <'.$reply_to.'>'."\n";
|
||||
$headers = 'From: '.Email::emailHeaderEncode($local_user[0]['username'],'UTF-8').' <'.$reply_to.'>'."\n";
|
||||
$headers .= 'Sender: '.$local_user[0]['email']."\n";
|
||||
} else {
|
||||
$headers = 'From: '.email_header_encode($local_user[0]['username'],'UTF-8').' <'.$local_user[0]['email'].'>'."\n";
|
||||
$headers = 'From: '.Email::emailHeaderEncode($local_user[0]['username'],'UTF-8').' <'.$local_user[0]['email'].'>'."\n";
|
||||
}
|
||||
} else {
|
||||
$headers = 'From: '. email_header_encode($local_user[0]['username'],'UTF-8') .' <'. t('noreply') .'@'.$a->get_hostname() .'>'. "\n";
|
||||
$headers = 'From: '. Email::emailHeaderEncode($local_user[0]['username'],'UTF-8') .' <'. t('noreply') .'@'.$a->get_hostname() .'>'. "\n";
|
||||
}
|
||||
|
||||
//if ($reply_to)
|
||||
// $headers .= 'Reply-to: '.$reply_to . "\n";
|
||||
|
||||
$headers .= 'Message-Id: <'. iri2msgid($it['uri']).'>'. "\n";
|
||||
$headers .= 'Message-Id: <'. Email::iri2msgid($it['uri']).'>'. "\n";
|
||||
|
||||
//logger("Mail: uri: ".$it['uri']." parent-uri ".$it['parent-uri'], LOGGER_DEBUG);
|
||||
//logger("Mail: Data: ".print_r($it, true), LOGGER_DEBUG);
|
||||
//logger("Mail: Data: ".print_r($it, true), LOGGER_DATA);
|
||||
|
||||
if ($it['uri'] !== $it['parent-uri']) {
|
||||
$headers .= "References: <".iri2msgid($it["parent-uri"]).">";
|
||||
$headers .= "References: <".Email::iri2msgid($it["parent-uri"]).">";
|
||||
|
||||
// If Threading is enabled, write down the correct parent
|
||||
if (($it["thr-parent"] != "") && ($it["thr-parent"] != $it["parent-uri"]))
|
||||
$headers .= " <".iri2msgid($it["thr-parent"]).">";
|
||||
$headers .= " <".Email::iri2msgid($it["thr-parent"]).">";
|
||||
$headers .= "\n";
|
||||
|
||||
if (!$it['title']) {
|
||||
|
@ -469,7 +469,7 @@ class Delivery {
|
|||
if (strncasecmp($subject,'RE:',3))
|
||||
$subject = 'Re: '.$subject;
|
||||
}
|
||||
email_send($addr, $subject, $headers, $it);
|
||||
Email::emailSend($addr, $subject, $headers, $it);
|
||||
}
|
||||
break;
|
||||
|
||||
|
|
|
@ -8,6 +8,7 @@ use Friendica\Core\Config;
|
|||
use Friendica\Core\PConfig;
|
||||
use Friendica\Database\DBM;
|
||||
use Friendica\Object\Contact;
|
||||
use Friendica\Protocol\Email;
|
||||
use Friendica\Protocol\PortableContact;
|
||||
use dba;
|
||||
|
||||
|
@ -20,7 +21,6 @@ Class OnePoll
|
|||
|
||||
require_once 'include/datetime.php';
|
||||
require_once 'include/items.php';
|
||||
require_once 'include/email.php';
|
||||
require_once 'include/queue_fn.php';
|
||||
|
||||
logger('onepoll: start');
|
||||
|
@ -328,10 +328,10 @@ Class OnePoll
|
|||
$condition = array("`server` != '' AND `uid` = ?", $importer_uid);
|
||||
$mailconf = dba::select('mailacct', array(), $condition, array('limit' => 1));
|
||||
if (DBM::is_result($x) && DBM::is_result($mailconf)) {
|
||||
$mailbox = construct_mailbox_name($mailconf);
|
||||
$mailbox = Email::constructMailboxName($mailconf);
|
||||
$password = '';
|
||||
openssl_private_decrypt(hex2bin($mailconf['pass']), $password, $x['prvkey']);
|
||||
$mbox = email_connect($mailbox, $mailconf['user'], $password);
|
||||
$mbox = Email::emailConnect($mailbox, $mailconf['user'], $password);
|
||||
unset($password);
|
||||
logger("Mail: Connect to " . $mailconf['user']);
|
||||
if ($mbox) {
|
||||
|
@ -344,12 +344,12 @@ Class OnePoll
|
|||
}
|
||||
|
||||
if ($mbox) {
|
||||
$msgs = email_poll($mbox, $contact['addr']);
|
||||
$msgs = Email::emailPoll($mbox, $contact['addr']);
|
||||
|
||||
if (count($msgs)) {
|
||||
logger("Mail: Parsing ".count($msgs)." mails from ".$contact['addr']." for ".$mailconf['user'], LOGGER_DEBUG);
|
||||
|
||||
$metas = email_msg_meta($mbox,implode(',', $msgs));
|
||||
$metas = Email::emailMsgMeta($mbox,implode(',', $msgs));
|
||||
if (count($metas) != count($msgs)) {
|
||||
logger("onepoll: for " . $mailconf['user'] . " there are ". count($msgs) . " messages but received " . count($metas) . " metas", LOGGER_DEBUG);
|
||||
} else {
|
||||
|
@ -361,10 +361,10 @@ Class OnePoll
|
|||
$datarray = array();
|
||||
$datarray['verb'] = ACTIVITY_POST;
|
||||
$datarray['object-type'] = ACTIVITY_OBJ_NOTE;
|
||||
// $meta = email_msg_meta($mbox, $msg_uid);
|
||||
// $headers = email_msg_headers($mbox, $msg_uid);
|
||||
// $meta = Email::emailMsgMeta($mbox, $msg_uid);
|
||||
// $headers = email_msg_headers($mbox, $msg_uid);
|
||||
|
||||
$datarray['uri'] = msgid2iri(trim($meta->message_id, '<>'));
|
||||
$datarray['uri'] = Email::msgid2iri(trim($meta->message_id, '<>'));
|
||||
|
||||
// Have we seen it before?
|
||||
$fields = array('deleted', 'id');
|
||||
|
@ -416,7 +416,7 @@ Class OnePoll
|
|||
$refs_arr = explode(' ', $raw_refs);
|
||||
if (count($refs_arr)) {
|
||||
for ($x = 0; $x < count($refs_arr); $x ++) {
|
||||
$refs_arr[$x] = "'" . msgid2iri(str_replace(array('<', '>', ' '),array('', '', ''),dbesc($refs_arr[$x]))) . "'";
|
||||
$refs_arr[$x] = "'" . Email::msgid2iri(str_replace(array('<', '>', ' '),array('', '', ''),dbesc($refs_arr[$x]))) . "'";
|
||||
}
|
||||
}
|
||||
$qstr = implode(',', $refs_arr);
|
||||
|
@ -466,7 +466,7 @@ Class OnePoll
|
|||
$datarray['parent-uri'] = $datarray['uri'];
|
||||
}
|
||||
|
||||
$r = email_get_msg($mbox, $msg_uid, $reply);
|
||||
$r = Email::emailGetMsg($mbox, $msg_uid, $reply);
|
||||
if (!$r) {
|
||||
logger("Mail: can't fetch msg ".$msg_uid." for ".$mailconf['user']);
|
||||
continue;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue