mirror of
https://github.com/friendica/friendica
synced 2025-04-28 12:24:23 +02:00
Mail storing is now centralized
This commit is contained in:
parent
10b5ea825d
commit
b8a23369b6
3 changed files with 72 additions and 97 deletions
|
@ -25,6 +25,7 @@ use Friendica\Model\Conversation;
|
|||
use Friendica\Model\Event;
|
||||
use Friendica\Model\GContact;
|
||||
use Friendica\Model\Item;
|
||||
use Friendica\Model\Mail;
|
||||
use Friendica\Model\PermissionSet;
|
||||
use Friendica\Model\Profile;
|
||||
use Friendica\Model\User;
|
||||
|
@ -1865,7 +1866,6 @@ class DFRN
|
|||
{
|
||||
Logger::log("Processing mails");
|
||||
|
||||
/// @TODO Rewrite this to one statement
|
||||
$msg = [];
|
||||
$msg["uid"] = $importer["importer_uid"];
|
||||
$msg["from-name"] = $xpath->query("dfrn:sender/dfrn:name/text()", $mail)->item(0)->nodeValue;
|
||||
|
@ -1877,34 +1877,8 @@ class DFRN
|
|||
$msg["created"] = DateTimeFormat::utc($xpath->query("dfrn:sentdate/text()", $mail)->item(0)->nodeValue);
|
||||
$msg["title"] = $xpath->query("dfrn:subject/text()", $mail)->item(0)->nodeValue;
|
||||
$msg["body"] = $xpath->query("dfrn:content/text()", $mail)->item(0)->nodeValue;
|
||||
$msg["seen"] = 0;
|
||||
$msg["replied"] = 0;
|
||||
|
||||
DBA::insert('mail', $msg);
|
||||
|
||||
$msg["id"] = DBA::lastInsertId();
|
||||
|
||||
// send notifications.
|
||||
/// @TODO Arange this mess
|
||||
$notif_params = [
|
||||
"type" => NOTIFY_MAIL,
|
||||
"notify_flags" => $importer["notify-flags"],
|
||||
"language" => $importer["language"],
|
||||
"to_name" => $importer["username"],
|
||||
"to_email" => $importer["email"],
|
||||
"uid" => $importer["importer_uid"],
|
||||
"item" => $msg,
|
||||
"parent" => $msg["parent-uri"],
|
||||
"source_name" => $msg["from-name"],
|
||||
"source_link" => $importer["url"],
|
||||
"source_photo" => $importer["thumb"],
|
||||
"verb" => ACTIVITY_POST,
|
||||
"otype" => "mail"
|
||||
];
|
||||
|
||||
notification($notif_params);
|
||||
|
||||
Logger::log("Mail is processed, notification was sent.");
|
||||
Mail::insert($msg);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -27,6 +27,7 @@ use Friendica\Model\Conversation;
|
|||
use Friendica\Model\GContact;
|
||||
use Friendica\Model\Group;
|
||||
use Friendica\Model\Item;
|
||||
use Friendica\Model\Mail;
|
||||
use Friendica\Model\Profile;
|
||||
use Friendica\Model\User;
|
||||
use Friendica\Network\Probe;
|
||||
|
@ -1841,14 +1842,7 @@ class Diaspora
|
|||
|
||||
$person = self::personByHandle($msg_author);
|
||||
|
||||
DBA::lock('mail');
|
||||
|
||||
if (DBA::exists('mail', ['guid' => $msg_guid, 'uid' => $importer["uid"]])) {
|
||||
Logger::log("duplicate message already delivered.", Logger::DEBUG);
|
||||
return false;
|
||||
}
|
||||
|
||||
DBA::insert('mail', [
|
||||
return Mail::insert([
|
||||
'uid' => $importer['uid'],
|
||||
'guid' => $msg_guid,
|
||||
'convid' => $conversation['id'],
|
||||
|
@ -1858,36 +1852,10 @@ class Diaspora
|
|||
'contact-id' => $contact['id'],
|
||||
'title' => $subject,
|
||||
'body' => $body,
|
||||
'seen' => 0,
|
||||
'reply' => 0,
|
||||
'uri' => $message_uri,
|
||||
'parent-uri' => $author . ':' . $guid,
|
||||
'created' => $msg_created_at
|
||||
]);
|
||||
|
||||
$message_id = DBA::lastInsertId();
|
||||
|
||||
DBA::unlock();
|
||||
|
||||
DBA::update('conv', ['updated' => DateTimeFormat::utcNow()], ['id' => $conversation["id"]]);
|
||||
|
||||
notification([
|
||||
"type" => NOTIFY_MAIL,
|
||||
"notify_flags" => $importer["notify-flags"],
|
||||
"language" => $importer["language"],
|
||||
"to_name" => $importer["username"],
|
||||
"to_email" => $importer["email"],
|
||||
"uid" => $importer["uid"],
|
||||
"item" => ["id" => $message_id, "title" => $subject, "subject" => $subject, "body" => $body],
|
||||
"parent" => $conversation["id"],
|
||||
"source_name" => $person["name"],
|
||||
"source_link" => $person["url"],
|
||||
"source_photo" => $person["photo"],
|
||||
"verb" => ACTIVITY_POST,
|
||||
"otype" => "mail"
|
||||
]);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -2105,14 +2073,7 @@ class Diaspora
|
|||
|
||||
$body = self::replacePeopleGuid($body, $person["url"]);
|
||||
|
||||
DBA::lock('mail');
|
||||
|
||||
if (DBA::exists('mail', ['guid' => $guid, 'uid' => $importer["uid"]])) {
|
||||
Logger::log("duplicate message already delivered.", Logger::DEBUG);
|
||||
return false;
|
||||
}
|
||||
|
||||
DBA::insert('mail', [
|
||||
return Mail::insert([
|
||||
'uid' => $importer['uid'],
|
||||
'guid' => $guid,
|
||||
'convid' => $conversation['id'],
|
||||
|
@ -2122,36 +2083,11 @@ class Diaspora
|
|||
'contact-id' => $contact['id'],
|
||||
'title' => $conversation['subject'],
|
||||
'body' => $body,
|
||||
'seen' => 0,
|
||||
'reply' => 1,
|
||||
'uri' => $message_uri,
|
||||
'parent-uri' => $author.":".$conversation['guid'],
|
||||
'created' => $created_at
|
||||
]);
|
||||
|
||||
$message_id = DBA::lastInsertId();
|
||||
|
||||
DBA::unlock();
|
||||
|
||||
DBA::update('conv', ['updated' => DateTimeFormat::utcNow()], ['id' => $conversation["id"]]);
|
||||
|
||||
notification([
|
||||
"type" => NOTIFY_MAIL,
|
||||
"notify_flags" => $importer["notify-flags"],
|
||||
"language" => $importer["language"],
|
||||
"to_name" => $importer["username"],
|
||||
"to_email" => $importer["email"],
|
||||
"uid" => $importer["uid"],
|
||||
"item" => ["id" => $message_id, "title" => $conversation["subject"], "subject" => $conversation["subject"], "body" => $body],
|
||||
"parent" => $conversation["id"],
|
||||
"source_name" => $person["name"],
|
||||
"source_link" => $person["url"],
|
||||
"source_photo" => $person["photo"],
|
||||
"verb" => ACTIVITY_POST,
|
||||
"otype" => "mail"
|
||||
]);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue