@@ -15,7+15,7 @@ function onepoll_run(&$argv, &$argc){
if(is_null($a)) {
$a = new App;
}
if(is_null($a)) {
$a = new App;
}
-
+
if(is_null($db)) {
@include(".htconfig.php");
require_once("include/dba.php");
if(is_null($db)) {
@include(".htconfig.php");
require_once("include/dba.php");
@@ -57,28+57,30 @@ function onepoll_run(&$argv, &$argc){
return;
}
return;
}
- // Test
- $lockpath = get_config('system','lockpath');
+ $lockpath = get_lockpath();
if ($lockpath != '') {
if ($lockpath != '') {
- $pidfile = new pidfile($lockpath, 'onepoll'.$contact_id.'.lck');
- if($pidfile->is_already_running()) {
+ $pidfile = new pidfile($lockpath, 'onepoll'.$contact_id);
+ if($pidfile->is_already_running()) {
logger("onepoll: Already running for contact ".$contact_id);
logger("onepoll: Already running for contact ".$contact_id);
+ if ($pidfile->running_time() > 9*60) {
+ $pidfile->kill();
+ logger("killed stale process");
+ }
exit;
}
}
exit;
}
}
-
$d = datetime_convert();
// Only poll from those with suitable relationships,
$d = datetime_convert();
// Only poll from those with suitable relationships,
- // and which have a polling address and ignore Diaspora since
+ // and which have a polling address and ignore Diaspora since
// we are unable to match those posts with a Diaspora GUID and prevent duplicates.
// we are unable to match those posts with a Diaspora GUID and prevent duplicates.
- $contacts = q("SELECT `contact`.* FROM `contact`
+ $contacts = q("SELECT `contact`.* FROM `contact`
WHERE ( `rel` = %d OR `rel` = %d ) AND `poll` != ''
AND NOT `network` IN ( '%s', '%s', '%s' )
AND `contact`.`id` = %d
WHERE ( `rel` = %d OR `rel` = %d ) AND `poll` != ''
AND NOT `network` IN ( '%s', '%s', '%s' )
AND `contact`.`id` = %d
- AND `self` = 0 AND `contact`.`blocked` = 0 AND `contact`.`readonly` = 0
+ AND `self` = 0 AND `contact`.`blocked` = 0 AND `contact`.`readonly` = 0
AND `contact`.`archive` = 0 LIMIT 1",
intval(CONTACT_IS_SHARING),
intval(CONTACT_IS_FRIEND),
AND `contact`.`archive` = 0 LIMIT 1",
intval(CONTACT_IS_SHARING),
intval(CONTACT_IS_FRIEND),
@@ -112,7+114,7 @@ function onepoll_run(&$argv, &$argc){
$importer_uid = $contact['uid'];
$importer_uid = $contact['uid'];
- $r = q("SELECT `contact`.*, `user`.`page-flags` FROM `contact` LEFT JOIN `user` on `contact`.`uid` = `user`.`uid` WHERE `user`.`uid` = %d AND `contact`.`self` = 1 LIMIT 1",
+ $r = q("SELECT `contact`.*, `user`.`page-flags` FROM `contact` INNER JOIN `user` on `contact`.`uid` = `user`.`uid` WHERE `user`.`uid` = %d AND `contact`.`self` = 1 LIMIT 1",
intval($importer_uid)
);
if(! count($r))
intval($importer_uid)
);
if(! count($r))
@@ -174,7+176,7 @@ function onepoll_run(&$argv, &$argc){
return;
}
return;
}
- if(! strstr($handshake_xml,'<?xml')) {
+ if(! strstr($handshake_xml,'<')) {
logger('poller: response from ' . $url . ' did not contain XML.');
mark_for_death($contact);
logger('poller: response from ' . $url . ' did not contain XML.');
mark_for_death($contact);
@@ -282,13+284,13 @@ function onepoll_run(&$argv, &$argc){
@@ -330,6+334,8 @@ function onepoll_run(&$argv, &$argc){
logger("Mail: Parsing mail ".$msg_uid, LOGGER_DATA);
$datarray = array();
logger("Mail: Parsing mail ".$msg_uid, LOGGER_DATA);
$datarray = array();
+ $datarray['verb'] = ACTIVITY_POST;
+ $datarray['object-type'] = ACTIVITY_OBJ_NOTE;
// $meta = email_msg_meta($mbox,$msg_uid);
// $headers = email_msg_headers($mbox,$msg_uid);
// $meta = email_msg_meta($mbox,$msg_uid);
// $headers = email_msg_headers($mbox,$msg_uid);
@@ -423,7+429,6 @@ function onepoll_run(&$argv, &$argc){
// If it seems to be a reply but a header couldn't be found take the last message with matching subject
if(!x($datarray,'parent-uri') and $reply) {
// If it seems to be a reply but a header couldn't be found take the last message with matching subject
if(!x($datarray,'parent-uri') and $reply) {
- //$r = q("SELECT `uri` , `parent-uri` FROM `item` WHERE MATCH (`title`) AGAINST ('".'"%s"'."' IN BOOLEAN MODE) AND `uid` = %d ORDER BY `created` DESC LIMIT 1",
$r = q("SELECT `uri` , `parent-uri` FROM `item` WHERE `title` = \"%s\" AND `uid` = %d ORDER BY `created` DESC LIMIT 1",
dbesc(protect_sprintf($datarray['title'])),
intval($importer_uid));
$r = q("SELECT `uri` , `parent-uri` FROM `item` WHERE `title` = \"%s\" AND `uid` = %d ORDER BY `created` DESC LIMIT 1",
dbesc(protect_sprintf($datarray['title'])),
intval($importer_uid));
@@ -520,7+525,10 @@ function onepoll_run(&$argv, &$argc){
}
}
}
}
}
}
- }
+ } else
+ logger("Mail: no mails for ".$mailconf[0]['user']);
+
+ logger("Mail: closing connection for ".$mailconf[0]['user']);
imap_close($mbox);
}
}
imap_close($mbox);
}
}
@@ -534,7+542,7 @@ function onepoll_run(&$argv, &$argc){
if($xml) {
logger('poller: received xml : ' . $xml, LOGGER_DATA);
if($xml) {
logger('poller: received xml : ' . $xml, LOGGER_DATA);