]> git.mxchange.org Git - friendica.git/commitdiff
Asynchronously add contacts to avoid timeout problems
authorMichael <heluecht@pirati.ca>
Thu, 6 Feb 2020 00:00:00 +0000 (00:00 +0000)
committerMichael <heluecht@pirati.ca>
Thu, 6 Feb 2020 00:00:00 +0000 (00:00 +0000)
mod/settings.php
src/Worker/AddContact.php [new file with mode: 0644]

index 69d9c77c9fd2fe78c60b38213957b8d4eb7cce56..dde7bbf478b70592b612a70e42462563b7eadead 100644 (file)
@@ -403,7 +403,7 @@ function settings_post(App $a)
                                        // "http" or "@" to be present in the string.
                                        // All other fields from the row will be ignored
                                        if ((strpos($csvRow[0],'@') !== false) || (strpos($csvRow[0],'http') !== false)) {
-                                               $arr = Contact::createFromProbe($_SESSION['uid'], $csvRow[0], '', false);
+                                               Worker::add(PRIORITY_LOW, 'AddContact', $_SESSION['uid'], $csvRow[0]);
                                        }
                                }
                                info(DI::l10n()->t('Importing Contacts done'));
diff --git a/src/Worker/AddContact.php b/src/Worker/AddContact.php
new file mode 100644 (file)
index 0000000..47d9d01
--- /dev/null
@@ -0,0 +1,24 @@
+<?php
+
+/**
+ * @file src/Worker/AddContact.php
+ */
+
+namespace Friendica\Worker;
+
+use Friendica\Core\Logger;
+use Friendica\Model\Contact;
+
+class AddContact
+{
+       /**
+        * Add contact data via probe
+        * @param int    $uid User ID
+        * @param string $url Contact link
+        */
+       public static function execute(int $uid, string $url)
+       {
+               $result = Contact::createFromProbe($uid, $url, '', false);
+               Logger::info('Added contact', ['uid' => $uid, 'url' => $url, 'result' => $result]);
+       }
+}