mirror of
https://github.com/friendica/friendica
synced 2025-04-28 12:24:23 +02:00
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:
parent
956ae6241d
commit
3114754f4b
4 changed files with 33 additions and 30 deletions
|
@ -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;
|
||||
|
|
|
@ -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)) {
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue