'nick' => $user['nickname'],
'pubkey' => $user['pubkey'],
'prvkey' => $user['prvkey'],
- 'photo' => DI::baseUrl() . '/photo/profile/' . $user['uid'] . '.jpg',
- 'thumb' => DI::baseUrl() . '/photo/avatar/' . $user['uid'] . '.jpg',
- 'micro' => DI::baseUrl() . '/photo/micro/' . $user['uid'] . '.jpg',
+ 'photo' => User::getAvatarUrlForId($user['uid']),
+ 'thumb' => User::getAvatarUrlForId($user['uid'], Proxy::SIZE_THUMB),
+ 'micro' => User::getAvatarUrlForId($user['uid'], Proxy::SIZE_MICRO),
'blocked' => 0,
'pending' => 0,
'url' => DI::baseUrl() . '/profile/' . $user['nickname'],
public static function updateSelfFromUserID($uid, $update_avatar = false)
{
$fields = ['id', 'name', 'nick', 'location', 'about', 'keywords', 'avatar', 'prvkey', 'pubkey',
- 'xmpp', 'contact-type', 'forum', 'prv', 'avatar-date', 'url', 'nurl', 'unsearchable',
+ 'xmpp', 'matrix', 'contact-type', 'forum', 'prv', 'avatar-date', 'url', 'nurl', 'unsearchable',
'photo', 'thumb', 'micro', 'addr', 'request', 'notify', 'poll', 'confirm', 'poco', 'network'];
$self = DBA::selectFirst('contact', $fields, ['uid' => $uid, 'self' => true]);
if (!DBA::isResult($self)) {
}
$fields = ['name', 'photo', 'thumb', 'about', 'address', 'locality', 'region',
- 'country-name', 'pub_keywords', 'xmpp', 'net-publish'];
+ 'country-name', 'pub_keywords', 'xmpp', 'matrix', 'net-publish'];
$profile = DBA::selectFirst('profile', $fields, ['uid' => $uid]);
if (!DBA::isResult($profile)) {
return false;
'avatar-date' => $self['avatar-date'], 'location' => Profile::formatLocation($profile),
'about' => $profile['about'], 'keywords' => $profile['pub_keywords'],
'contact-type' => $user['account-type'], 'prvkey' => $user['prvkey'],
- 'pubkey' => $user['pubkey'], 'xmpp' => $profile['xmpp'], 'network' => Protocol::DFRN];
+ 'pubkey' => $user['pubkey'], 'xmpp' => $profile['xmpp'], 'matrix' => $profile['matrix'], 'network' => Protocol::DFRN];
// it seems as if ported accounts can have wrong values, so we make sure that now everything is fine.
$fields['url'] = DI::baseUrl() . '/profile/' . $user['nickname'];
$fields['micro'] = self::getDefaultAvatar($fields, Proxy::SIZE_MICRO);
}
- $fields['avatar'] = DI::baseUrl() . '/photo/profile/' .$uid . '.' . $file_suffix;
+ $fields['avatar'] = User::getAvatarUrlForId($uid);
$fields['forum'] = $user['page-flags'] == User::PAGE_FLAGS_COMMUNITY;
$fields['prv'] = $user['page-flags'] == User::PAGE_FLAGS_PRVGROUP;
$fields['unsearchable'] = !$profile['net-publish'];
DBA::update('contact', $fields, ['uid' => 0, 'nurl' => $self['nurl']]);
// Update the profile
- $fields = ['photo' => DI::baseUrl() . '/photo/profile/' .$uid . '.' . $file_suffix,
- 'thumb' => DI::baseUrl() . '/photo/avatar/' . $uid .'.' . $file_suffix];
+ $fields = [
+ 'photo' => User::getAvatarUrlForId($uid),
+ 'thumb' => User::getAvatarUrlForId($uid, Proxy::SIZE_THUMB)
+ ];
+
DBA::update('profile', $fields, ['uid' => $uid]);
}
if ($dissolve) {
ActivityPub\Transmitter::sendContactReject($contact['url'], $contact['hub-verify'], $user['uid']);
}
+ } else {
+ $hook_data = [
+ 'contact' => $contact,
+ 'dissolve' => $dissolve,
+ ];
+ Hook::callAll('unfollow', $hook_data);
}
}
if ($thread_mode) {
$items = Post::toArray(Post::selectForUser(local_user(), ['uri-id', 'gravity', 'parent-uri-id', 'thr-parent-id', 'author-id'], $condition, $params));
- $o .= conversation($a, $items, 'contacts', $update, false, 'commented', local_user());
+ $o .= DI::conversation()->create($items, 'contacts', $update, false, 'commented', local_user());
} else {
$items = Post::toArray(Post::selectForUser(local_user(), Item::DISPLAY_FIELDLIST, $condition, $params));
- $o .= conversation($a, $items, 'contact-posts', $update);
+ $o .= DI::conversation()->create($items, 'contact-posts', $update);
}
if (!$update) {
*/
private static function updateContact(int $id, int $uid, string $old_url, string $new_url, array $fields)
{
- if (Strings::normaliseLink($new_url) != Strings::normaliseLink($old_url)) {
- Logger::notice('New URL differs from old URL', ['old' => $old_url, 'new' => $new_url]);
- return;
- }
-
if (!DBA::update('contact', $fields, ['id' => $id])) {
Logger::info('Couldn\'t update contact.', ['id' => $id, 'fields' => $fields]);
return;
*/
// These fields aren't updated by this routine:
- // 'xmpp', 'sensitive'
+ // 'sensitive'
$fields = ['uid', 'uri-id', 'avatar', 'header', 'name', 'nick', 'location', 'keywords', 'about', 'subscribe',
'manually-approve', 'unsearchable', 'url', 'addr', 'batch', 'notify', 'poll', 'request', 'confirm', 'poco',
- 'network', 'alias', 'baseurl', 'gsid', 'forum', 'prv', 'contact-type', 'pubkey', 'last-item'];
+ 'network', 'alias', 'baseurl', 'gsid', 'forum', 'prv', 'contact-type', 'pubkey', 'last-item', 'xmpp', 'matrix'];
$contact = DBA::selectFirst('contact', $fields, ['id' => $id]);
if (!DBA::isResult($contact)) {
return false;
$updated = DateTimeFormat::utcNow();
+ if (Strings::normaliseLink($contact['url']) != Strings::normaliseLink($ret['url'])) {
+ Logger::notice('New URL differs from old URL', ['id' => $id, 'uid' => $uid, 'old' => $contact['url'], 'new' => $ret['url']]);
+ self::updateContact($id, $uid, $contact['url'], $ret['url'], ['failed' => true, 'last-update' => $updated, 'failure_update' => $updated]);
+ return false;
+ }
+
// We must not try to update relay contacts via probe. They are no real contacts.
// We check after the probing to be able to correct falsely detected contact types.
if (($contact['contact-type'] == self::TYPE_RELAY) &&
$probed = false;
$ret = $arr['contact'];
} else {
- $probed = true;
+ $probed = true;
$ret = Probe::uri($url, $network, $uid);
}
return null;
}
- public static function removeFollower($importer, $contact)
+ public static function removeFollower(array $contact)
{
- if (($contact['rel'] == self::FRIEND) || ($contact['rel'] == self::SHARING)) {
+ if (in_array($contact['rel'] ?? [], [self::FRIEND, self::SHARING])) {
DBA::update('contact', ['rel' => self::SHARING], ['id' => $contact['id']]);
- } else {
+ } elseif (!empty($contact['id'])) {
self::remove($contact['id']);
+ } else {
+ DI::logger()->info('Couldn\'t remove follower because of invalid contact array', ['contact' => $contact, 'callstack' => System::callstack()]);
}
}