Merge pull request #8242 from annando/addcontact

Asynchronously add contacts to avoid timeout problems
This commit is contained in:
Hypolite Petovan 2020-02-05 20:32:57 -05:00 committed by GitHub
commit dad6b43689
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 25 additions and 1 deletions

View 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'));

24
src/Worker/AddContact.php Normal file
View File

@ -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]);
}
}