Merge pull request #268 from annando/1505-statusnet-mentions

New option to fetch only mentions.
This commit is contained in:
fabrixxm 2015-06-08 08:34:13 +02:00
commit d6eeed7be2

View file

@ -280,8 +280,11 @@ function statusnet_settings(&$a,&$s) {
$defchecked = (($defenabled) ? ' checked="checked" ' : ''); $defchecked = (($defenabled) ? ' checked="checked" ' : '');
$mirrorenabled = get_pconfig(local_user(),'statusnet','mirror_posts'); $mirrorenabled = get_pconfig(local_user(),'statusnet','mirror_posts');
$mirrorchecked = (($mirrorenabled) ? ' checked="checked" ' : ''); $mirrorchecked = (($mirrorenabled) ? ' checked="checked" ' : '');
$importenabled = get_pconfig(local_user(),'statusnet','import'); $import = get_pconfig(local_user(),'statusnet','import');
$importchecked = (($importenabled) ? ' checked="checked" ' : ''); $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_userenabled = get_pconfig(local_user(),'statusnet','create_user');
$create_userchecked = (($create_userenabled) ? ' checked="checked" ' : ''); $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 .= '<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 .= '<input id="statusnet-mirror" type="checkbox" name="statusnet-mirror" value="1" '. $mirrorchecked . '/>';
$s .= '<div class="clear"></div>'; $s .= '<div class="clear"></div>';
$s .= '</div>'; $s .= '</div>';
$s .= '<label id="statusnet-import-label" for="statusnet-import">'.t('Import the remote timeline').'</label>'; $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 .= '<div class="clear"></div>';
/* /*
$s .= '<label id="statusnet-create_user-label" for="statusnet-create_user">'.t('Automatically create contacts').'</label>'; $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); $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)) { if(count($r)) {
foreach($r as $rr) { foreach($r as $rr) {
if ($abandon_days != 0) { if ($abandon_days != 0) {
@ -780,7 +790,7 @@ function statusnet_cron($a,$b) {
} }
logger('statusnet: importing timeline from user '.$rr['uid']); 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(); $conversations = array();
$ckey = get_pconfig($uid, 'statusnet', 'consumerkey'); $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 = array("exclude_replies" => false, "trim_user" => false, "contributor_details" => true, "include_rts" => true);
//$parameters["count"] = 200; //$parameters["count"] = 200;
if ($mode == 1) {
// Fetching timeline // Fetching timeline
$lastid = get_pconfig($uid, 'statusnet', 'lasthometimelineid'); $lastid = get_pconfig($uid, 'statusnet', 'lasthometimelineid');
//$lastid = 1; //$lastid = 1;
@ -1433,6 +1443,7 @@ function statusnet_fetchhometimeline($a, $uid) {
} }
} }
set_pconfig($uid, 'statusnet', 'lasthometimelineid', $lastid); set_pconfig($uid, 'statusnet', 'lasthometimelineid', $lastid);
}
// Fetching mentions // Fetching mentions
$lastid = get_pconfig($uid, 'statusnet', 'lastmentionid'); $lastid = get_pconfig($uid, 'statusnet', 'lastmentionid');