]> git.mxchange.org Git - friendica.git/blobdiff - src/Protocol/Diaspora.php
Use the owner, not the author
[friendica.git] / src / Protocol / Diaspora.php
index 4549ba643f88023ebcbf17aebf6d97a8b01868f9..dd6c2115b5e32714a868bae0ee589465ca76bf31 100644 (file)
@@ -42,7 +42,6 @@ use Friendica\Model\Tag;
 use Friendica\Model\User;
 use Friendica\Network\HTTPClient\Client\HttpClientAccept;
 use Friendica\Network\HTTPException;
-use Friendica\Network\HTTPException\BadRequestException;
 use Friendica\Network\Probe;
 use Friendica\Protocol\Delivery;
 use Friendica\Util\Crypto;
@@ -268,7 +267,7 @@ class Diaspora
                                if ($no_exit) {
                                        return false;
                                } else {
-                                       throw new BadRequestException();
+                                       throw new HTTPException\BadRequestException();
                                }
                        }
                } else {
@@ -282,7 +281,7 @@ class Diaspora
                        if ($no_exit) {
                                return false;
                        } else {
-                               throw new BadRequestException();
+                               throw new HTTPException\BadRequestException();
                        }
                }
 
@@ -308,7 +307,7 @@ class Diaspora
                        if ($no_exit) {
                                return false;
                        } else {
-                               throw new BadRequestException();
+                               throw new HTTPException\BadRequestException();
                        }
                }
 
@@ -323,7 +322,7 @@ class Diaspora
                        if ($no_exit) {
                                return false;
                        } else {
-                               throw new BadRequestException();
+                               throw new HTTPException\BadRequestException();
                        }
                }
 
@@ -333,7 +332,7 @@ class Diaspora
                        if ($no_exit) {
                                return false;
                        } else {
-                               throw new BadRequestException();
+                               throw new HTTPException\BadRequestException();
                        }
                }
 
@@ -425,7 +424,7 @@ class Diaspora
 
                if (!$base) {
                        Logger::notice('unable to locate salmon data in xml');
-                       throw new BadRequestException();
+                       throw new HTTPException\BadRequestException();
                }
 
 
@@ -465,14 +464,14 @@ class Diaspora
                $key = self::key($author);
                if (!$key) {
                        Logger::notice('Could not retrieve author key.');
-                       throw new BadRequestException();
+                       throw new HTTPException\BadRequestException();
                }
 
                $verify = Crypto::rsaVerify($signed_data, $signature, $key);
 
                if (!$verify) {
                        Logger::notice('Message did not verify. Discarding.');
-                       throw new BadRequestException();
+                       throw new HTTPException\BadRequestException();
                }
 
                Logger::info('Message verified.');
@@ -2655,7 +2654,7 @@ class Diaspora
 
                $datarray = [
                        'guid'        => $guid,
-                       'uri-id'      => ItemURI::insert(['uri' => $guid, 'guid' => $guid]),
+                       'plink'       => self::plink($author, $guid),
                        'uid'         => $importer['uid'],
                        'contact-id'  => $contact['id'],
                        'network'     => Protocol::DIASPORA,
@@ -2673,9 +2672,12 @@ class Diaspora
                        'post-type'   => Item::PT_NOTE,
                ];
 
-               $datarray['guid'] = $guid;
-               $datarray['uri'] = $datarray['thr-parent'] = self::getUriFromGuid($guid, $author);
-               $datarray['uri-id'] = ItemURI::insert(['uri' => $datarray['uri'], 'guid' => $datarray['guid']]);
+               $datarray['uri']        = $datarray['thr-parent'] = self::getUriFromGuid($guid, $author);
+               $datarray['uri-id']     = ItemURI::insert(['uri' => $datarray['uri'], 'guid' => $datarray['guid']]);
+               $datarray['owner-link'] = $datarray['author-link'];
+               $datarray['owner-id']   = $datarray['author-id'];
+
+               $datarray = self::setDirection($datarray, $direction);
 
                // Attach embedded pictures to the body
                if ($data->photo) {
@@ -2686,7 +2688,6 @@ class Diaspora
                        $datarray['object-type'] = Activity\ObjectType::IMAGE;
                        $datarray['post-type'] = Item::PT_IMAGE;
                } elseif ($data->poll) {
-                       $datarray['object-type'] = Activity\ObjectType::NOTE;
                        $datarray['post-type'] = Item::PT_POLL;
                }
 
@@ -2711,7 +2712,6 @@ class Diaspora
                        $datarray['app'] = $provider_display_name;
                }
 
-               $datarray['plink'] = self::plink($author, $guid);
                $datarray['changed'] = $datarray['created'] = $datarray['edited'] = $created_at;
 
                if (isset($address['address'])) {