* @param array $condition condition array with the key values
* @param array|boolean $old_fields array with the old field values that are about to be replaced (true = update on duplicate, false = don't update identical fields)
*
* @param array $condition condition array with the key values
* @param array|boolean $old_fields array with the old field values that are about to be replaced (true = update on duplicate, false = don't update identical fields)
*
$background_update = DI::config()->get('system', 'update_active_contacts') ? $contact['local-data'] : true;
// Update the contact in the background if needed
$background_update = DI::config()->get('system', 'update_active_contacts') ? $contact['local-data'] : true;
// Update the contact in the background if needed
try {
UpdateContact::add(['priority' => Worker::PRIORITY_LOW, 'dont_fork' => true], $contact['id']);
} catch (\InvalidArgumentException $e) {
try {
UpdateContact::add(['priority' => Worker::PRIORITY_LOW, 'dont_fork' => true], $contact['id']);
} catch (\InvalidArgumentException $e) {
if (self::canReceivePrivateMessages($contact) && empty($contact['pending'])) {
$pm_url = 'message/new/' . $contact['id'];
}
if (self::canReceivePrivateMessages($contact) && empty($contact['pending'])) {
$pm_url = 'message/new/' . $contact['id'];
}
try {
UpdateContact::add(['priority' => Worker::PRIORITY_LOW, 'dont_fork' => true], $contact['id']);
} catch (\InvalidArgumentException $e) {
try {
UpdateContact::add(['priority' => Worker::PRIORITY_LOW, 'dont_fork' => true], $contact['id']);
} catch (\InvalidArgumentException $e) {
* @return string photo path
*/
private static function getAvatarPath(array $contact, string $size, bool $no_update = false): string
* @return string photo path
*/
private static function getAvatarPath(array $contact, string $size, bool $no_update = false): string
* @return string photo path
*/
public static function getPhoto(array $contact, bool $no_update = false): string
* @return string photo path
*/
public static function getPhoto(array $contact, bool $no_update = false): string
* @return string photo path
*/
public static function getThumb(array $contact, bool $no_update = false): string
* @return string photo path
*/
public static function getThumb(array $contact, bool $no_update = false): string
* @return string photo path
*/
public static function getMicro(array $contact, bool $no_update = false): string
* @return string photo path
*/
public static function getMicro(array $contact, bool $no_update = false): string
* @return array contact array with avatar cache fields
*/
private static function checkAvatarCacheByArray(array $contact, bool $no_update = false): array
* @return array contact array with avatar cache fields
*/
private static function checkAvatarCacheByArray(array $contact, bool $no_update = false): array
if (($contact['avatar'] != $avatar) || empty($contact['blurhash'])) {
$update_fields = ['avatar' => $avatar];
if (!Network::isLocalLink($avatar)) {
if (($contact['avatar'] != $avatar) || empty($contact['blurhash'])) {
$update_fields = ['avatar' => $avatar];
if (!Network::isLocalLink($avatar)) {
- $fetchResult = HTTPSignature::fetchRaw($avatar, 0, [HttpClientOptions::ACCEPT_CONTENT => [HttpClientAccept::IMAGE]]);
-
- $img_str = $fetchResult->getBody();
- if (!empty($img_str)) {
- $image = new Image($img_str, Images::getMimeTypeByData($img_str));
- if ($image->isValid()) {
- $update_fields['blurhash'] = $image->getBlurHash();
- } else {
- return;
+ try {
+ $fetchResult = HTTPSignature::fetchRaw($avatar, 0, [HttpClientOptions::ACCEPT_CONTENT => [HttpClientAccept::IMAGE]]);
+
+ $img_str = $fetchResult->getBody();
+ if (!empty($img_str)) {
+ $image = new Image($img_str, Images::getMimeTypeByData($img_str));
+ if ($image->isValid()) {
+ $update_fields['blurhash'] = $image->getBlurHash();
+ } else {
+ return;
+ }
$condition = ['self' => false, 'nurl' => Strings::normaliseLink($url)];
$condition['network'] = [Protocol::DFRN, Protocol::DIASPORA, Protocol::ACTIVITYPUB];
$condition = ['self' => false, 'nurl' => Strings::normaliseLink($url)];
$condition['network'] = [Protocol::DFRN, Protocol::DIASPORA, Protocol::ACTIVITYPUB];
self::update($fields, $condition);
// We mustn't set the update fields for OStatus contacts since they are updated in OnePoll
self::update($fields, $condition);
// We mustn't set the update fields for OStatus contacts since they are updated in OnePoll
// Periodical checks are only done on federated contacts
$failed_next_update = null;
$success_next_update = null;
} elseif ($has_local_data) {
$failed_next_update = GServer::getNextUpdateDate(false, $created, $last_update, !in_array($contact['network'], Protocol::FEDERATED));
$success_next_update = GServer::getNextUpdateDate(true, $created, $last_update, !in_array($contact['network'], Protocol::FEDERATED));
// Periodical checks are only done on federated contacts
$failed_next_update = null;
$success_next_update = null;
} elseif ($has_local_data) {
$failed_next_update = GServer::getNextUpdateDate(false, $created, $last_update, !in_array($contact['network'], Protocol::FEDERATED));
$success_next_update = GServer::getNextUpdateDate(true, $created, $last_update, !in_array($contact['network'], Protocol::FEDERATED));
$failed_next_update = DateTimeFormat::utc('now +6 month');
$success_next_update = DateTimeFormat::utc('now +1 month');
$failed_next_update = DateTimeFormat::utc('now +6 month');
$success_next_update = DateTimeFormat::utc('now +1 month');
if (($user['notify-flags'] & Notification\Type::INTRO) && $user['page-flags'] == User::PAGE_FLAGS_NORMAL) {
DI::notify()->createFromArray([
if (($user['notify-flags'] & Notification\Type::INTRO) && $user['page-flags'] == User::PAGE_FLAGS_NORMAL) {
DI::notify()->createFromArray([
- * @param string $search Name or nick
- * @param string $mode Search mode (e.g. "community")
- * @param int $uid User ID
- * @param int $limit Maximum amount of returned values
- * @param int $offset Limit offset
+ * @param string $search Name or nick
+ * @param string $mode Search mode (e.g. "community")
+ * @param bool $show_blocked Show users from blocked servers. Default is false
+ * @param int $uid User ID
+ * @param int $limit Maximum amount of returned values
+ * @param int $offset Limit offset
*
* @return array with search results
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
*
* @return array with search results
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
- public static function searchByName(string $search, string $mode = '', int $uid = 0, int $limit = 0, int $offset = 0): array
+ public static function searchByName(string $search, string $mode = '', bool $show_blocked = false, int $uid = 0, int $limit = 0, int $offset = 0): array
- $condition = ['network' => $networks, 'failed' => false, 'deleted' => false, 'uid' => $uid];
+ $condition = [
+ 'network' => $networks,
+ 'server-failed' => false,
+ 'failed' => false,
+ 'deleted' => false,
+ 'unsearchable' => false,
+ 'uid' => $uid
+ ];
+
+ if (!$show_blocked) {
+ $condition['server-blocked'] = true;
+ }
- ["(NOT `unsearchable` OR `nurl` IN (SELECT `nurl` FROM `owner-view` WHERE `publish` OR `net-publish`))
- AND (`addr` LIKE ? OR `name` LIKE ? OR `nick` LIKE ?)", $search, $search, $search]);
+ ["(`addr` LIKE ? OR `name` LIKE ? OR `nick` LIKE ?)", $search, $search, $search]);
- return self::selectToArray([], $condition, $params);
+ return DBA::selectToArray('account-user-view', [], $condition, $params);
if (empty($contact['id']) && Network::isValidHttpUrl($url)) {
Worker::add(Worker::PRIORITY_LOW, 'AddContact', 0, $url);
++$added;
if (empty($contact['id']) && Network::isValidHttpUrl($url)) {
Worker::add(Worker::PRIORITY_LOW, 'AddContact', 0, $url);
++$added;