]> git.mxchange.org Git - friendica.git/commitdiff
Accepting contact request does finally work per Mastodon API
authorMichael <heluecht@pirati.ca>
Sat, 29 Oct 2022 19:04:29 +0000 (19:04 +0000)
committerMichael <heluecht@pirati.ca>
Sat, 29 Oct 2022 19:04:29 +0000 (19:04 +0000)
src/Factory/Api/Mastodon/Notification.php
src/Module/Api/Mastodon/FollowRequests.php

index 33c252e4f173a0c72a5175db788406e17c65e522..3e43835b4398bc1ac2598f0ff09e1bc2ed53d7d0 100644 (file)
@@ -83,7 +83,10 @@ class Notification extends BaseFactory
        public static function getType(Entity\Notification $Notification): string
        {
                if (($Notification->verb == Activity::FOLLOW) && ($Notification->type === Post\UserNotification::TYPE_NONE)) {
-                       $contact = Contact::getById($Notification->actorId, ['pending']);
+                       $contact = Contact::getById($Notification->actorId, ['pending', 'uri-id', 'uid']);
+                       if (($contact['uid'] == 0) && !empty($contact['uri-id'])) {
+                               $contact = Contact::selectFirst(['pending', 'uri-id', 'uid'], ['uri-id' => $contact['uri-id'], 'uid' => $Notification->uid]);
+                       }
                        $type = $contact['pending'] ? MstdnNotification::TYPE_INTRODUCTION : MstdnNotification::TYPE_FOLLOW;
                } elseif (($Notification->verb == Activity::ANNOUNCE) &&
                        in_array($Notification->type, [Post\UserNotification::TYPE_DIRECT_COMMENT, Post\UserNotification::TYPE_DIRECT_THREAD_COMMENT])) {
index 99e20cd7f0792d0557fed528e3fde088a69af9cb..af08517e9747906817540d0baf28598ce604be07 100644 (file)
@@ -47,7 +47,12 @@ class FollowRequests extends BaseApi
                self::checkAllowedScope(self::SCOPE_FOLLOW);
                $uid = self::getCurrentUserID();
 
-               $introduction = DI::intro()->selectOneById($this->parameters['id'], $uid);
+               $cdata = Contact::getPublicAndUserContactID($this->parameters['id'], $uid);
+               if (empty($cdata['user'])) {
+                       throw new HTTPException\NotFoundException('Contact not found');
+               }
+
+               $introduction = DI::intro()->selectForContact($cdata['user']);
 
                $contactId = $introduction->cid;