]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - plugins/Bookmark/BookmarkPlugin.php
Merge ActivitySpam plugin
[quix0rs-gnu-social.git] / plugins / Bookmark / BookmarkPlugin.php
index 77b8a8483cfc6f244bdd3d041c6f61a0ff650139..319366c19bae017ce8b427cae98d0f63a7904630 100644 (file)
@@ -551,4 +551,41 @@ class BookmarkPlugin extends MicroAppPlugin
         // TRANS: Application title.
         return _m('TITLE','Bookmark');
     }
+
+    function onEndUpgrade()
+    {
+        // Version 0.9.x of the plugin didn't stamp notices
+        // with verb and object-type (for obvious reasons). Update
+        // those notices here.
+
+        $notice = new Notice();
+        
+        $notice->whereAdd('exists (select uri from bookmark where bookmark.uri = notice.uri)');
+        $notice->whereAdd('((object_type is null) or (object_type = "' .ActivityObject::NOTE.'"))');
+
+        $notice->find();
+
+        while ($notice->fetch()) {
+            $original = clone($notice);
+            $notice->verb        = ActivityVerb::POST;
+            $notice->object_type = ActivityObject::BOOKMARK;
+            $notice->update($original);
+        }
+    }
+
+    public function activityObjectOutputJson(ActivityObject $obj, array &$out)
+    {
+        assert($obj->type == ActivityObject::BOOKMARK);
+
+        $bm = Bookmark::staticGet('uri', $obj->id);
+
+        if (empty($bm)) {
+            throw new ServerException("Unknown bookmark: " . $obj->id);
+        }
+
+        $out['displayName'] = $bm->title;
+        $out['targetUrl']   = $bm->url;
+
+        return true;
+    }
 }