Refactor Model\Contact::addRelationship

- Remove unused parameter $item
- Replace q() call with DBA::insert
- Update check on $contact that can only be an array now
- Add moethod doc block
This commit is contained in:
Hypolite Petovan 2019-05-19 18:43:19 -04:00
parent 956ae6241d
commit 3114754f4b
4 changed files with 33 additions and 30 deletions

View file

@ -530,7 +530,7 @@ class Processor
DBA::update('contact', ['hub-verify' => $activity['id'], 'protocol' => Protocol::ACTIVITYPUB], ['id' => $cid]);
$contact = DBA::selectFirst('contact', [], ['id' => $cid, 'network' => Protocol::NATIVE_SUPPORT]);
} else {
$contact = false;
$contact = [];
}
$item = ['author-id' => Contact::getIdForURL($activity['actor']),
@ -541,7 +541,7 @@ class Processor
// Ensure that the contact has got the right network type
self::switchContact($item['author-id']);
Contact::addRelationship($owner, $contact, $item, '', false, $note);
$result = Contact::addRelationship($owner, $contact, $item, false, $note);
$cid = Contact::getIdForURL($activity['actor'], $uid);
if (empty($cid)) {
return;

View file

@ -2247,13 +2247,12 @@ class DFRN
// The functions below are partly used by ostatus.php as well - where we have this variable
$r = q("SELECT * FROM `contact` WHERE `id` = %d", intval($importer["id"]));
$contact = $r[0];
$nickname = $contact["nick"];
// Big question: Do we need these functions? They were part of the "consume_feed" function.
// This function once was responsible for DFRN and OStatus.
if (activity_match($item["verb"], ACTIVITY_FOLLOW)) {
Logger::log("New follower");
Contact::addRelationship($importer, $contact, $item, $nickname);
Contact::addRelationship($importer, $contact, $item);
return false;
}
if (activity_match($item["verb"], ACTIVITY_UNFOLLOW)) {
@ -2263,7 +2262,7 @@ class DFRN
}
if (activity_match($item["verb"], ACTIVITY_REQ_FRIEND)) {
Logger::log("New friend request");
Contact::addRelationship($importer, $contact, $item, $nickname, true);
Contact::addRelationship($importer, $contact, $item, true);
return false;
}
if (activity_match($item["verb"], ACTIVITY_UNFRIEND)) {

View file

@ -417,13 +417,6 @@ class OStatus
$author = self::fetchAuthor($xpath, $entry, $importer, $contact, $stored);
}
$value = XML::getFirstNodeValue($xpath, 'atom:author/poco:preferredUsername/text()', $entry);
if ($value != "") {
$nickname = $value;
} else {
$nickname = $author["author-name"];
}
$item = array_merge($header, $author);
$item["uri"] = XML::getFirstNodeValue($xpath, 'atom:id/text()', $entry);
@ -463,7 +456,7 @@ class OStatus
}
if ($item["verb"] == ACTIVITY_FOLLOW) {
Contact::addRelationship($importer, $contact, $item, $nickname);
Contact::addRelationship($importer, $contact, $item);
continue;
}