<?php
+
/**
* @file src/Model/Mail.php
*/
namespace Friendica\Model;
-use Friendica\App;
+use Friendica\Core\L10n;
use Friendica\Core\System;
use Friendica\Core\Worker;
use Friendica\Database\DBM;
+use Friendica\Network\Probe;
+use Friendica\Util\DateTimeFormat;
use dba;
require_once 'include/dba.php';
-require_once 'include/datetime.php';
/**
* Class to handle private messages
}
if (!strlen($subject)) {
- $subject = t('[no subject]');
+ $subject = L10n::t('[no subject]');
}
$me = dba::selectFirst('contact', [], ['uid' => local_user(), 'self' => true]);
if (!$convid) {
// create a new conversation
- $recip_host = substr($contact[0]['url'], strpos($contact[0]['url'], '://') + 3);
+ $recip_host = substr($contact['url'], strpos($contact['url'], '://') + 3);
$recip_host = substr($recip_host, 0, strpos($recip_host, '/'));
- $recip_handle = (($contact[0]['addr']) ? $contact[0]['addr'] : $contact[0]['nick'] . '@' . $recip_host);
+ $recip_handle = (($contact['addr']) ? $contact['addr'] : $contact['nick'] . '@' . $recip_host);
$sender_handle = $a->user['nickname'] . '@' . substr(System::baseUrl(), strpos(System::baseUrl(), '://') + 3);
$conv_guid = get_guid(32);
$handles = $recip_handle . ';' . $sender_handle;
$fields = ['uid' => local_user(), 'guid' => $conv_guid, 'creator' => $sender_handle,
- 'created' => datetime_convert(), 'updated' => datetime_convert(),
+ 'created' => DateTimeFormat::utcNow(), 'updated' => DateTimeFormat::utcNow(),
'subject' => $subject, 'recips' => $handles];
if (dba::insert('conv', $fields)) {
$convid = dba::lastInsertId();
'uid' => local_user(),
'guid' => $guid,
'convid' => $convid,
- 'from-name' => $me[0]['name'],
- 'from-photo' => $me[0]['thumb'],
- 'from-url' => $me[0]['url'],
+ 'from-name' => $me['name'],
+ 'from-photo' => $me['thumb'],
+ 'from-url' => $me['url'],
'contact-id' => $recipient,
'title' => $subject,
'body' => $body,
- 'seen' => true,
+ 'seen' => 1,
'reply' => $reply,
- 'replied' => false,
+ 'replied' => 0,
'uri' => $uri,
'parent-uri' => $replyto,
- 'created' => datetime_convert()
+ 'created' => DateTimeFormat::utcNow()
]
);
}
if (!strlen($subject)) {
- $subject = t('[no subject]');
+ $subject = L10n::t('[no subject]');
}
$guid = get_guid(32);
$convid = null;
$fields = ['uid' => $recipient['uid'], 'guid' => $conv_guid, 'creator' => $sender_handle,
- 'created' => datetime_convert(), 'updated' => datetime_convert(),
+ 'created' => DateTimeFormat::utcNow(), 'updated' => DateTimeFormat::utcNow(),
'subject' => $subject, 'recips' => $handles];
if (dba::insert('conv', $fields)) {
$convid = dba::lastInsertId();
}
-
+
if (!$convid) {
logger('send message: conversation not found.');
return -4;
'contact-id' => 0,
'title' => $subject,
'body' => $body,
- 'seen' => false,
- 'reply' => false,
- 'replied' => false,
+ 'seen' => 0,
+ 'reply' => 0,
+ 'replied' => 0,
'uri' => $uri,
'parent-uri' => $replyto,
- 'created' => datetime_convert(),
- 'unknown' => true
+ 'created' => DateTimeFormat::utcNow(),
+ 'unknown' => 1
]
);