mirror of
https://github.com/friendica/friendica
synced 2024-11-17 22:23:41 +00:00
Use centralized function to update contact entries
This commit is contained in:
parent
a4b0ab90b1
commit
9c14eb0c6b
20 changed files with 90 additions and 72 deletions
|
@ -3848,7 +3848,7 @@ function api_friendships_destroy($type)
|
|||
if ($dissolve) {
|
||||
Contact::remove($contact['id']);
|
||||
} else {
|
||||
DBA::update('contact', ['rel' => Contact::FOLLOWER], ['id' => $contact['id']]);
|
||||
Contact::update(['rel' => Contact::FOLLOWER], ['id' => $contact['id']]);
|
||||
}
|
||||
|
||||
// "uid" and "self" are only needed for some internal stuff, so remove it from here
|
||||
|
@ -4504,14 +4504,14 @@ function api_account_update_profile($type)
|
|||
if (!empty($_POST['name'])) {
|
||||
DBA::update('profile', ['name' => $_POST['name']], ['uid' => $local_user]);
|
||||
DBA::update('user', ['username' => $_POST['name']], ['uid' => $local_user]);
|
||||
DBA::update('contact', ['name' => $_POST['name']], ['uid' => $local_user, 'self' => 1]);
|
||||
DBA::update('contact', ['name' => $_POST['name']], ['id' => $api_user['id']]);
|
||||
Contact::update(['name' => $_POST['name']], ['uid' => $local_user, 'self' => 1]);
|
||||
Contact::update(['name' => $_POST['name']], ['id' => $api_user['id']]);
|
||||
}
|
||||
|
||||
if (isset($_POST['description'])) {
|
||||
DBA::update('profile', ['about' => $_POST['description']], ['uid' => $local_user]);
|
||||
DBA::update('contact', ['about' => $_POST['description']], ['uid' => $local_user, 'self' => 1]);
|
||||
DBA::update('contact', ['about' => $_POST['description']], ['id' => $api_user['id']]);
|
||||
Contact::update(['about' => $_POST['description']], ['uid' => $local_user, 'self' => 1]);
|
||||
Contact::update(['about' => $_POST['description']], ['id' => $api_user['id']]);
|
||||
}
|
||||
|
||||
Profile::publishUpdate($local_user);
|
||||
|
|
|
@ -96,7 +96,7 @@ function pubsub_init(App $a)
|
|||
}
|
||||
|
||||
if (!empty($hub_mode)) {
|
||||
DBA::update('contact', ['subhub' => $subscribe], ['id' => $contact['id']]);
|
||||
Contact::update(['subhub' => $subscribe], ['id' => $contact['id']]);
|
||||
Logger::log($hub_mode . ' success for contact ' . $contact_id . '.');
|
||||
}
|
||||
hub_return(true, $hub_challenge);
|
||||
|
|
|
@ -149,7 +149,7 @@ function unfollow_process(string $url)
|
|||
Contact::remove($contact['id']);
|
||||
$return_path = $base_return_path;
|
||||
} else {
|
||||
DBA::update('contact', ['rel' => Contact::FOLLOWER], ['id' => $contact['id']]);
|
||||
Contact::update(['rel' => Contact::FOLLOWER], ['id' => $contact['id']]);
|
||||
$return_path = $base_return_path . '/' . $contact['id'];
|
||||
}
|
||||
|
||||
|
|
|
@ -24,6 +24,7 @@ namespace Friendica\Console;
|
|||
use Friendica\App;
|
||||
use Friendica\Database\Database;
|
||||
use Friendica\DI;
|
||||
use Friendica\Model\Contact;
|
||||
use Friendica\Util\Strings;
|
||||
use RuntimeException;
|
||||
|
||||
|
@ -104,7 +105,7 @@ HELP;
|
|||
if (!$this->dba->exists('contact', ['nurl' => $nurl, 'archive' => false])) {
|
||||
throw new RuntimeException(DI::l10n()->t('Could not find any unarchived contact entry for this URL (%s)', $nurl));
|
||||
}
|
||||
if ($this->dba->update('contact', ['archive' => true], ['nurl' => $nurl])) {
|
||||
if (Contact::update(['archive' => true], ['nurl' => $nurl])) {
|
||||
$this->out($this->l10n->t('The contact entries have been archived'));
|
||||
} else {
|
||||
throw new RuntimeException('The contact archival failed.');
|
||||
|
|
|
@ -98,7 +98,7 @@ HELP;
|
|||
|
||||
$contact_id = Contact::getIdForURL($this->getArgument(0));
|
||||
if ($contact_id) {
|
||||
$this->dba->update('contact', ['hidden' => true], ['id' => $contact_id]);
|
||||
Contact::update(['hidden' => true], ['id' => $contact_id]);
|
||||
$this->out('The account has been successfully silenced from the global community page.');
|
||||
} else {
|
||||
throw new RuntimeException('Could not find any public contact entry for this URL (' . $this->getArgument(0) . ')');
|
||||
|
|
|
@ -208,6 +208,23 @@ class Contact
|
|||
return $contact['id'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates rows in the contact table
|
||||
*
|
||||
* @param array $fields contains the fields that are updated
|
||||
* @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)
|
||||
*
|
||||
* @return boolean was the update successfull?
|
||||
* @throws \Exception
|
||||
*/
|
||||
public static function update(array $fields, array $condition, $old_fields = [])
|
||||
{
|
||||
$ret = DBA::update('contact', $fields, $condition, $old_fields);
|
||||
// @todo Apply changes to the "user-contact" table on dedicated fields
|
||||
return $ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param integer $id Contact ID
|
||||
* @param array $fields Array of selected fields, empty for all
|
||||
|
@ -765,12 +782,12 @@ class Contact
|
|||
$fields['name-date'] = DateTimeFormat::utcNow();
|
||||
}
|
||||
$fields['updated'] = DateTimeFormat::utcNow();
|
||||
DBA::update('contact', $fields, ['id' => $self['id']]);
|
||||
self::update($fields, ['id' => $self['id']]);
|
||||
|
||||
// Update the public contact as well
|
||||
$fields['prvkey'] = null;
|
||||
$fields['self'] = false;
|
||||
DBA::update('contact', $fields, ['uid' => 0, 'nurl' => $self['nurl']]);
|
||||
self::update($fields, ['uid' => 0, 'nurl' => $self['nurl']]);
|
||||
|
||||
// Update the profile
|
||||
$fields = ['photo' => DI::baseUrl() . '/photo/profile/' .$uid . '.' . $file_suffix,
|
||||
|
@ -797,7 +814,7 @@ class Contact
|
|||
}
|
||||
|
||||
// Archive the contact
|
||||
DBA::update('contact', ['archive' => true, 'network' => Protocol::PHANTOM, 'deleted' => true], ['id' => $id]);
|
||||
self::update(['archive' => true, 'network' => Protocol::PHANTOM, 'deleted' => true], ['id' => $id]);
|
||||
|
||||
// Delete it in the background
|
||||
Worker::add(PRIORITY_MEDIUM, 'RemoveContact', $id);
|
||||
|
@ -883,8 +900,8 @@ class Contact
|
|||
}
|
||||
|
||||
if ($contact['term-date'] <= DBA::NULL_DATETIME) {
|
||||
DBA::update('contact', ['term-date' => DateTimeFormat::utcNow()], ['id' => $contact['id']]);
|
||||
DBA::update('contact', ['term-date' => DateTimeFormat::utcNow()], ['`nurl` = ? AND `term-date` <= ? AND NOT `self`', Strings::normaliseLink($contact['url']), DBA::NULL_DATETIME]);
|
||||
self::update(['term-date' => DateTimeFormat::utcNow()], ['id' => $contact['id']]);
|
||||
self::update(['term-date' => DateTimeFormat::utcNow()], ['`nurl` = ? AND `term-date` <= ? AND NOT `self`', Strings::normaliseLink($contact['url']), DBA::NULL_DATETIME]);
|
||||
} else {
|
||||
/* @todo
|
||||
* We really should send a notification to the owner after 2-3 weeks
|
||||
|
@ -901,8 +918,8 @@ class Contact
|
|||
* delete, though if the owner tries to unarchive them we'll start
|
||||
* the whole process over again.
|
||||
*/
|
||||
DBA::update('contact', ['archive' => true], ['id' => $contact['id']]);
|
||||
DBA::update('contact', ['archive' => true], ['nurl' => Strings::normaliseLink($contact['url']), 'self' => false]);
|
||||
self::update(['archive' => true], ['id' => $contact['id']]);
|
||||
self::update(['archive' => true], ['nurl' => Strings::normaliseLink($contact['url']), 'self' => false]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -923,7 +940,7 @@ class Contact
|
|||
$fields = ['failed' => false, 'term-date' => DBA::NULL_DATETIME, 'archive' => false];
|
||||
$condition = ['uid' => 0, 'network' => Protocol::FEDERATED, 'batch' => $contact['batch'], 'contact-type' => self::TYPE_RELAY];
|
||||
if (!DBA::exists('contact', array_merge($condition, $fields))) {
|
||||
DBA::update('contact', $fields, $condition);
|
||||
self::update($fields, $condition);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -947,8 +964,8 @@ class Contact
|
|||
|
||||
// It's a miracle. Our dead contact has inexplicably come back to life.
|
||||
$fields = ['failed' => false, 'term-date' => DBA::NULL_DATETIME, 'archive' => false];
|
||||
DBA::update('contact', $fields, ['id' => $contact['id']]);
|
||||
DBA::update('contact', $fields, ['nurl' => Strings::normaliseLink($contact['url']), 'self' => false]);
|
||||
self::update($fields, ['id' => $contact['id']]);
|
||||
self::update($fields, ['nurl' => Strings::normaliseLink($contact['url']), 'self' => false]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1496,7 +1513,7 @@ class Contact
|
|||
*/
|
||||
public static function block($cid, $reason = null)
|
||||
{
|
||||
$return = DBA::update('contact', ['blocked' => true, 'block_reason' => $reason], ['id' => $cid]);
|
||||
$return = self::update(['blocked' => true, 'block_reason' => $reason], ['id' => $cid]);
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
@ -1510,7 +1527,7 @@ class Contact
|
|||
*/
|
||||
public static function unblock($cid)
|
||||
{
|
||||
$return = DBA::update('contact', ['blocked' => false, 'block_reason' => null], ['id' => $cid]);
|
||||
$return = self::update(['blocked' => false, 'block_reason' => null], ['id' => $cid]);
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
@ -1809,7 +1826,7 @@ class Contact
|
|||
// Only update the cached photo links of public contacts when they already are cached
|
||||
if (($uid == 0) && !$force && empty($contact['thumb']) && empty($contact['micro']) && !$create_cache) {
|
||||
if ($contact['avatar'] != $avatar) {
|
||||
DBA::update('contact', ['avatar' => $avatar], ['id' => $cid]);
|
||||
self::update(['avatar' => $avatar], ['id' => $cid]);
|
||||
Logger::info('Only update the avatar', ['id' => $cid, 'avatar' => $avatar, 'contact' => $contact]);
|
||||
}
|
||||
return;
|
||||
|
@ -1906,7 +1923,7 @@ class Contact
|
|||
$cids[] = $cid;
|
||||
$uids[] = $uid;
|
||||
Logger::info('Updating cached contact avatars', ['cid' => $cids, 'uid' => $uids, 'fields' => $fields]);
|
||||
DBA::update('contact', $fields, ['id' => $cids]);
|
||||
self::update($fields, ['id' => $cids]);
|
||||
}
|
||||
|
||||
public static function deleteContactByUrl(string $url)
|
||||
|
@ -1933,7 +1950,7 @@ class Contact
|
|||
*/
|
||||
private static function updateContact(int $id, int $uid, string $old_url, string $new_url, array $fields)
|
||||
{
|
||||
if (!DBA::update('contact', $fields, ['id' => $id])) {
|
||||
if (!self::update($fields, ['id' => $id])) {
|
||||
Logger::info('Couldn\'t update contact.', ['id' => $id, 'fields' => $fields]);
|
||||
return;
|
||||
}
|
||||
|
@ -1966,7 +1983,7 @@ class Contact
|
|||
$condition = ['self' => false, 'nurl' => Strings::normaliseLink($old_url)];
|
||||
|
||||
$condition['network'] = [Protocol::DFRN, Protocol::DIASPORA, Protocol::ACTIVITYPUB];
|
||||
DBA::update('contact', $fields, $condition);
|
||||
self::update($fields, $condition);
|
||||
|
||||
// We mustn't set the update fields for OStatus contacts since they are updated in OnePoll
|
||||
$condition['network'] = Protocol::OSTATUS;
|
||||
|
@ -1982,7 +1999,7 @@ class Contact
|
|||
return;
|
||||
}
|
||||
|
||||
DBA::update('contact', $fields, $condition);
|
||||
self::update($fields, $condition);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -2256,7 +2273,7 @@ class Contact
|
|||
}
|
||||
}
|
||||
if (!empty($fields)) {
|
||||
DBA::update('contact', $fields, ['id' => $id, 'self' => false]);
|
||||
self::update($fields, ['id' => $id, 'self' => false]);
|
||||
Logger::info('Updating local contact', ['id' => $id]);
|
||||
}
|
||||
}
|
||||
|
@ -2434,7 +2451,7 @@ class Contact
|
|||
$new_relation = (($contact['rel'] == self::FOLLOWER) ? self::FRIEND : self::SHARING);
|
||||
|
||||
$fields = ['rel' => $new_relation, 'subhub' => $subhub, 'readonly' => false];
|
||||
DBA::update('contact', $fields, ['id' => $contact['id']]);
|
||||
self::update($fields, ['id' => $contact['id']]);
|
||||
} else {
|
||||
$new_relation = (in_array($protocol, [Protocol::MAIL]) ? self::FRIEND : self::SHARING);
|
||||
|
||||
|
@ -2567,7 +2584,7 @@ class Contact
|
|||
$fields = ['url' => $contact['url'], 'request' => $contact['request'],
|
||||
'notify' => $contact['notify'], 'poll' => $contact['poll'],
|
||||
'confirm' => $contact['confirm'], 'poco' => $contact['poco']];
|
||||
DBA::update('contact', $fields, ['id' => $contact['id']]);
|
||||
self::update($fields, ['id' => $contact['id']]);
|
||||
}
|
||||
|
||||
return $contact;
|
||||
|
@ -2670,7 +2687,7 @@ class Contact
|
|||
|
||||
if (($contact['rel'] == self::SHARING)
|
||||
|| ($sharing && $contact['rel'] == self::FOLLOWER)) {
|
||||
DBA::update('contact', ['rel' => self::FRIEND, 'writable' => true, 'pending' => false],
|
||||
self::update(['rel' => self::FRIEND, 'writable' => true, 'pending' => false],
|
||||
['id' => $contact['id'], 'uid' => $importer['uid']]);
|
||||
}
|
||||
|
||||
|
@ -2750,7 +2767,7 @@ class Contact
|
|||
$fields['rel'] = self::FRIEND;
|
||||
}
|
||||
|
||||
DBA::update('contact', $fields, $condition);
|
||||
self::update($fields, $condition);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -2762,7 +2779,7 @@ class Contact
|
|||
public static function removeFollower($importer, $contact)
|
||||
{
|
||||
if (($contact['rel'] == self::FRIEND) || ($contact['rel'] == self::SHARING)) {
|
||||
DBA::update('contact', ['rel' => self::SHARING], ['id' => $contact['id']]);
|
||||
self::update(['rel' => self::SHARING], ['id' => $contact['id']]);
|
||||
} else {
|
||||
self::remove($contact['id']);
|
||||
}
|
||||
|
@ -2771,7 +2788,7 @@ class Contact
|
|||
public static function removeSharer($importer, $contact)
|
||||
{
|
||||
if (($contact['rel'] == self::FRIEND) || ($contact['rel'] == self::FOLLOWER)) {
|
||||
DBA::update('contact', ['rel' => self::FOLLOWER], ['id' => $contact['id']]);
|
||||
self::update(['rel' => self::FOLLOWER], ['id' => $contact['id']]);
|
||||
} else {
|
||||
self::remove($contact['id']);
|
||||
}
|
||||
|
|
|
@ -114,7 +114,7 @@ class Relation
|
|||
}
|
||||
|
||||
if (empty($followers) && empty($followings)) {
|
||||
DBA::update('contact', ['last-discovery' => DateTimeFormat::utcNow()], ['id' => $contact['id']]);
|
||||
Contact::update(['last-discovery' => DateTimeFormat::utcNow()], ['id' => $contact['id']]);
|
||||
Logger::info('The contact does not offer discoverable data', ['id' => $contact['id'], 'url' => $url, 'network' => $contact['network']]);
|
||||
return;
|
||||
}
|
||||
|
@ -162,7 +162,7 @@ class Relation
|
|||
DBA::delete('contact-relation', ['cid' => $target, 'follows' => false, 'last-interaction' => DBA::NULL_DATETIME]);
|
||||
}
|
||||
|
||||
DBA::update('contact', ['last-discovery' => DateTimeFormat::utcNow()], ['id' => $target]);
|
||||
Contact::update(['last-discovery' => DateTimeFormat::utcNow()], ['id' => $target]);
|
||||
Logger::info('Contacts discovery finished', ['id' => $target, 'url' => $url, 'follower' => $follower_counter, 'following' => $following_counter]);
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -110,7 +110,7 @@ class Introduction extends BaseModel
|
|||
'hidden' => $hidden ?? $contact['hidden'],
|
||||
'rel' => $newRelation,
|
||||
];
|
||||
$this->dba->update('contact', $fields, ['id' => $contact['id']]);
|
||||
Contact::update($fields, ['id' => $contact['id']]);
|
||||
|
||||
array_merge($contact, $fields);
|
||||
|
||||
|
@ -159,7 +159,7 @@ class Introduction extends BaseModel
|
|||
if ($this->dba->exists('contact', $condition)) {
|
||||
Contact::remove($this->{'contact-id'});
|
||||
} else {
|
||||
$this->dba->update('contact', ['pending' => false], ['id' => $this->{'contact-id'}]);
|
||||
Contact::update(['pending' => false], ['id' => $this->{'contact-id'}]);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1753,15 +1753,15 @@ class Item
|
|||
} else {
|
||||
$condition = ['id' => $arr['contact-id'], 'self' => false];
|
||||
}
|
||||
DBA::update('contact', ['failed' => false, 'success_update' => $arr['received'], 'last-item' => $arr['received']], $condition);
|
||||
Contact::update(['failed' => false, 'success_update' => $arr['received'], 'last-item' => $arr['received']], $condition);
|
||||
}
|
||||
// Now do the same for the system wide contacts with uid=0
|
||||
if ($arr['private'] != self::PRIVATE) {
|
||||
DBA::update('contact', ['failed' => false, 'success_update' => $arr['received'], 'last-item' => $arr['received']],
|
||||
Contact::update(['failed' => false, 'success_update' => $arr['received'], 'last-item' => $arr['received']],
|
||||
['id' => $arr['owner-id']]);
|
||||
|
||||
if ($arr['owner-id'] != $arr['author-id']) {
|
||||
DBA::update('contact', ['failed' => false, 'success_update' => $arr['received'], 'last-item' => $arr['received']],
|
||||
Contact::update(['failed' => false, 'success_update' => $arr['received'], 'last-item' => $arr['received']],
|
||||
['id' => $arr['author-id']]);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -50,7 +50,7 @@ class Note extends BaseApi
|
|||
DI::mstdnError()->RecordNotFound();
|
||||
}
|
||||
|
||||
DBA::update('contact', ['info' => $request['comment']], ['id' => $cdata['user']]);
|
||||
Contact::update(['info' => $request['comment']], ['id' => $cdata['user']]);
|
||||
|
||||
System::jsonExit(DI::mstdnRelationship()->createFromContactId($parameters['id'], $uid)->toArray());
|
||||
}
|
||||
|
|
|
@ -139,7 +139,7 @@ class Contact extends BaseModule
|
|||
|
||||
$info = Strings::escapeHtml(trim($_POST['info'] ?? ''));
|
||||
|
||||
$r = DBA::update('contact', [
|
||||
$r = Model\Contact::update([
|
||||
'priority' => $priority,
|
||||
'info' => $info,
|
||||
'hidden' => $hidden,
|
||||
|
@ -175,7 +175,7 @@ class Contact extends BaseModule
|
|||
$result = Model\Contact::createFromProbeForUser($contact['uid'], $contact['url'], $contact['network']);
|
||||
|
||||
if ($result['success']) {
|
||||
DBA::update('contact', ['subhub' => 1], ['id' => $contact_id]);
|
||||
Model\Contact::update(['subhub' => 1], ['id' => $contact_id]);
|
||||
}
|
||||
|
||||
// pull feed and consume it, which should subscribe to the hub.
|
||||
|
|
|
@ -912,7 +912,7 @@ class Processor
|
|||
$cid = Contact::getIdForURL($activity['actor'], $uid);
|
||||
if (!empty($cid)) {
|
||||
self::switchContact($cid);
|
||||
DBA::update('contact', ['hub-verify' => $activity['id'], 'protocol' => Protocol::ACTIVITYPUB], ['id' => $cid]);
|
||||
Contact::update(['hub-verify' => $activity['id'], 'protocol' => Protocol::ACTIVITYPUB], ['id' => $cid]);
|
||||
}
|
||||
|
||||
$item = ['author-id' => Contact::getIdForURL($activity['actor']),
|
||||
|
@ -932,7 +932,7 @@ class Processor
|
|||
}
|
||||
|
||||
if (empty($contact)) {
|
||||
DBA::update('contact', ['hub-verify' => $activity['id'], 'protocol' => Protocol::ACTIVITYPUB], ['id' => $cid]);
|
||||
Contact::update(['hub-verify' => $activity['id'], 'protocol' => Protocol::ACTIVITYPUB], ['id' => $cid]);
|
||||
}
|
||||
|
||||
Logger::notice('Follow user ' . $uid . ' from contact ' . $cid . ' with id ' . $activity['id']);
|
||||
|
@ -1011,7 +1011,7 @@ class Processor
|
|||
}
|
||||
|
||||
$condition = ['id' => $cid];
|
||||
DBA::update('contact', $fields, $condition);
|
||||
Contact::update($fields, $condition);
|
||||
Logger::info('Accept contact request', ['contact' => $cid, 'user' => $uid]);
|
||||
}
|
||||
|
||||
|
|
|
@ -115,7 +115,7 @@ class Transmitter
|
|||
$activity_id = ActivityPub\Transmitter::activityIDFromContact($contact['id']);
|
||||
$success = ActivityPub\Transmitter::sendActivity('Follow', $url, 0, $activity_id);
|
||||
if ($success) {
|
||||
DBA::update('contact', ['rel' => Contact::FRIEND], ['id' => $contact['id']]);
|
||||
Contact::update(['rel' => Contact::FRIEND], ['id' => $contact['id']]);
|
||||
}
|
||||
|
||||
return $success;
|
||||
|
@ -137,7 +137,7 @@ class Transmitter
|
|||
|
||||
$success = self::sendContactUndo($url, $contact['id'], 0);
|
||||
if ($success || $force) {
|
||||
DBA::update('contact', ['rel' => Contact::NOTHING], ['id' => $contact['id']]);
|
||||
Contact::update(['rel' => Contact::NOTHING], ['id' => $contact['id']]);
|
||||
}
|
||||
|
||||
return $success;
|
||||
|
|
|
@ -1215,12 +1215,12 @@ class DFRN
|
|||
'xmpp' => $contact['xmpp'], 'name-date' => DateTimeFormat::utc($contact['name-date']),
|
||||
'unsearchable' => $contact['hidden'], 'uri-date' => DateTimeFormat::utc($contact['uri-date'])];
|
||||
|
||||
DBA::update('contact', $fields, ['id' => $contact['id'], 'network' => $contact['network']], $contact_old);
|
||||
Contact::update($fields, ['id' => $contact['id'], 'network' => $contact['network']], $contact_old);
|
||||
|
||||
// Update the public contact. Don't set the "hidden" value, this is used differently for public contacts
|
||||
unset($fields['hidden']);
|
||||
$condition = ['uid' => 0, 'nurl' => Strings::normaliseLink($contact_old['url'])];
|
||||
DBA::update('contact', $fields, $condition, true);
|
||||
Contact::update($fields, $condition, true);
|
||||
|
||||
Contact::updateAvatar($contact['id'], $author['avatar']);
|
||||
|
||||
|
@ -1400,7 +1400,7 @@ class DFRN
|
|||
'poll' => $relocate["poll"], 'site-pubkey' => $relocate["sitepubkey"]];
|
||||
$condition = ["(`id` = ?) OR (`nurl` = ?)", $importer["id"], Strings::normaliseLink($old["url"])];
|
||||
|
||||
DBA::update('contact', $fields, $condition);
|
||||
Contact::update($fields, $condition);
|
||||
|
||||
Contact::updateAvatar($importer["id"], $relocate["avatar"], true);
|
||||
|
||||
|
@ -2200,36 +2200,36 @@ class DFRN
|
|||
$accounttype = intval(XML::getFirstNodeValue($xpath, "/atom:feed/dfrn:account_type/text()"));
|
||||
|
||||
if ($accounttype != $importer["contact-type"]) {
|
||||
DBA::update('contact', ['contact-type' => $accounttype], ['id' => $importer['id']]);
|
||||
Contact::update(['contact-type' => $accounttype], ['id' => $importer['id']]);
|
||||
|
||||
// Updating the public contact as well
|
||||
DBA::update('contact', ['contact-type' => $accounttype], ['uid' => 0, 'nurl' => $importer['nurl']]);
|
||||
Contact::update(['contact-type' => $accounttype], ['uid' => 0, 'nurl' => $importer['nurl']]);
|
||||
}
|
||||
// A forum contact can either have set "forum" or "prv" - but not both
|
||||
if ($accounttype == User::ACCOUNT_TYPE_COMMUNITY) {
|
||||
// It's a forum, so either set the public or private forum flag
|
||||
$condition = ['(`forum` != ? OR `prv` != ?) AND `id` = ?', $forum, !$forum, $importer['id']];
|
||||
DBA::update('contact', ['forum' => $forum, 'prv' => !$forum], $condition);
|
||||
Contact::update(['forum' => $forum, 'prv' => !$forum], $condition);
|
||||
|
||||
// Updating the public contact as well
|
||||
$condition = ['(`forum` != ? OR `prv` != ?) AND `uid` = 0 AND `nurl` = ?', $forum, !$forum, $importer['nurl']];
|
||||
DBA::update('contact', ['forum' => $forum, 'prv' => !$forum], $condition);
|
||||
Contact::update(['forum' => $forum, 'prv' => !$forum], $condition);
|
||||
} else {
|
||||
// It's not a forum, so remove the flags
|
||||
$condition = ['(`forum` OR `prv`) AND `id` = ?', $importer['id']];
|
||||
DBA::update('contact', ['forum' => false, 'prv' => false], $condition);
|
||||
Contact::update(['forum' => false, 'prv' => false], $condition);
|
||||
|
||||
// Updating the public contact as well
|
||||
$condition = ['(`forum` OR `prv`) AND `uid` = 0 AND `nurl` = ?', $importer['nurl']];
|
||||
DBA::update('contact', ['forum' => false, 'prv' => false], $condition);
|
||||
Contact::update(['forum' => false, 'prv' => false], $condition);
|
||||
}
|
||||
} elseif ($forum != $importer["forum"]) { // Deprecated since 3.5.1
|
||||
$condition = ['`forum` != ? AND `id` = ?', $forum, $importer["id"]];
|
||||
DBA::update('contact', ['forum' => $forum], $condition);
|
||||
Contact::update(['forum' => $forum], $condition);
|
||||
|
||||
// Updating the public contact as well
|
||||
$condition = ['`forum` != ? AND `uid` = 0 AND `nurl` = ?', $forum, $importer['nurl']];
|
||||
DBA::update('contact', ['forum' => $forum], $condition);
|
||||
Contact::update(['forum' => $forum], $condition);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -1367,7 +1367,7 @@ class Diaspora
|
|||
'notify' => $data['notify'], 'poll' => $data['poll'],
|
||||
'network' => $data['network']];
|
||||
|
||||
DBA::update('contact', $fields, ['addr' => $old_handle]);
|
||||
Contact::update($fields, ['addr' => $old_handle]);
|
||||
|
||||
Logger::log('Contacts are updated.');
|
||||
|
||||
|
@ -2129,7 +2129,7 @@ class Diaspora
|
|||
$fields['bd'] = $birthday;
|
||||
}
|
||||
|
||||
DBA::update('contact', $fields, ['id' => $contact['id']]);
|
||||
Contact::update($fields, ['id' => $contact['id']]);
|
||||
|
||||
Logger::log("Profile of contact ".$contact["id"]." stored for user ".$importer["uid"], Logger::DEBUG);
|
||||
|
||||
|
|
|
@ -732,7 +732,7 @@ class Feed
|
|||
|
||||
if ($contact['rating'] != $priority) {
|
||||
Logger::notice('Adjusting priority', ['old' => $contact['rating'], 'new' => $priority, 'id' => $contact['id'], 'uid' => $contact['uid'], 'url' => $contact['url']]);
|
||||
DBA::update('contact', ['rating' => $priority], ['id' => $contact['id']]);
|
||||
Contact::update(['rating' => $priority], ['id' => $contact['id']]);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -209,7 +209,7 @@ class OStatus
|
|||
|
||||
$contact['name-date'] = DateTimeFormat::utcNow();
|
||||
|
||||
DBA::update('contact', $contact, ['id' => $contact["id"]], $current);
|
||||
Contact::update($contact, ['id' => $contact["id"]], $current);
|
||||
|
||||
if (!empty($author["author-avatar"]) && ($author["author-avatar"] != $current['avatar'])) {
|
||||
Logger::log("Update profile picture for contact ".$contact["id"], Logger::DEBUG);
|
||||
|
@ -230,7 +230,7 @@ class OStatus
|
|||
'about' => $contact["about"], 'location' => $contact["location"],
|
||||
'success_update' => DateTimeFormat::utcNow(), 'last-update' => DateTimeFormat::utcNow()];
|
||||
|
||||
DBA::update('contact', $fields, ['id' => $cid], $old_contact);
|
||||
Contact::update($fields, ['id' => $cid], $old_contact);
|
||||
|
||||
// Update the avatar
|
||||
if (!empty($author["author-avatar"])) {
|
||||
|
|
|
@ -166,7 +166,7 @@ class Relay
|
|||
$fields['updated'] = DateTimeFormat::utcNow();
|
||||
|
||||
Logger::info('Update relay contact', ['server' => $gserver['url'], 'id' => $old['id'], 'fields' => $fields]);
|
||||
DBA::update('contact', $fields, ['id' => $old['id']], $old);
|
||||
Contact::update($fields, ['id' => $old['id']], $old);
|
||||
} else {
|
||||
$default = ['created' => DateTimeFormat::utcNow(),
|
||||
'name' => 'relay', 'nick' => 'relay', 'url' => $gserver['url'],
|
||||
|
|
|
@ -82,7 +82,7 @@ class OnePoll
|
|||
Logger::warning('No self contact for user', ['uid' => $importer_uid]);
|
||||
|
||||
// set the last-update so we don't keep polling
|
||||
DBA::update('contact', ['last-update' => $updated], ['id' => $contact['id']]);
|
||||
Contact::update(['last-update' => $updated], ['id' => $contact['id']]);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -122,16 +122,16 @@ class OnePoll
|
|||
{
|
||||
if (in_array($contact['network'], [Protocol::FEED, Protocol::MAIL, Protocol::OSTATUS])) {
|
||||
// Update the user's contact
|
||||
DBA::update('contact', $fields, ['id' => $contact['id']]);
|
||||
Contact::update($fields, ['id' => $contact['id']]);
|
||||
|
||||
// Update the public contact
|
||||
DBA::update('contact', $fields, ['uid' => 0, 'nurl' => $contact['nurl']]);
|
||||
Contact::update($fields, ['uid' => 0, 'nurl' => $contact['nurl']]);
|
||||
|
||||
// Update the rest of the contacts that aren't polled
|
||||
DBA::update('contact', $fields, ['rel' => Contact::FOLLOWER, 'nurl' => $contact['nurl']]);
|
||||
Contact::update($fields, ['rel' => Contact::FOLLOWER, 'nurl' => $contact['nurl']]);
|
||||
} else {
|
||||
// Update all contacts
|
||||
DBA::update('contact', $fields, ['nurl' => $contact['nurl']]);
|
||||
Contact::update($fields, ['nurl' => $contact['nurl']]);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -456,7 +456,7 @@ class OnePoll
|
|||
Logger::info('Hub subscription start', ['mode' => $hubmode, 'name' => $contact['name'], 'hub' => $url, 'endpoint' => $push_url, 'verifier' => $verify_token]);
|
||||
|
||||
if (!strlen($contact['hub-verify']) || ($contact['hub-verify'] != $verify_token)) {
|
||||
DBA::update('contact', ['hub-verify' => $verify_token], ['id' => $contact['id']]);
|
||||
Contact::update(['hub-verify' => $verify_token], ['id' => $contact['id']]);
|
||||
}
|
||||
|
||||
$postResult = DI::httpClient()->post($url, $params);
|
||||
|
|
|
@ -44,7 +44,7 @@ class RemoveUnusedAvatars
|
|||
$count = 0;
|
||||
$contacts = DBA::select('contact', ['id'], $condition);
|
||||
while ($contact = DBA::fetch($contacts)) {
|
||||
DBA::update('contact', ['photo' => '', 'thumb' => '', 'micro' => ''], ['id' => $contact['id']]);
|
||||
Contact::update(['photo' => '', 'thumb' => '', 'micro' => ''], ['id' => $contact['id']]);
|
||||
Photo::delete(['contact-id' => $contact['id'], 'album' => Photo::CONTACT_PHOTOS]);
|
||||
if ((++$count % 1000) == 0) {
|
||||
if (!Worker::isInMaintenanceWindow()) {
|
||||
|
|
Loading…
Reference in a new issue