1
0
Fork 0

OStatus conversation are now checked every 30 minutes for new answers.

This commit is contained in:
Michael Vogel 2013-02-04 00:57:23 +01:00
parent 2350aa54eb
commit c9307eb96a
3 changed files with 60 additions and 20 deletions

View file

@ -1,9 +1,39 @@
<?php
function complete_conversation($itemid, $conversation_url) {
global $a;
define('OSTATUS_DEFAULT_POLL_INTERVAL', 30); // given in minutes
require_once('include/html2bbcode.php');
require_once('include/items.php');
function check_conversations() {
$last = get_config('system','ostatus_last_poll');
$poll_interval = intval(get_config('system','ostatus_poll_interval'));
if(! $poll_interval)
$poll_interval = OSTATUS_DEFAULT_POLL_INTERVAL;
if($last) {
$next = $last + ($poll_interval * 60);
if($next > time()) {
logger('complete_conversation: poll intervall not reached');
return;
}
}
logger('complete_conversation: cron_start');
$start = date("Y-m-d H:i:s", time() - 86400);
$conversations = q("SELECT * FROM `term` WHERE `type` = 7 AND `term` > '%s'",
dbesc($start));
foreach ($conversations AS $conversation) {
$id = $conversation['oid'];
$url = $conversation['url'];
complete_conversation($id, $url);
}
logger('complete_conversation: cron_end');
set_config('system','ostatus_last_poll', time());
}
function complete_conversation($itemid, $conversation_url, $only_add_conversation = false) {
global $a;
//logger('complete_conversation: completing conversation url '.$conversation_url.' for id '.$itemid);
@ -12,13 +42,6 @@ function complete_conversation($itemid, $conversation_url) {
return;
$message = $messages[0];
// Get the parent
$parents = q("SELECT `id`, `uri`, `contact-id`, `type`, `verb`, `visible` FROM `item` WHERE `uid` = %d AND `id` = %d LIMIT 1",
intval($message["uid"]), intval($message["parent"]));
if (!$parents)
return;
$parent = $parents[0];
// Store conversation url if not done before
$conversation = q("SELECT `url` FROM `term` WHERE `uid` = %d AND `oid` = %d AND `otype` = %d AND `type` = %d",
intval($message["uid"]), intval($itemid), intval(TERM_OBJ_POST), intval(TERM_CONVERSATION));
@ -29,6 +52,19 @@ function complete_conversation($itemid, $conversation_url) {
logger('complete_conversation: Storing conversation url '.$conversation_url.' for id '.$itemid);
}
if ($only_add_conversation)
return;
// Get the parent
$parents = q("SELECT `id`, `uri`, `contact-id`, `type`, `verb`, `visible` FROM `item` WHERE `uid` = %d AND `id` = %d LIMIT 1",
intval($message["uid"]), intval($message["parent"]));
if (!$parents)
return;
$parent = $parents[0];
require_once('include/html2bbcode.php');
require_once('include/items.php');
$conv = str_replace("/conversation/", "/api/statusnet/conversation/", $conversation_url).".as";
logger('complete_conversation: fetching conversation url '.$conv.' for '.$itemid);
@ -111,6 +147,9 @@ function complete_conversation($itemid, $conversation_url) {
$newitem = item_store($arr);
// Add the conversation entry (but don't fetch the whole conversation)
complete_conversation($newitem, $conversation_url, true);
// If the newly created item is the top item then change the parent settings of the thread
if ($newitem AND ($arr["uri"] == $first_id)) {
logger('complete_conversation: setting new parent to id '.$newitem);

View file

@ -86,7 +86,8 @@ function poller_run(&$argv, &$argc){
if($abandon_days < 1)
$abandon_days = 0;
// Check OStatus conversations
check_conversations();
// once daily run birthday_updates and then expire in background

View file

@ -349,11 +349,11 @@
.fancybox-ie .fancybox-bg { background: transparent !important; }
.fancybox-ie #fancybox-bg-n { filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='fancybox/fancy_shadow_n.png', sizingMethod='scale'); }
.fancybox-ie #fancybox-bg-ne { filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='fancybox/fancy_shadow_ne.png', sizingMethod='scale'); }
.fancybox-ie #fancybox-bg-e { filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='fancybox/fancy_shadow_e.png', sizingMethod='scale'); }
.fancybox-ie #fancybox-bg-se { filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='fancybox/fancy_shadow_se.png', sizingMethod='scale'); }
.fancybox-ie #fancybox-bg-s { filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='fancybox/fancy_shadow_s.png', sizingMethod='scale'); }
.fancybox-ie #fancybox-bg-sw { filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='fancybox/fancy_shadow_sw.png', sizingMethod='scale'); }
.fancybox-ie #fancybox-bg-w { filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='fancybox/fancy_shadow_w.png', sizingMethod='scale'); }
.fancybox-ie #fancybox-bg-nw { filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='fancybox/fancy_shadow_nw.png', sizingMethod='scale'); }
.fancybox-ie #fancybox-bg-n { filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='library/fancybox/fancy_shadow_n.png', sizingMethod='scale'); }
.fancybox-ie #fancybox-bg-ne { filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='library/fancybox/fancy_shadow_ne.png', sizingMethod='scale'); }
.fancybox-ie #fancybox-bg-e { filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='library/fancybox/fancy_shadow_e.png', sizingMethod='scale'); }
.fancybox-ie #fancybox-bg-se { filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='library/fancybox/fancy_shadow_se.png', sizingMethod='scale'); }
.fancybox-ie #fancybox-bg-s { filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='library/fancybox/fancy_shadow_s.png', sizingMethod='scale'); }
.fancybox-ie #fancybox-bg-sw { filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='library/fancybox/fancy_shadow_sw.png', sizingMethod='scale'); }
.fancybox-ie #fancybox-bg-w { filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='library/fancybox/fancy_shadow_w.png', sizingMethod='scale'); }
.fancybox-ie #fancybox-bg-nw { filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='library/fancybox/fancy_shadow_nw.png', sizingMethod='scale'); }