define('STATUSNET_DEFAULT_POLL_INTERVAL', 5); // given in minutes
require_once('library/twitteroauth.php');
+require_once('include/enotify.php');
+require_once("include/socgraph.php");
class StatusNetOAuth extends TwitterOAuth {
function get_maxlength() {
register_hook('jot_networks', 'addon/statusnet/statusnet.php', 'statusnet_jot_nets');
register_hook('cron', 'addon/statusnet/statusnet.php', 'statusnet_cron');
register_hook('prepare_body', 'addon/statusnet/statusnet.php', 'statusnet_prepare_body');
+ register_hook('check_item_notification','addon/statusnet/statusnet.php', 'statusnet_check_item_notification');
logger("installed GNU Social");
}
unregister_hook('jot_networks', 'addon/statusnet/statusnet.php', 'statusnet_jot_nets');
unregister_hook('cron', 'addon/statusnet/statusnet.php', 'statusnet_cron');
unregister_hook('prepare_body', 'addon/statusnet/statusnet.php', 'statusnet_prepare_body');
+ unregister_hook('check_item_notification','addon/statusnet/statusnet.php', 'statusnet_check_item_notification');
// old setting - remove only
unregister_hook('post_local_end', 'addon/statusnet/statusnet.php', 'statusnet_post_hook');
}
+function statusnet_check_item_notification($a, &$notification_data) {
+ $notification_data["profiles"][] = get_pconfig($notification_data["uid"], 'statusnet', 'own_url');
+}
+
function statusnet_jot_nets(&$a,&$b) {
if(! local_user())
return;
$image = "";
- if (isset($msgarr["url"])) {
+ if (isset($msgarr["url"]) AND ($msgarr["type"] != "photo")) {
if ((strlen($msgarr["url"]) > 20) AND
((strlen($msg." \n".$msgarr["url"]) > $max_char)))
$msg .= " \n".short_link($msgarr["url"]);
$msgarr = plaintext($a, $item, $max_char, true, 7);
$msg = $msgarr["text"];
- if (isset($msgarr["url"]))
+ if (isset($msgarr["url"]) AND ($msgarr["type"] != "photo"))
$msg .= " ".$msgarr["url"];
if (isset($msgarr["image"]))
$_REQUEST["source"] = $post->source;
$_REQUEST["extid"] = NETWORK_STATUSNET;
+ if (isset($post->id)) {
+ $_REQUEST['message_id'] = item_new_uri($a->get_hostname(), $uid, NETWORK_STATUSNET.":".$post->id);
+ }
+
//$_REQUEST["date"] = $post->created_at;
$_REQUEST["title"] = "";
if ($contact->statusnet_profile_url == "")
return(-1);
- // Check if the unique contact is existing
- // To-Do: only update once a while
- $r = q("SELECT id FROM unique_contacts WHERE url='%s' LIMIT 1",
- dbesc(normalise_link($contact->statusnet_profile_url)));
+ update_gcontact(array("url" => $contact->statusnet_profile_url,
+ "network" => NETWORK_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));
- if (count($r) == 0)
- q("INSERT INTO unique_contacts (url, name, nick, avatar) VALUES ('%s', '%s', '%s', '%s')",
- dbesc(normalise_link($contact->statusnet_profile_url)),
- dbesc($contact->name),
- dbesc($contact->screen_name),
- dbesc($contact->profile_image_url));
- else
- q("UPDATE unique_contacts SET name = '%s', nick = '%s', avatar = '%s' WHERE url = '%s'",
- dbesc($contact->name),
- dbesc($contact->screen_name),
- dbesc($contact->profile_image_url),
- dbesc(normalise_link($contact->statusnet_profile_url)));
-
- if (DB_UPDATE_VERSION >= "1177")
- q("UPDATE `unique_contacts` SET `location` = '%s', `about` = '%s' WHERE url = '%s'",
- dbesc($contact->location),
- dbesc($contact->description),
- dbesc(normalise_link($contact->statusnet_profile_url)));
-
- $r = q("SELECT * FROM `contact` WHERE `uid` = %d AND `alias` = '%s' LIMIT 1",
- intval($uid), dbesc(normalise_link($contact->statusnet_profile_url)));
+ $r = q("SELECT * FROM `contact` WHERE `uid` = %d AND `alias` = '%s' AND `network` = '%s'LIMIT 1",
+ intval($uid), dbesc(normalise_link($contact->statusnet_profile_url)), dbesc(NETWORK_STATUSNET));
if(!count($r) AND !$create_user)
return(0);
// create contact record
q("INSERT INTO `contact` ( `uid`, `created`, `url`, `nurl`, `addr`, `alias`, `notify`, `poll`,
`name`, `nick`, `photo`, `network`, `rel`, `priority`,
- `writable`, `blocked`, `readonly`, `pending` )
- VALUES ( %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d, %d, %d, 0, 0, 0 ) ",
+ `location`, `about`, `writable`, `blocked`, `readonly`, `pending` )
+ VALUES ( %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d, %d, '%s', '%s', %d, 0, 0, 0 ) ",
intval($uid),
dbesc(datetime_convert()),
dbesc($contact->statusnet_profile_url),
dbesc(NETWORK_STATUSNET),
intval(CONTACT_IS_FRIEND),
intval(1),
+ dbesc($contact->location),
+ dbesc($contact->description),
intval(1)
);
- $r = q("SELECT * FROM `contact` WHERE `alias` = '%s' AND `uid` = %d LIMIT 1",
+ $r = q("SELECT * FROM `contact` WHERE `alias` = '%s' AND `uid` = %d AND `network` = '%s' LIMIT 1",
dbesc($contact->statusnet_profile_url),
- intval($uid)
- );
+ intval($uid),
+ dbesc(NETWORK_STATUSNET));
if(! count($r))
return(false);
dbesc(datetime_convert()),
intval($contact_id)
);
-
- if (DB_UPDATE_VERSION >= "1177")
- q("UPDATE `contact` SET `location` = '%s',
- `about` = '%s'
- WHERE `id` = %d",
- dbesc($contact->location),
- dbesc($contact->description),
- intval($contact_id)
- );
-
} else {
// update profile photos once every two weeks as we have no notification of when they change.
`nurl` = '%s',
`addr` = '%s',
`name` = '%s',
- `nick` = '%s'
+ `nick` = '%s',
+ `location` = '%s',
+ `about` = '%s'
WHERE `id` = %d",
dbesc($photos[0]),
dbesc($photos[1]),
dbesc(statusnet_address($contact)),
dbesc($contact->name),
dbesc($contact->screen_name),
+ dbesc($contact->location),
+ dbesc($contact->description),
intval($r[0]['id'])
);
-
- if (DB_UPDATE_VERSION >= "1177")
- q("UPDATE `contact` SET `location` = '%s',
- `about` = '%s'
- WHERE `id` = %d",
- dbesc($contact->location),
- dbesc($contact->description),
- intval($r[0]['id'])
- );
}
}
logger('statusnet_fetchhometimeline: User '.$self["nick"].' posted home timeline item '.$item);
- if ($item != 0)
+ if ($item AND !function_exists("check_item_notification"))
statusnet_checknotification($a, $uid, $nick, $item, $postarray);
}
$postarray["id"] = $item;
logger('statusnet_fetchhometimeline: User '.$self["nick"].' posted mention timeline item '.$item);
+
+ if ($item AND function_exists("check_item_notification"))
+ check_item_notification($item, $uid, NOTIFY_TAGSELF);
}
}
$parent_id = $r[0]['parent'];
}
- if ($item != 0) {
+ if (($item != 0) AND !function_exists("check_item_notification")) {
require_once('include/enotify.php');
notification(array(
'type' => NOTIFY_TAGSELF,
$api = get_pconfig($uid, 'statusnet', 'baseapi');
$otoken = get_pconfig($uid, 'statusnet', 'oauthtoken');
$osecret = get_pconfig($uid, 'statusnet', 'oauthsecret');
+ $own_url = get_pconfig($uid, 'statusnet', 'own_url');
require_once('library/twitteroauth.php');
logger('statusnet_complete_conversation: User '.$self["nick"].' posted home timeline item '.$item);
- if ($item != 0)
+ if ($item AND !function_exists("check_item_notification"))
statusnet_checknotification($a, $uid, $nick, $item, $postarray);
}
}