Fix defaults in Contact model

This commit is contained in:
Art4 2024-11-04 20:02:44 +00:00
parent 28f2b7fc81
commit ad6be21b56

View file

@ -2706,8 +2706,6 @@ class Contact
* *
* @param int $id * @param int $id
* @param array $contact * @param array $contact
*
* @return boolean
*/ */
private static function hasLocalData(int $id, array $contact): bool private static function hasLocalData(int $id, array $contact): bool
{ {
@ -2767,6 +2765,8 @@ class Contact
'network', 'alias', 'baseurl', 'gsid', 'forum', 'prv', 'contact-type', 'pubkey', 'last-item', 'xmpp', 'matrix', 'network', 'alias', 'baseurl', 'gsid', 'forum', 'prv', 'contact-type', 'pubkey', 'last-item', 'xmpp', 'matrix',
'created', 'last-update' 'created', 'last-update'
]; ];
/** @var array<string,mixed> */
$contact = DBA::selectFirst('contact', $fields, ['id' => $id]); $contact = DBA::selectFirst('contact', $fields, ['id' => $id]);
if (!DBA::isResult($contact)) { if (!DBA::isResult($contact)) {
return false; return false;
@ -2792,22 +2792,22 @@ class Contact
$has_local_data = self::hasLocalData($id, $contact); $has_local_data = self::hasLocalData($id, $contact);
$uid = $contact['uid']; $uid = $contact['uid'] ?? null;
unset($contact['uid']); unset($contact['uid']);
$uriid = $contact['uri-id']; $uriid = $contact['uri-id'] ?? null;
unset($contact['uri-id']); unset($contact['uri-id']);
$pubkey = $contact['pubkey']; $pubkey = $contact['pubkey'] ?? null;
unset($contact['pubkey']); unset($contact['pubkey']);
$created = $contact['created']; $created = $contact['created'] ?? '';
unset($contact['created']); unset($contact['created']);
$last_update = $contact['last-update']; $last_update = $contact['last-update'] ?? '';
unset($contact['last-update']); unset($contact['last-update']);
$contact['photo'] = $contact['avatar']; $contact['photo'] = $contact['avatar'] ?? null;
unset($contact['avatar']); unset($contact['avatar']);
$updated = DateTimeFormat::utcNow(); $updated = DateTimeFormat::utcNow();