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
|
@ -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'],
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue