mirror of
https://github.com/friendica/friendica
synced 2025-04-27 03:50:11 +00:00
Merge branch 'friendica:2022.12-rc' into new_image_presentation
This commit is contained in:
commit
c7811576cc
24 changed files with 167 additions and 72 deletions
|
@ -291,14 +291,11 @@ class APContact
|
|||
return $fetched_contact;
|
||||
}
|
||||
|
||||
$parts = parse_url($apcontact['url']);
|
||||
unset($parts['scheme']);
|
||||
unset($parts['path']);
|
||||
|
||||
if (empty($apcontact['addr'])) {
|
||||
if (!empty($apcontact['nick']) && is_array($parts)) {
|
||||
$apcontact['addr'] = $apcontact['nick'] . '@' . str_replace('//', '', Network::unparseURL($parts));
|
||||
} else {
|
||||
try {
|
||||
$apcontact['addr'] = $apcontact['nick'] . '@' . (new Uri($apcontact['url']))->getAuthority();
|
||||
} catch (\Throwable $e) {
|
||||
Logger::warning('Unable to coerce APContact URL into a UriInterface object', ['url' => $apcontact['url'], 'error' => $e->getMessage()]);
|
||||
$apcontact['addr'] = '';
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1395,7 +1395,17 @@ class Contact
|
|||
}
|
||||
|
||||
if ($data['network'] == Protocol::DIASPORA) {
|
||||
DI::dsprContact()->updateFromProbeArray($data);
|
||||
try {
|
||||
DI::dsprContact()->updateFromProbeArray($data);
|
||||
} catch (\InvalidArgumentException $e) {
|
||||
Logger::error($e->getMessage(), ['url' => $url, 'data' => $data]);
|
||||
}
|
||||
} elseif (!empty($data['networks'][Protocol::DIASPORA])) {
|
||||
try {
|
||||
DI::dsprContact()->updateFromProbeArray($data['networks'][Protocol::DIASPORA]);
|
||||
} catch (\InvalidArgumentException $e) {
|
||||
Logger::error($e->getMessage(), ['url' => $url, 'data' => $data['networks'][Protocol::DIASPORA]]);
|
||||
}
|
||||
}
|
||||
|
||||
self::updateFromProbeArray($contact_id, $data);
|
||||
|
@ -2097,7 +2107,7 @@ class Contact
|
|||
if ($static) {
|
||||
$query_params['static'] = true;
|
||||
}
|
||||
|
||||
|
||||
return $url . ($guid ?: $cid) . (!empty($query_params) ? '?' . http_build_query($query_params) : '');
|
||||
}
|
||||
|
||||
|
@ -2483,13 +2493,23 @@ class Contact
|
|||
return false;
|
||||
}
|
||||
|
||||
$ret = Probe::uri($contact['url'], $network, $contact['uid']);
|
||||
$data = Probe::uri($contact['url'], $network, $contact['uid']);
|
||||
|
||||
if ($ret['network'] == Protocol::DIASPORA) {
|
||||
DI::dsprContact()->updateFromProbeArray($ret);
|
||||
if ($data['network'] == Protocol::DIASPORA) {
|
||||
try {
|
||||
DI::dsprContact()->updateFromProbeArray($data);
|
||||
} catch (\InvalidArgumentException $e) {
|
||||
Logger::error($e->getMessage(), ['id' => $id, 'network' => $network, 'contact' => $contact, 'data' => $data]);
|
||||
}
|
||||
} elseif (!empty($data['networks'][Protocol::DIASPORA])) {
|
||||
try {
|
||||
DI::dsprContact()->updateFromProbeArray($data['networks'][Protocol::DIASPORA]);
|
||||
} catch (\InvalidArgumentException $e) {
|
||||
Logger::error($e->getMessage(), ['id' => $id, 'network' => $network, 'contact' => $contact, 'data' => $data]);
|
||||
}
|
||||
}
|
||||
|
||||
return self::updateFromProbeArray($id, $ret);
|
||||
return self::updateFromProbeArray($id, $data);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -2671,7 +2691,7 @@ class Contact
|
|||
}
|
||||
|
||||
$update = false;
|
||||
$guid = ($ret['guid'] ?? '') ?: Item::guidFromUri($ret['url'], parse_url($ret['url'], PHP_URL_HOST));
|
||||
$guid = ($ret['guid'] ?? '') ?: Item::guidFromUri($ret['url']);
|
||||
|
||||
// make sure to not overwrite existing values with blank entries except some technical fields
|
||||
$keep = ['batch', 'notify', 'poll', 'request', 'confirm', 'poco', 'baseurl'];
|
||||
|
@ -3189,8 +3209,9 @@ class Contact
|
|||
self::clearFollowerFollowingEndpointCache($contact['uid']);
|
||||
|
||||
$cdata = self::getPublicAndUserContactID($contact['id'], $contact['uid']);
|
||||
|
||||
DI::notification()->deleteForUserByVerb($contact['uid'], Activity::FOLLOW, ['actor-id' => $cdata['public']]);
|
||||
if (!empty($cdata['public'])) {
|
||||
DI::notification()->deleteForUserByVerb($contact['uid'], Activity::FOLLOW, ['actor-id' => $cdata['public']]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -2036,9 +2036,10 @@ class Item
|
|||
* Posts that are created on this system are using System::createUUID.
|
||||
* Received ActivityPub posts are using Processor::getGUIDByURL.
|
||||
*
|
||||
* @param string $uri uri of an item entry
|
||||
* @param string $uri uri of an item entry
|
||||
* @param string|null $host hostname for the GUID prefix
|
||||
* @return string Unique guid
|
||||
* @throws \Exception
|
||||
*/
|
||||
public static function guidFromUri(string $uri, string $host = null): string
|
||||
{
|
||||
|
@ -2049,11 +2050,16 @@ class Item
|
|||
// Remove the scheme to make sure that "https" and "http" doesn't make a difference
|
||||
unset($parsed['scheme']);
|
||||
|
||||
$hostPart = $host ?? $parsed['host'] ?? '';
|
||||
if (!$hostPart) {
|
||||
Logger::warning('Empty host GUID part', ['uri' => $uri, 'host' => $host, 'parsed' => $parsed, 'callstack' => System::callstack(10)]);
|
||||
}
|
||||
|
||||
// Glue it together to be able to make a hash from it
|
||||
$host_id = implode('/', $parsed);
|
||||
|
||||
// Use a mixture of several hashes to provide some GUID like experience
|
||||
return hash('crc32', $host) . '-'. hash('joaat', $host_id) . '-'. hash('fnv164', $host_id);
|
||||
return hash('crc32', $hostPart) . '-' . hash('joaat', $host_id) . '-' . hash('fnv164', $host_id);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -59,8 +59,7 @@ class Mail
|
|||
}
|
||||
|
||||
if (empty($msg['guid'])) {
|
||||
$host = parse_url($msg['from-url'], PHP_URL_HOST);
|
||||
$msg['guid'] = Item::guidFromUri($msg['uri'], $host);
|
||||
$msg['guid'] = Item::guidFromUri($msg['uri'], parse_url($msg['from-url'], PHP_URL_HOST));
|
||||
}
|
||||
|
||||
$msg['created'] = (!empty($msg['created']) ? DateTimeFormat::utc($msg['created']) : DateTimeFormat::utcNow());
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue