]> git.mxchange.org Git - friendica.git/commitdiff
New function "add"
authorMichael <heluecht@pirati.ca>
Thu, 23 Jan 2025 21:42:11 +0000 (21:42 +0000)
committerMichael <heluecht@pirati.ca>
Fri, 24 Jan 2025 06:52:20 +0000 (06:52 +0000)
src/Model/Contact/Relation.php
src/Worker/AddContact.php

index 736c4361dd3309b5ccee1ff9df86917e861df3c1..b5c6680f3e40a2fbe4e34f289a36a2dfde3a3934 100644 (file)
@@ -24,6 +24,7 @@ use Friendica\Protocol\ActivityPub;
 use Friendica\Util\DateTimeFormat;
 use Friendica\Util\Network;
 use Friendica\Util\Strings;
+use Friendica\Worker\AddContact;
 
 /**
  * This class provides relationship information based on the `contact-relation` table.
@@ -179,7 +180,7 @@ class Relation
                                        $following_counter++;
                                }
                        } elseif (!Network::isUrlBlocked($contact_url)) {
-                               Worker::add(Worker::PRIORITY_LOW, 'AddContact', 0, $contact_url);
+                               AddContact::add(Worker::PRIORITY_LOW, 0, $contact_url);
                        }
                }
 
index 3b27c7e78d866e9fdb8fd4945a49e0f2e7020297..658a1ebcd1a59ed1f5b06b413f3642717fa914d1 100644 (file)
@@ -7,10 +7,12 @@
 
 namespace Friendica\Worker;
 
+use Friendica\Core\Worker;
 use Friendica\DI;
 use Friendica\Model\Contact;
 use Friendica\Network\HTTPException\InternalServerErrorException;
 use Friendica\Network\HTTPException\NotFoundException;
+use Friendica\Util\Network;
 
 class AddContact
 {
@@ -39,4 +41,20 @@ class AddContact
                        DI::logger()->notice('Imagick not found.', ['exception' => $e, 'uid' => $uid, 'url' => $url]);
                }
        }
+
+       /**
+        * @param array|int $run_parameters Priority constant or array of options described in Worker::add
+        * @param int    $uid User ID
+        * @param string $url Contact link
+        * @return int
+        */
+       public static function add($run_parameters, int $uid, string $url): int
+       {
+               if (Network::isUrlBlocked($url)) {
+                       return 0;
+               }
+
+               DI::logger()->debug('Add contact', ['uid' => $uid, 'url' => $url]);
+               return Worker::add($run_parameters, 'AddContact', 0, $url);
+       }
 }