]> git.mxchange.org Git - friendica.git/blobdiff - include/onepoll.php
redoing the change concerning the hostname.
[friendica.git] / include / onepoll.php
index f66a48dd46a6d4c831ecafe6f5160b466f9c51e8..f38f6b4c61d88fbf54528267d3940e52f64530d5 100644 (file)
@@ -42,7 +42,7 @@ function onepoll_run(&$argv, &$argc){
        load_hooks();
 
        logger('onepoll: start');
-       
+
        $manual_id  = 0;
        $generation = 0;
        $hub_update = false;
@@ -56,7 +56,17 @@ function onepoll_run(&$argv, &$argc){
                logger('onepoll: no contact');
                return;
        }
-       
+
+       // Test
+       $lockpath = get_config('system','lockpath');
+       if ($lockpath != '') {
+               $pidfile = new pidfile($lockpath, 'onepoll'.$contact_id.'.lck');
+               if($pidfile->is_already_running()) {
+                       logger("onepoll: Already running for contact ".$contact_id);
+                       exit;
+               }
+       }
+
 
        $d = datetime_convert();
 
@@ -331,13 +341,17 @@ function onepoll_run(&$argv, &$argc){
                                                );
 
                                                if(count($r)) {
-                                                       logger("Mail: Seen before ".$msg_uid." for ".$mailconf[0]['user'],LOGGER_DEBUG);
-                                                       if($meta->deleted && ! $r[0]['deleted']) {
-                                                               q("UPDATE `item` SET `deleted` = 1, `changed` = '%s' WHERE `id` = %d LIMIT 1",
-                                                                       dbesc(datetime_convert()),
-                                                                       intval($r[0]['id'])
-                                                               );
-                                                       }
+                                                       logger("Mail: Seen before ".$msg_uid." for ".$mailconf[0]['user']." UID: ".$importer_uid." URI: ".$datarray['uri'],LOGGER_DEBUG);
+
+                                                       // Only delete when mails aren't automatically moved or deleted
+                                                       if (($mailconf[0]['action'] != 1) AND ($mailconf[0]['action'] != 3))
+                                                               if($meta->deleted && ! $r[0]['deleted']) {
+                                                                       q("UPDATE `item` SET `deleted` = 1, `changed` = '%s' WHERE `id` = %d LIMIT 1",
+                                                                               dbesc(datetime_convert()),
+                                                                               intval($r[0]['id'])
+                                                                       );
+                                                               }
+
                                                        switch ($mailconf[0]['action']) {
                                                                case 0:
                                                                        logger("Mail: Seen before ".$msg_uid." for ".$mailconf[0]['user'].". Doing nothing.", LOGGER_DEBUG);
@@ -426,6 +440,7 @@ function onepoll_run(&$argv, &$argc){
                                                        continue;
                                                }
                                                $datarray['body'] = escape_tags($r['body']);
+                                               $datarray['body'] = limit_body_size($datarray['body']);
 
                                                logger("Mail: Importing ".$msg_uid." for ".$mailconf[0]['user']);
 
@@ -536,10 +551,10 @@ function onepoll_run(&$argv, &$argc){
                if($contact['network'] === NETWORK_DFRN || $contact['blocked'] || $contact['readonly'])
                        $hubmode = 'unsubscribe';
 
-               if($contact['network'] === NETWORK_OSTATUS && (! $contact['hub-verify']))
+               if(($contact['network'] === NETWORK_OSTATUS ||  $contact['network'] == NETWORK_FEED) && (! $contact['hub-verify']))
                        $hub_update = true;
 
-               if((strlen($hub)) && ($hub_update) && ($contact['rel'] != CONTACT_IS_FOLLOWER)) {
+               if((strlen($hub)) && ($hub_update) && (($contact['rel'] != CONTACT_IS_FOLLOWER) || $contact['network'] == NETWORK_FEED) ) {
                        logger('poller: hub ' . $hubmode . ' : ' . $hub . ' contact name : ' . $contact['name'] . ' local user : ' . $importer['name']);
                        $hubs = explode(',', $hub);
                        if(count($hubs)) {