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;
*/
public static function participantsForThread($thread, array $contacts)
{
- $r = DBA::p("SELECT `contact`.`batch`, `contact`.`id`, `contact`.`name`, `contact`.`network`,
+ $r = DBA::p("SELECT `contact`.`batch`, `contact`.`id`, `contact`.`name`, `contact`.`network`, `contact`.`protocol`,
`fcontact`.`batch` AS `fbatch`, `fcontact`.`network` AS `fnetwork` FROM `participation`
INNER JOIN `contact` ON `contact`.`id` = `participation`.`cid`
INNER JOIN `fcontact` ON `fcontact`.`id` = `participation`.`fid`
}
unset($contact['fnetwork']);
+ if (empty($contact['protocol'])) {
+ $contact['protocol'] = $contact['network'];
+ }
+
if (empty($contact['batch']) && !empty($contact['fbatch'])) {
$contact['batch'] = $contact['fbatch'];
}
$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'],
'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;
}
/**
$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'],
'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;
}
/**