define('OSTATUS_DEFAULT_POLL_INTERVAL', 30); // given in minutes
define('OSTATUS_DEFAULT_POLL_TIMEFRAME', 1440); // given in minutes
+define('OSTATUS_DEFAULT_POLL_TIMEFRAME_MENTIONS', 14400); // given in minutes
function ostatus_fetchauthor($xpath, $context, $importer, &$contact) {
return $href;
}
-function check_conversations($override = false) {
+function check_conversations($mentions = false, $override = false) {
$last = get_config('system','ostatus_last_poll');
$poll_interval = intval(get_config('system','ostatus_poll_interval'));
if (($poll_interval < 0) AND !$override)
return;
- $poll_timeframe = intval(get_config('system','ostatus_poll_timeframe'));
- if (!$poll_timeframe)
- $poll_timeframe = OSTATUS_DEFAULT_POLL_TIMEFRAME;
+ if (!$mentions) {
+ $poll_timeframe = intval(get_config('system','ostatus_poll_timeframe'));
+ if (!$poll_timeframe)
+ $poll_timeframe = OSTATUS_DEFAULT_POLL_TIMEFRAME;
+ } else {
+ $poll_timeframe = intval(get_config('system','ostatus_poll_timeframe'));
+ if (!$poll_timeframe)
+ $poll_timeframe = OSTATUS_DEFAULT_POLL_TIMEFRAME_MENTIONS;
+ }
+
if ($last AND !$override) {
$next = $last + ($poll_interval * 60);
logger('cron_start');
$start = date("Y-m-d H:i:s", time() - ($poll_timeframe * 60));
- $conversations = q("SELECT `oid`, `url`, `uid` FROM `term` WHERE `type` = 7 AND `term` > '%s' GROUP BY `url`, `uid` ORDER BY `term` DESC",
- dbesc($start));
+
+ if ($mentions)
+ $conversations = q("SELECT `term`.`oid`, `term`.`url`, `term`.`uid` FROM `term`
+ STRAIGHT_JOIN `thread` ON `thread`.`iid` = `term`.`oid` AND `thread`.`uid` = `term`.`uid`
+ WHERE `term`.`type` = 7 AND `term`.`term` > '%s' AND `thread`.`mention`
+ GROUP BY `term`.`url`, `term`.`uid` ORDER BY `term`.`term` DESC", dbesc($start));
+ else
+ $conversations = q("SELECT `oid`, `url`, `uid` FROM `term`
+ WHERE `type` = 7 AND `term` > '%s'
+ GROUP BY `url`, `uid` ORDER BY `term` DESC", dbesc($start));
foreach ($conversations AS $conversation) {
ostatus_completion($conversation['url'], $conversation['uid']);