]> git.mxchange.org Git - friendica.git/commitdiff
The whole contact handling does work now, yeah ...
authorMichael <heluecht@pirati.ca>
Sat, 15 Sep 2018 20:31:05 +0000 (20:31 +0000)
committerMichael <heluecht@pirati.ca>
Sat, 15 Sep 2018 20:31:05 +0000 (20:31 +0000)
mod/dfrn_confirm.php
src/Model/Contact.php
src/Protocol/ActivityPub.php

index 2a872dd4147df8dfa7af189bb3005cf3a06ba571..4abaf978fb7f99d0e319690258f6f07f9952f973 100644 (file)
@@ -337,7 +337,7 @@ function dfrn_confirm_post(App $a, $handsfree = null)
                        );
                } else {
                        if ($network == Protocol::ACTIVITYPUB) {
-                               ActivityPub::transmitContactActivity('Accept', $contact['url'], $contact['hub-verify'], $uid);
+                               ActivityPub::transmitContactAccept($contact['url'], $contact['hub-verify'], $uid);
                                $pending = true;
                        } else {
                                $pending = false;
index 2bcb86327bdd0c6ba1dc652286c9dd5d28352c2f..1e61c0d10d2ed5e7a211348117e17bc57e4bdebd 100644 (file)
@@ -557,7 +557,7 @@ class Contact extends BaseObject
                } elseif ($contact['network'] == Protocol::DIASPORA) {
                        Diaspora::sendUnshare($user, $contact);
                } elseif ($contact['network'] == Protocol::ACTIVITYPUB) {
-                       ActivityPub::transmitContactActivity('Undo', $contact['url'], '', $user['uid']);
+                       ActivityPub::transmitContactUndo($contact['url'], '', $user['uid']);
                }
        }
 
@@ -1834,7 +1834,7 @@ class Contact extends BaseObject
                        return;
                }
 
-               $url = $pub_contact['url'];
+               $url = defaults($datarray, 'author-link', $pub_contact['url']);
                $name = $pub_contact['name'];
                $photo = $pub_contact['photo'];
                $nick = $pub_contact['nick'];
@@ -1848,7 +1848,7 @@ class Contact extends BaseObject
                        }
 
                        if ($contact['network'] == Protocol::ACTIVITYPUB) {
-                               ActivityPub::transmitContactActivity('Accept', $contact['url'], $contact['hub-verify'], $importer['uid']);
+                               ActivityPub::transmitContactAccept($contact['url'], $contact['hub-verify'], $importer['uid']);
                        }
 
                        // send email notification to owner?
index 78d5d44daff8fc82f58402348089a2f3f12d70e2..73d5231d72995f3fe122cd3ea86f01d82481308f 100644 (file)
@@ -213,7 +213,24 @@ class ActivityPub
                return self::transmit($data,  $profile['notify'], $uid);
        }
 
-       public static function transmitContactActivity($activity, $target, $id, $uid)
+       public static function transmitContactAccept($target, $id, $uid)
+       {
+               $profile = Probe::uri($target, Protocol::ACTIVITYPUB);
+
+               $owner = User::getOwnerDataById($uid);
+               $data = ['@context' => 'https://www.w3.org/ns/activitystreams',
+                       'id' => 'https://pirati.ca/activity/' . System::createGUID(),
+                       'type' => 'Accept',
+                       'actor' => $owner['url'],
+                       'object' => ['id' => $id, 'type' => 'Follow',
+                               'actor' => $profile['url'],
+                               'object' => $owner['url']]];
+
+               logger('Sending accept to ' . $target . ' for user ' . $uid . ' with id ' . $id, LOGGER_DEBUG);
+               return self::transmit($data,  $profile['notify'], $uid);
+       }
+
+       public static function transmitContactUndo($target, $id, $uid)
        {
                $profile = Probe::uri($target, Protocol::ACTIVITYPUB);
 
@@ -224,13 +241,13 @@ class ActivityPub
                $owner = User::getOwnerDataById($uid);
                $data = ['@context' => 'https://www.w3.org/ns/activitystreams',
                        'id' => 'https://pirati.ca/activity/' . System::createGUID(),
-                       'type' => $activity,
+                       'type' => 'Undo',
                        'actor' => $owner['url'],
                        'object' => ['id' => $id, 'type' => 'Follow',
                                'actor' => $owner['url'],
                                'object' => $profile['url']]];
 
-               logger('Sending ' . $activity . ' to ' . $target . ' for user ' . $uid . ' with id ' . $id, LOGGER_DEBUG);
+               logger('Sending undo to ' . $target . ' for user ' . $uid . ' with id ' . $id, LOGGER_DEBUG);
                return self::transmit($data,  $profile['notify'], $uid);
        }
 
@@ -1099,10 +1116,10 @@ class ActivityPub
                        $contact = false;
                }
 
-               $item = ['author-id' => Contact::getIdForURL($activity['owner'])];
+               $item = ['author-id' => Contact::getIdForURL($activity['owner']),
+                       'author-link' => $activity['owner']];
 
                Contact::addRelationship($owner, $contact, $item);
-
                $cid = Contact::getIdForURL($activity['owner'], $uid);
                if (empty($cid)) {
                        return;