use Friendica\Core\Config;
use Friendica\Core\L10n;
use Friendica\Core\PConfig;
+use Friendica\Core\Protocol;
use Friendica\Database\DBA;
use Friendica\Model\ItemContent;
use Friendica\Util\Proxy as ProxyUtils;
switch ($profile->service) {
case 'facebook':
- $send = ($b["extid"] != NETWORK_FACEBOOK);
+ $send = ($b["extid"] != Protocol::FACEBOOK);
$limit = 0;
$markup = false;
$includedlinks = false;
break;
case 'google':
- $send = ($b["extid"] != NETWORK_GPLUS);
+ $send = ($b["extid"] != Protocol::GPLUS);
$limit = 0;
$markup = true;
$includedlinks = false;
break;
case 'twitter':
- $send = ($b["extid"] != NETWORK_TWITTER);
+ $send = ($b["extid"] != Protocol::TWITTER);
$limit = 280;
$markup = false;
$includedlinks = true;
break;
case 'linkedin':
- $send = ($b["extid"] != NETWORK_LINKEDIN);
+ $send = ($b["extid"] != Protocol::LINKEDIN);
$limit = 700;
$markup = false;
$includedlinks = true;
use Friendica\Core\Addon;
use Friendica\Core\L10n;
use Friendica\Core\PConfig;
+use Friendica\Core\Protocol;
use Friendica\Database\DBA;
use Friendica\Model\Queue;
$hostname = $a->get_hostname();
$qi = q("SELECT * FROM `queue` WHERE `network` = '%s'",
- DBA::escape(NETWORK_DIASPORA2)
+ DBA::escape(Protocol::DIASPORA2)
);
if (!DBA::isResult($qi)) {
}
foreach ($qi as $x) {
- if ($x['network'] !== NETWORK_DIASPORA2) {
+ if ($x['network'] !== Protocol::DIASPORA2) {
continue;
}
$s = serialize(['url' => $url, 'item' => $b['id'], 'post' => $body]);
- Queue::add($a->contact, NETWORK_DIASPORA2, $s);
+ Queue::add($a->contact, Protocol::DIASPORA2, $s);
notice(L10n::t('Diaspora post failed. Queued for retry.').EOL);
}
}
use Friendica\Core\Config;
use Friendica\Core\L10n;
use Friendica\Core\PConfig;
+use Friendica\Core\Protocol;
use Friendica\Object\Image;
use Friendica\Util\DateTimeFormat;
use Friendica\Util\Network;
$_REQUEST['profile_uid'] = $uid;
$_REQUEST['source'] = $source;
- $_REQUEST['extid'] = NETWORK_GPLUS;
+ $_REQUEST['extid'] = Protocol::GPLUS;
if (isset($id)) {
- $_REQUEST['message_id'] = Item::newURI($uid, NETWORK_GPLUS.':'.$id);
+ $_REQUEST['message_id'] = Item::newURI($uid, Protocol::GPLUS.':'.$id);
}
// $_REQUEST['verb']
use Friendica\Core\Addon;
use Friendica\Core\L10n;
use Friendica\Core\PConfig;
+use Friendica\Core\Protocol;
use Friendica\Database\DBA;
use Friendica\Model\Item;
if (strstr($item['url'], 'facebook.com')) {
$hash = hash('ripemd128', item['url']);
- $_REQUEST['extid'] = NETWORK_FACEBOOK;
- $_REQUEST['message_id'] = Item::newURI($uid, NETWORK_FACEBOOK . ':' . $hash);
+ $_REQUEST['extid'] = Protocol::FACEBOOK;
+ $_REQUEST['message_id'] = Item::newURI($uid, Protocol::FACEBOOK . ':' . $hash);
}
if ($item['type'] == 'link') {
use Friendica\Core\Config;
use Friendica\Core\L10n;
use Friendica\Core\PConfig;
+use Friendica\Core\Protocol;
use Friendica\Database\DBA;
use Friendica\Model\User;
use Friendica\Util\Network;
// for each user, go through list of contacts
$contacts = q("SELECT * FROM `contact` WHERE `uid`=%d AND ((LENGTH(`dfrn-id`) AND LENGTH(`pubkey`)) OR (LENGTH(`issued-id`) AND LENGTH(`prvkey`))) AND `network` = '%s'",
- intval($uid), DBA::escape(NETWORK_DFRN));
+ intval($uid), DBA::escape(Protocol::DFRN));
foreach ($contacts as $contact_row) {
$request = $contact_row["request"];
if (!$request) {
use Friendica\Core\Config;
use Friendica\Core\L10n;
use Friendica\Core\PConfig;
+use Friendica\Core\Protocol;
use Friendica\Core\Worker;
use Friendica\Database\DBA;
use Friendica\Model\Contact;
if ($b['parent'] != $b['id']) {
// Looking if its a reply to a pumpio post
- $condition = ['id' => $b['parent'], 'network' => NETWORK_PUMPIO];
+ $condition = ['id' => $b['parent'], 'network' => Protocol::PUMPIO];
$orig_post = Item::selectFirst([], $condition);
if (!DBA::isResult($orig_post)) {
$s = serialize(['url' => $url, 'item' => $b['id'], 'post' => $params]);
- Queue::add($a->contact, NETWORK_PUMPIO, $s);
+ Queue::add($a->contact, Protocol::PUMPIO, $s);
notice(L10n::t('Pump.io post failed. Queued for retry.').EOL);
}
}
$s = serialize(['url' => $url, 'item' => $orig_post["id"], 'post' => $params]);
- Queue::add($a->contact, NETWORK_PUMPIO, $s);
+ Queue::add($a->contact, Protocol::PUMPIO, $s);
notice(L10n::t('Pump.io like failed. Queued for retry.').EOL);
}
}
$_REQUEST["source"] = "pump.io";
if (isset($post->object->id)) {
- $_REQUEST['message_id'] = NETWORK_PUMPIO.":".$post->object->id;
+ $_REQUEST['message_id'] = Protocol::PUMPIO.":".$post->object->id;
}
if ($post->object->displayName != "") {
$likedata['gravity'] = GRAVITY_ACTIVITY;
$likedata['uid'] = $uid;
$likedata['wall'] = 0;
- $likedata['network'] = NETWORK_PUMPIO;
+ $likedata['network'] = Protocol::PUMPIO;
$likedata['uri'] = Item::newURI($uid);
$likedata['parent-uri'] = $orig_post["uri"];
$likedata['contact-id'] = $contactid;
function pumpio_get_contact($uid, $contact, $no_insert = false)
{
- $gcontact = ["url" => $contact->url, "network" => NETWORK_PUMPIO, "generation" => 2,
+ $gcontact = ["url" => $contact->url, "network" => Protocol::PUMPIO, "generation" => 2,
"name" => $contact->displayName, "hide" => true,
"nick" => $contact->preferredUsername,
"addr" => str_replace("acct:", "", $contact->id)];
DBA::escape($contact->displayName),
DBA::escape($contact->preferredUsername),
DBA::escape($contact->image->url),
- DBA::escape(NETWORK_PUMPIO),
+ DBA::escape(Protocol::PUMPIO),
intval(Contact::FRIEND),
intval(1),
DBA::escape($contact->location->displayName),
}
$postarray = [];
- $postarray['network'] = NETWORK_PUMPIO;
+ $postarray['network'] = Protocol::PUMPIO;
$postarray['uid'] = $uid;
$postarray['wall'] = 0;
$postarray['uri'] = $post->object->id;
INNER JOIN `item` ON `item`.`id` = `thread`.`iid`
WHERE `thread`.`network` = '%s' AND `thread`.`uid` = %d AND `item`.`extid` != ''
ORDER BY `thread`.`commented` DESC LIMIT 10",
- DBA::escape(NETWORK_PUMPIO),
+ DBA::escape(Protocol::PUMPIO),
intval($uid)
);
function pumpio_queue_hook(App $a, array &$b)
{
$qi = q("SELECT * FROM `queue` WHERE `network` = '%s'",
- DBA::escape(NETWORK_PUMPIO)
+ DBA::escape(Protocol::PUMPIO)
);
if (!DBA::isResult($qi)) {
}
foreach ($qi as $x) {
- if ($x['network'] !== NETWORK_PUMPIO) {
+ if ($x['network'] !== Protocol::PUMPIO) {
continue;
}
$r = q("SELECT `name`, `nick`, `url` FROM `contact` WHERE `id` = %d AND `uid` = %d AND `network` = '%s' AND `blocked` = 0 AND `readonly` = 0 LIMIT 1",
intval($cid),
intval($b["uid"]),
- DBA::escape(NETWORK_PUMPIO)
+ DBA::escape(Protocol::PUMPIO)
);
if (DBA::isResult($r)) {
"FROM `group_member`, `contact` WHERE `group_member`.`gid` = %d ".
"AND `contact`.`id` = `group_member`.`contact-id` AND `contact`.`network` = '%s'",
intval($gid),
- DBA::escape(NETWORK_PUMPIO)
+ DBA::escape(Protocol::PUMPIO)
);
foreach ($r AS $row)
$r = q("SELECT `name`, `nick`, `url` FROM `contact` WHERE `id` = %d AND `uid` = %d AND `network` = '%s' AND `blocked` = 0 AND `readonly` = 0 LIMIT 1",
intval($cid),
intval($b["uid"]),
- DBA::escape(NETWORK_PUMPIO)
+ DBA::escape(Protocol::PUMPIO)
);
if (DBA::isResult($r)) {
use Friendica\Core\Config;
use Friendica\Core\L10n;
use Friendica\Core\PConfig;
+use Friendica\Core\Protocol;
use Friendica\Database\DBA;
use Friendica\Model\Contact;
use Friendica\Model\GContact;
}
// if posts comes from GNU Social don't send it back
- if ($b['extid'] == NETWORK_STATUSNET) {
+ if ($b['extid'] == Protocol::STATUSNET) {
return;
}
function statusnet_prepare_body(App $a, &$b)
{
- if ($b["item"]["network"] != NETWORK_STATUSNET) {
+ if ($b["item"]["network"] != Protocol::STATUSNET) {
return;
}
$_REQUEST["profile_uid"] = $uid;
//$_REQUEST["source"] = "StatusNet";
$_REQUEST["source"] = $post->source;
- $_REQUEST["extid"] = NETWORK_STATUSNET;
+ $_REQUEST["extid"] = Protocol::STATUSNET;
if (isset($post->id)) {
- $_REQUEST['message_id'] = Item::newURI($uid, NETWORK_STATUSNET . ":" . $post->id);
+ $_REQUEST['message_id'] = Item::newURI($uid, Protocol::STATUSNET . ":" . $post->id);
}
//$_REQUEST["date"] = $post->created_at;
}
GContact::update(["url" => $contact->statusnet_profile_url,
- "network" => NETWORK_STATUSNET, "photo" => $contact->profile_image_url,
+ "network" => Protocol::STATUSNET, "photo" => $contact->profile_image_url,
"name" => $contact->name, "nick" => $contact->screen_name,
"location" => $contact->location, "about" => $contact->description,
"addr" => statusnet_address($contact), "generation" => 3]);
- $r = q("SELECT * FROM `contact` WHERE `uid` = %d AND `alias` = '%s' AND `network` = '%s'LIMIT 1", intval($uid), DBA::escape(normalise_link($contact->statusnet_profile_url)), DBA::escape(NETWORK_STATUSNET));
+ $r = q("SELECT * FROM `contact` WHERE `uid` = %d AND `alias` = '%s' AND `network` = '%s'LIMIT 1", intval($uid), DBA::escape(normalise_link($contact->statusnet_profile_url)), DBA::escape(Protocol::STATUSNET));
if (!DBA::isResult($r) && !$create_user) {
return 0;
DBA::escape($contact->name),
DBA::escape($contact->screen_name),
DBA::escape($contact->profile_image_url),
- DBA::escape(NETWORK_STATUSNET),
+ DBA::escape(Protocol::STATUSNET),
intval(Contact::FRIEND),
intval(1),
DBA::escape($contact->location),
$r = q("SELECT * FROM `contact` WHERE `alias` = '%s' AND `uid` = %d AND `network` = '%s' LIMIT 1",
DBA::escape($contact->statusnet_profile_url),
intval($uid),
- DBA::escape(NETWORK_STATUSNET));
+ DBA::escape(Protocol::STATUSNET));
if (!DBA::isResult($r)) {
return false;
$hostname = preg_replace("=https?://([\w\.]*)/.*=ism", "$1", $api);
$postarray = [];
- $postarray['network'] = NETWORK_STATUSNET;
+ $postarray['network'] = Protocol::STATUSNET;
$postarray['uid'] = $uid;
$postarray['wall'] = 0;
use Friendica\Core\Config;
use Friendica\Core\L10n;
use Friendica\Core\PConfig;
+use Friendica\Core\Protocol;
use Friendica\Core\Worker;
use Friendica\Database\DBA;
use Friendica\Model\Contact;
}
// if post comes from twitter don't send it back
- if ($b['extid'] == NETWORK_TWITTER) {
+ if ($b['extid'] == Protocol::TWITTER) {
return;
}
$s = serialize(['url' => $url, 'item' => $b['id'], 'post' => $post]);
- Queue::add($a->contact, NETWORK_TWITTER, $s);
+ Queue::add($a->contact, Protocol::TWITTER, $s);
notice(L10n::t('Twitter post failed. Queued for retry.') . EOL);
} elseif ($iscomment) {
logger('twitter_post: Update extid ' . $result->id_str . " for post id " . $b['id']);
return;
}
- $r = DBA::select('item', ['id', 'iaid', 'icid'], ['deleted' => true, 'network' => NETWORK_TWITTER]);
+ $r = DBA::select('item', ['id', 'iaid', 'icid'], ['deleted' => true, 'network' => Protocol::TWITTER]);
while ($row = DBA::fetch($r)) {
DBA::delete('item', ['id' => $row['id']]);
if (!empty($row['iaid']) && !DBA::exists('item', ['iaid' => $row['iaid']])) {
if (DBA::isResult($r)) {
foreach ($r as $rr) {
logger('twitter_expire: user ' . $rr['uid']);
- Item::expire($rr['uid'], $days, NETWORK_TWITTER, true);
+ Item::expire($rr['uid'], $days, Protocol::TWITTER, true);
}
}
function twitter_prepare_body(App $a, array &$b)
{
- if ($b["item"]["network"] != NETWORK_TWITTER) {
+ if ($b["item"]["network"] != Protocol::TWITTER) {
return;
}
{
$datarray['api_source'] = true;
$datarray['profile_uid'] = $uid;
- $datarray['extid'] = NETWORK_TWITTER;
- $datarray['message_id'] = Item::newURI($uid, NETWORK_TWITTER . ':' . $post->id);
+ $datarray['extid'] = Protocol::TWITTER;
+ $datarray['message_id'] = Item::newURI($uid, Protocol::TWITTER . ':' . $post->id);
$datarray['protocol'] = Conversation::PARCEL_TWITTER;
$datarray['source'] = json_encode($post);
$datarray['title'] = '';
function twitter_queue_hook(App $a)
{
$qi = q("SELECT * FROM `queue` WHERE `network` = '%s'",
- DBA::escape(NETWORK_TWITTER)
+ DBA::escape(Protocol::TWITTER)
);
if (!DBA::isResult($qi)) {
return;
}
foreach ($qi as $x) {
- if ($x['network'] !== NETWORK_TWITTER) {
+ if ($x['network'] !== Protocol::TWITTER) {
continue;
}
$url = "https://twitter.com/" . $data->screen_name;
$addr = $data->screen_name . "@twitter.com";
- GContact::update(["url" => $url, "network" => NETWORK_TWITTER,
+ GContact::update(["url" => $url, "network" => Protocol::TWITTER,
"photo" => $avatar, "hide" => true,
"name" => $data->name, "nick" => $data->screen_name,
"location" => $data->location, "about" => $data->description,
"addr" => $addr, "generation" => 2]);
- $fields = ['url' => $url, 'network' => NETWORK_TWITTER,
+ $fields = ['url' => $url, 'network' => Protocol::TWITTER,
'name' => $data->name, 'nick' => $data->screen_name, 'addr' => $addr,
'location' => $data->location, 'about' => $data->description];
function twitter_createpost(App $a, $uid, $post, array $self, $create_user, $only_existing_contact, $noquote)
{
$postarray = [];
- $postarray['network'] = NETWORK_TWITTER;
+ $postarray['network'] = Protocol::TWITTER;
$postarray['uid'] = $uid;
$postarray['wall'] = 0;
$postarray['uri'] = "twitter::" . $post->id_str;