New option to fetch only mentions.

pull/268/head
Michael Vogel 2015-05-31 23:11:21 +02:00
parent 46f0493742
commit 708c670ee4
1 changed files with 62 additions and 51 deletions

View File

@ -280,8 +280,11 @@ function statusnet_settings(&$a,&$s) {
$defchecked = (($defenabled) ? ' checked="checked" ' : '');
$mirrorenabled = get_pconfig(local_user(),'statusnet','mirror_posts');
$mirrorchecked = (($mirrorenabled) ? ' checked="checked" ' : '');
$importenabled = get_pconfig(local_user(),'statusnet','import');
$importchecked = (($importenabled) ? ' checked="checked" ' : '');
$import = get_pconfig(local_user(),'statusnet','import');
$importselected = array("", "", "");
$importselected[$import] = ' selected="selected"';
//$importenabled = get_pconfig(local_user(),'statusnet','import');
//$importchecked = (($importenabled) ? ' checked="checked" ' : '');
$create_userenabled = get_pconfig(local_user(),'statusnet','create_user');
$create_userchecked = (($create_userenabled) ? ' checked="checked" ' : '');
@ -388,11 +391,18 @@ function statusnet_settings(&$a,&$s) {
$s .= '<label id="statusnet-mirror-label" for="statusnet-mirror">'.t('Mirror all posts from statusnet that are no replies or repeated messages').'</label>';
$s .= '<input id="statusnet-mirror" type="checkbox" name="statusnet-mirror" value="1" '. $mirrorchecked . '/>';
$s .= '<div class="clear"></div>';
$s .= '</div>';
$s .= '<label id="statusnet-import-label" for="statusnet-import">'.t('Import the remote timeline').'</label>';
$s .= '<input id="statusnet-import" type="checkbox" name="statusnet-import" value="1" '. $importchecked . '/>';
//$s .= '<input id="statusnet-import" type="checkbox" name="statusnet-import" value="1" '. $importchecked . '/>';
$s .= '<select name="statusnet-import" id="statusnet-import" />';
$s .= '<option value="0" '.$importselected[0].'>'.t("Disabled").'</option>';
$s .= '<option value="1" '.$importselected[1].'>'.t("Full Timeline").'</option>';
$s .= '<option value="2" '.$importselected[2].'>'.t("Only Mentions").'</option>';
$s .= '</select>';
$s .= '<div class="clear"></div>';
/*
$s .= '<label id="statusnet-create_user-label" for="statusnet-create_user">'.t('Automatically create contacts').'</label>';
@ -768,7 +778,7 @@ function statusnet_cron($a,$b) {
$abandon_limit = date("Y-m-d H:i:s", time() - $abandon_days * 86400);
$r = q("SELECT * FROM `pconfig` WHERE `cat` = 'statusnet' AND `k` = 'import' AND `v` = '1' ORDER BY RAND()");
$r = q("SELECT * FROM `pconfig` WHERE `cat` = 'statusnet' AND `k` = 'import' AND `v` ORDER BY RAND()");
if(count($r)) {
foreach($r as $rr) {
if ($abandon_days != 0) {
@ -780,7 +790,7 @@ function statusnet_cron($a,$b) {
}
logger('statusnet: importing timeline from user '.$rr['uid']);
statusnet_fetchhometimeline($a, $rr["uid"]);
statusnet_fetchhometimeline($a, $rr["uid"], $rr["v"]);
}
}
@ -1318,7 +1328,7 @@ function statusnet_checknotification($a, $uid, $own_url, $top_item, $postarray)
}
}
function statusnet_fetchhometimeline($a, $uid) {
function statusnet_fetchhometimeline($a, $uid, $mode = 1) {
$conversations = array();
$ckey = get_pconfig($uid, 'statusnet', 'consumerkey');
@ -1371,7 +1381,7 @@ function statusnet_fetchhometimeline($a, $uid) {
$parameters = array("exclude_replies" => false, "trim_user" => false, "contributor_details" => true, "include_rts" => true);
//$parameters["count"] = 200;
if ($mode == 1) {
// Fetching timeline
$lastid = get_pconfig($uid, 'statusnet', 'lasthometimelineid');
//$lastid = 1;
@ -1433,6 +1443,7 @@ function statusnet_fetchhometimeline($a, $uid) {
}
}
set_pconfig($uid, 'statusnet', 'lasthometimelineid', $lastid);
}
// Fetching mentions
$lastid = get_pconfig($uid, 'statusnet', 'lastmentionid');