use Friendica\Core\Config;
use Friendica\Core\Lock;
use Friendica\Core\PConfig;
+use Friendica\Core\Protocol;
use Friendica\Core\System;
use Friendica\Core\Worker;
use Friendica\Database\DBA;
// We can always comment on posts from these networks
if (array_key_exists('writable', $row) &&
- in_array($row['internal-network'], [NETWORK_DFRN, NETWORK_DIASPORA, NETWORK_OSTATUS])) {
+ in_array($row['internal-network'], [Protocol::DFRN, Protocol::DIASPORA, Protocol::OSTATUS])) {
$row['writable'] = true;
}
if ($notify) {
$item['wall'] = 1;
$item['origin'] = 1;
- $item['network'] = NETWORK_DFRN;
+ $item['network'] = Protocol::DFRN;
$item['protocol'] = Conversation::PARCEL_DFRN;
if (is_int($notify)) {
$priority = PRIORITY_HIGH;
}
} else {
- $item['network'] = trim(defaults($item, 'network', NETWORK_PHANTOM));
+ $item['network'] = trim(defaults($item, 'network', Protocol::PHANTOM));
}
$item['guid'] = self::guid($item, $notify);
// Converting the plink
/// @TODO Check if this is really still needed
- if ($item['network'] == NETWORK_OSTATUS) {
+ if ($item['network'] == Protocol::OSTATUS) {
if (isset($item['plink'])) {
$item['plink'] = OStatus::convertHref($item['plink']);
} elseif (isset($item['uri'])) {
* We have to check several networks since Friendica posts could be repeated
* via OStatus (maybe Diasporsa as well)
*/
- if (in_array($item['network'], [NETWORK_DIASPORA, NETWORK_DFRN, NETWORK_OSTATUS, ""])) {
+ if (in_array($item['network'], [Protocol::DIASPORA, Protocol::DFRN, Protocol::OSTATUS, ""])) {
$condition = ["`uri` = ? AND `uid` = ? AND `network` IN (?, ?, ?)",
trim($item['uri']), $item['uid'],
- NETWORK_DIASPORA, NETWORK_DFRN, NETWORK_OSTATUS];
+ Protocol::DIASPORA, Protocol::DFRN, Protocol::OSTATUS];
$existing = self::selectFirst(['id', 'network'], $condition);
if (DBA::isResult($existing)) {
// We only log the entries with a different user id than 0. Otherwise we would have too many false positives
unset($item['owner-name']);
unset($item['owner-avatar']);
- if ($item['network'] == NETWORK_PHANTOM) {
+ if ($item['network'] == Protocol::PHANTOM) {
logger('Missing network. Called by: '.System::callstack(), LOGGER_DEBUG);
- $item['network'] = NETWORK_DFRN;
+ $item['network'] = Protocol::DFRN;
logger("Set network to " . $item["network"] . " for " . $item["uri"], LOGGER_DEBUG);
}
$item['thr-parent-id'] = ItemURI::getIdByURI($item['thr-parent']);
$condition = ["`uri` = ? AND `network` IN (?, ?) AND `uid` = ?",
- $item['uri'], $item['network'], NETWORK_DFRN, $item['uid']];
+ $item['uri'], $item['network'], Protocol::DFRN, $item['uid']];
if (self::exists($condition)) {
logger('duplicated item with the same uri found. '.print_r($item,true));
return 0;
}
// On Friendica and Diaspora the GUID is unique
- if (in_array($item['network'], [NETWORK_DFRN, NETWORK_DIASPORA])) {
+ if (in_array($item['network'], [Protocol::DFRN, Protocol::DIASPORA])) {
$condition = ['guid' => $item['guid'], 'uid' => $item['uid']];
if (self::exists($condition)) {
logger('duplicated item with the same guid found. '.print_r($item,true));
// Only distribute public items from native networks
$condition = ['id' => $itemid, 'uid' => 0,
- 'network' => [NETWORK_DFRN, NETWORK_DIASPORA, NETWORK_OSTATUS, ""],
+ 'network' => [Protocol::DFRN, Protocol::DIASPORA, Protocol::OSTATUS, ""],
'visible' => true, 'deleted' => false, 'moderated' => false, 'private' => false];
$item = self::selectFirst(self::ITEM_FIELDLIST, ['id' => $itemid]);
if (!DBA::isResult($item)) {
}
// is it an entry from a connector? Only add an entry for natively connected networks
- if (!in_array($item["network"], [NETWORK_DFRN, NETWORK_DIASPORA, NETWORK_OSTATUS, ""])) {
+ if (!in_array($item["network"], [Protocol::DFRN, Protocol::DIASPORA, Protocol::OSTATUS, ""])) {
return;
}
// If this was a comment to a Diaspora post we don't get our comment back.
// This means that we have to distribute the comment by ourselves.
- if ($origin && self::exists(['id' => $parent, 'network' => NETWORK_DIASPORA])) {
+ if ($origin && self::exists(['id' => $parent, 'network' => Protocol::DIASPORA])) {
self::distribute($public_shadow);
}
}
$update = (!$arr['private'] && ((defaults($arr, 'author-link', '') === defaults($arr, 'owner-link', '')) || ($arr["parent-uri"] === $arr["uri"])));
// Is it a forum? Then we don't care about the rules from above
- if (!$update && ($arr["network"] == NETWORK_DFRN) && ($arr["parent-uri"] === $arr["uri"])) {
+ if (!$update && ($arr["network"] == Protocol::DFRN) && ($arr["parent-uri"] === $arr["uri"])) {
if (DBA::exists('contact', ['id' => $arr['contact-id'], 'forum' => true])) {
$update = true;
}
}
// Prevent the forwarding of posts that are forwarded
- if (!empty($datarray["extid"]) && ($datarray["extid"] == NETWORK_DFRN)) {
+ if (!empty($datarray["extid"]) && ($datarray["extid"] == Protocol::DFRN)) {
logger('Already forwarded', LOGGER_DEBUG);
return false;
}
return false;
}
- if (($contact['network'] != NETWORK_FEED) && $datarray['private']) {
+ if (($contact['network'] != Protocol::FEED) && $datarray['private']) {
logger('Not public', LOGGER_DEBUG);
return false;
}
unset($datarray['author-id']);
}
- if ($contact['network'] != NETWORK_FEED) {
+ if ($contact['network'] != Protocol::FEED) {
$datarray["guid"] = System::createGUID(32);
unset($datarray["plink"]);
$datarray["uri"] = self::newURI($contact['uid'], $datarray["guid"]);
$datarray["parent-uri"] = $datarray["uri"];
$datarray["thr-parent"] = $datarray["uri"];
- $datarray["extid"] = NETWORK_DFRN;
+ $datarray["extid"] = Protocol::DFRN;
$urlpart = parse_url($datarray2['author-link']);
$datarray["app"] = $urlpart["host"];
} else {
}
}
- if ($contact['network'] != NETWORK_FEED) {
+ if ($contact['network'] != Protocol::FEED) {
// Store the original post
$result = self::insert($datarray2, false, false);
logger('remote-self post original item - Contact '.$contact['url'].' return '.$result.' Item '.print_r($datarray2, true), LOGGER_DEBUG);
'contact-id' => $item_contact_id,
'wall' => $item['wall'],
'origin' => 1,
- 'network' => NETWORK_DFRN,
+ 'network' => Protocol::DFRN,
'gravity' => GRAVITY_ACTIVITY,
'parent' => $item['id'],
'parent-uri' => $item['uri'],