]> git.mxchange.org Git - friendica.git/blobdiff - src/Protocol/ActivityPub/Processor.php
Logger Levels
[friendica.git] / src / Protocol / ActivityPub / Processor.php
index dee70f152c08d10aeeb0cfcd7668fba92244a087..7d970c00390b2c87ee6b5bd3e23b1a0745ac7643 100644 (file)
@@ -5,6 +5,7 @@
 namespace Friendica\Protocol\ActivityPub;
 
 use Friendica\Database\DBA;
+use Friendica\Core\Logger;
 use Friendica\Core\Protocol;
 use Friendica\Model\Conversation;
 use Friendica\Model\Contact;
@@ -140,10 +141,12 @@ class Processor
                }
 
                if (($activity['id'] != $activity['reply-to-id']) && !Item::exists(['uri' => $activity['reply-to-id']])) {
-                       logger('Parent ' . $activity['reply-to-id'] . ' not found. Try to refetch it.');
+                       Logger::log('Parent ' . $activity['reply-to-id'] . ' not found. Try to refetch it.');
                        self::fetchMissingActivity($activity['reply-to-id'], $activity);
                }
 
+               $item['diaspora_signed_text'] = defaults($activity, 'diaspora:comment', '');
+
                self::postItem($activity, $item);
        }
 
@@ -156,7 +159,7 @@ class Processor
        {
                $owner = Contact::getIdForURL($activity['actor']);
 
-               logger('Deleting item ' . $activity['object_id'] . ' from ' . $owner, LOGGER_DEBUG);
+               Logger::log('Deleting item ' . $activity['object_id'] . ' from ' . $owner, Logger::DEBUG);
                Item::delete(['uri' => $activity['object_id'], 'owner-id' => $owner]);
        }
 
@@ -174,6 +177,8 @@ class Processor
                $item['gravity'] = GRAVITY_ACTIVITY;
                $item['object-type'] = ACTIVITY_OBJ_NOTE;
 
+               $item['diaspora_signed_text'] = defaults($activity, 'diaspora:like', '');
+
                self::postItem($activity, $item);
        }
 
@@ -207,7 +212,7 @@ class Processor
                }
 
                $event_id = Event::store($event);
-               logger('Event '.$event_id.' was stored', LOGGER_DEBUG);
+               Logger::log('Event '.$event_id.' was stored', Logger::DEBUG);
        }
 
        /**
@@ -221,7 +226,7 @@ class Processor
                /// @todo What to do with $activity['context']?
 
                if (($item['gravity'] != GRAVITY_PARENT) && !Item::exists(['uri' => $item['parent-uri']])) {
-                       logger('Parent ' . $item['parent-uri'] . ' not found, message will be discarded.', LOGGER_DEBUG);
+                       Logger::log('Parent ' . $item['parent-uri'] . ' not found, message will be discarded.', Logger::DEBUG);
                        return;
                }
 
@@ -234,7 +239,7 @@ class Processor
                        $item['owner-link'] = $activity['actor'];
                        $item['owner-id'] = Contact::getIdForURL($activity['actor'], 0, true);
                } else {
-                       logger('Ignoring actor because of thread completion.', LOGGER_DEBUG);
+                       Logger::log('Ignoring actor because of thread completion.', Logger::DEBUG);
                        $item['owner-link'] = $item['author-link'];
                        $item['owner-id'] = $item['author-id'];
                }
@@ -260,7 +265,6 @@ class Processor
                $item['tag'] = self::constructTagList($activity['tags'], $activity['sensitive']);
                $item['app'] = $activity['generator'];
                $item['plink'] = defaults($activity, 'alternate-url', $item['uri']);
-               $item['diaspora_signed_text'] = defaults($activity, 'diaspora:comment', '');
 
                $item = self::constructAttachList($activity['attachments'], $item);
 
@@ -281,7 +285,7 @@ class Processor
                        }
 
                        $item_id = Item::insert($item);
-                       logger('Storing for user ' . $item['uid'] . ': ' . $item_id);
+                       Logger::log('Storing for user ' . $item['uid'] . ': ' . $item_id);
                }
        }
 
@@ -299,7 +303,7 @@ class Processor
 
                $object = ActivityPub::fetchContent($url);
                if (empty($object)) {
-                       logger('Activity ' . $url . ' was not fetchable, aborting.');
+                       Logger::log('Activity ' . $url . ' was not fetchable, aborting.');
                        return;
                }
 
@@ -319,7 +323,7 @@ class Processor
                $ldactivity['thread-completion'] = true;
 
                ActivityPub\Receiver::processActivity($ldactivity);
-               logger('Activity ' . $url . ' had been fetched and processed.');
+               Logger::log('Activity ' . $url . ' had been fetched and processed.');
        }
 
        /**
@@ -357,7 +361,7 @@ class Processor
                }
 
                DBA::update('contact', ['hub-verify' => $activity['id']], ['id' => $cid]);
-               logger('Follow user ' . $uid . ' from contact ' . $cid . ' with id ' . $activity['id']);
+               Logger::log('Follow user ' . $uid . ' from contact ' . $cid . ' with id ' . $activity['id']);
        }
 
        /**
@@ -371,7 +375,7 @@ class Processor
                        return;
                }
 
-               logger('Updating profile for ' . $activity['object_id'], LOGGER_DEBUG);
+               Logger::log('Updating profile for ' . $activity['object_id'], Logger::DEBUG);
                APContact::getByURL($activity['object_id'], true);
        }
 
@@ -383,12 +387,12 @@ class Processor
        public static function deletePerson($activity)
        {
                if (empty($activity['object_id']) || empty($activity['actor'])) {
-                       logger('Empty object id or actor.', LOGGER_DEBUG);
+                       Logger::log('Empty object id or actor.', Logger::DEBUG);
                        return;
                }
 
                if ($activity['object_id'] != $activity['actor']) {
-                       logger('Object id does not match actor.', LOGGER_DEBUG);
+                       Logger::log('Object id does not match actor.', Logger::DEBUG);
                        return;
                }
 
@@ -398,7 +402,7 @@ class Processor
                }
                DBA::close($contacts);
 
-               logger('Deleted contact ' . $activity['object_id'], LOGGER_DEBUG);
+               Logger::log('Deleted contact ' . $activity['object_id'], Logger::DEBUG);
        }
 
        /**
@@ -417,7 +421,7 @@ class Processor
 
                $cid = Contact::getIdForURL($activity['actor'], $uid);
                if (empty($cid)) {
-                       logger('No contact found for ' . $activity['actor'], LOGGER_DEBUG);
+                       Logger::log('No contact found for ' . $activity['actor'], Logger::DEBUG);
                        return;
                }
 
@@ -432,7 +436,7 @@ class Processor
 
                $condition = ['id' => $cid];
                DBA::update('contact', $fields, $condition);
-               logger('Accept contact request from contact ' . $cid . ' for user ' . $uid, LOGGER_DEBUG);
+               Logger::log('Accept contact request from contact ' . $cid . ' for user ' . $uid, Logger::DEBUG);
        }
 
        /**
@@ -451,7 +455,7 @@ class Processor
 
                $cid = Contact::getIdForURL($activity['actor'], $uid);
                if (empty($cid)) {
-                       logger('No contact found for ' . $activity['actor'], LOGGER_DEBUG);
+                       Logger::log('No contact found for ' . $activity['actor'], Logger::DEBUG);
                        return;
                }
 
@@ -459,9 +463,9 @@ class Processor
 
                if (DBA::exists('contact', ['id' => $cid, 'rel' => Contact::SHARING, 'pending' => true])) {
                        Contact::remove($cid);
-                       logger('Rejected contact request from contact ' . $cid . ' for user ' . $uid . ' - contact had been removed.', LOGGER_DEBUG);
+                       Logger::log('Rejected contact request from contact ' . $cid . ' for user ' . $uid . ' - contact had been removed.', Logger::DEBUG);
                } else {
-                       logger('Rejected contact request from contact ' . $cid . ' for user ' . $uid . '.', LOGGER_DEBUG);
+                       Logger::log('Rejected contact request from contact ' . $cid . ' for user ' . $uid . '.', Logger::DEBUG);
                }
        }
 
@@ -504,7 +508,7 @@ class Processor
 
                $cid = Contact::getIdForURL($activity['actor'], $uid);
                if (empty($cid)) {
-                       logger('No contact found for ' . $activity['actor'], LOGGER_DEBUG);
+                       Logger::log('No contact found for ' . $activity['actor'], Logger::DEBUG);
                        return;
                }
 
@@ -516,7 +520,7 @@ class Processor
                }
 
                Contact::removeFollower($owner, $contact);
-               logger('Undo following request from contact ' . $cid . ' for user ' . $uid, LOGGER_DEBUG);
+               Logger::log('Undo following request from contact ' . $cid . ' for user ' . $uid, Logger::DEBUG);
        }
 
        /**
@@ -531,7 +535,7 @@ class Processor
                        return;
                }
 
-               logger('Change existing contact ' . $cid . ' from ' . $contact['network'] . ' to ActivityPub.');
+               Logger::log('Change existing contact ' . $cid . ' from ' . $contact['network'] . ' to ActivityPub.');
                Contact::updateFromProbe($cid, Protocol::ACTIVITYPUB);
        }
 }