use Friendica\BaseObject;
use Friendica\Core\Config;
use Friendica\Core\L10n;
+use Friendica\Core\Protocol;
use Friendica\Core\System;
use Friendica\Database\DBA;
use Friendica\Model\Contact;
}
$parent_id = intval($item['parent']);
- $condition = ['id' => [$item_id, $parent_id], 'visible' => true, 'moderated' => false];
+ $condition = ['id' => [$item_id, $parent_id], 'moderated' => false];
$params = ['order' => ['id']];
$itemdata = Item::select([], $condition, $params);
}
DBA::close($itemdata);
+ if (empty($target_item)) {
+ logger('Item ' . $item_id . "wasn't found. Quitting here.");
+ return;
+ }
+
+ if (empty($parent)) {
+ logger('Parent ' . $parent_id . ' for item ' . $item_id . "wasn't found. Quitting here.");
+ return;
+ }
+
$uid = $target_item['contact-uid'];
// avoid race condition with deleting entries
// Transmit via Diaspora if the thread had started as Diaspora post
// This is done since the uri wouldn't match (Diaspora doesn't transmit it)
- if (isset($parent) && ($parent['network'] == NETWORK_DIASPORA) && ($contact['network'] == NETWORK_DFRN)) {
- $contact['network'] = NETWORK_DIASPORA;
+ if (isset($parent) && ($parent['network'] == Protocol::DIASPORA) && ($contact['network'] == Protocol::DFRN)) {
+ $contact['network'] = Protocol::DIASPORA;
}
logger("Delivering " . $cmd . " followup=$followup - via network " . $contact['network']);
switch ($contact['network']) {
- case NETWORK_DFRN:
+ case Protocol::DFRN:
self::deliverDFRN($cmd, $contact, $owner, $items, $target_item, $public_message, $top_level, $followup);
break;
- case NETWORK_DIASPORA:
+ case Protocol::DIASPORA:
self::deliverDiaspora($cmd, $contact, $owner, $items, $target_item, $public_message, $top_level, $followup);
break;
- case NETWORK_OSTATUS:
+ case Protocol::OSTATUS:
// Do not send to otatus if we are not configured to send to public networks
if ($owner['prvnets']) {
break;
// This is done in "notifier.php" (See "url_recipients" and "push_notify")
break;
- case NETWORK_MAIL:
+ case Protocol::MAIL:
self::deliverMail($cmd, $contact, $owner, $target_item);
break;
}
}
- // We now have some contact, so we fetch it
- $target_importer = DBA::fetchFirst("SELECT *, `name` as `senderName`
- FROM `contact`
- WHERE NOT `blocked` AND `id` = ? LIMIT 1",
- $cid);
-
- // This should never fail
- if (!DBA::isResult($target_importer)) {
+ $target_importer = DFRN::getImporter($cid, $target_uid);
+ if (empty($target_importer)) {
+ // This should never happen
return;
}
- $user = DBA::selectFirst('user', [], ['uid' => $target_uid]);
-
- $target_importer = array_merge($target_importer, $user);
-
- // Set the user id. This is important if this is a public contact
- $target_importer['importer_uid'] = $target_uid;
DFRN::import($atom, $target_importer);
return;
}
if ($deliver_status < 0) {
logger('Delivery failed: queuing message ' . $target_item["guid"] );
- Queue::add($contact['id'], NETWORK_DFRN, $atom, false, $target_item['guid']);
+ Queue::add($contact['id'], Protocol::DFRN, $atom, false, $target_item['guid']);
}
if (($deliver_status >= 200) && ($deliver_status <= 299)) {
if (($target_item["thr-parent"] != "") && ($target_item["thr-parent"] != $target_item["parent-uri"])) {
$headers .= " <".Email::iri2msgid($target_item["thr-parent"]).">";
}
+
$headers .= "\n";
if (empty($target_item['title'])) {
$condition = ['uri' => $target_item['parent-uri'], 'uid' => $owner['uid']];
$title = Item::selectFirst(['title'], $condition);
+
if (DBA::isResult($title) && ($title['title'] != '')) {
$subject = $title['title'];
} else {
$condition = ['parent-uri' => $target_item['parent-uri'], 'uid' => $owner['uid']];
$title = Item::selectFirst(['title'], $condition);
+
if (DBA::isResult($title) && ($title['title'] != '')) {
$subject = $title['title'];
}
}
}
+
if (strncasecmp($subject, 'RE:', 3)) {
$subject = 'Re: ' . $subject;
}
}
+
Email::send($addr, $subject, $headers, $target_item);
}
}