]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
cleanup... Poll main & response events seem to sorta work over ostatus now
authorBrion Vibber <brion@pobox.com>
Thu, 10 Mar 2011 21:55:47 +0000 (13:55 -0800)
committerBrion Vibber <brion@pobox.com>
Thu, 10 Mar 2011 21:56:54 +0000 (13:56 -0800)
plugins/Poll/PollPlugin.php
plugins/Poll/Poll_response.php

index f76faedb05d52acebf23bbfe73a1076070898fe3..a2e9814555f1d877cc3193a53a4b91d7bdbf42bc 100644 (file)
@@ -280,31 +280,34 @@ class PollPlugin extends MicroAppPlugin
         $object->link    = $notice->bestUrl();
 
         $response = Poll_response::getByNotice($notice);
-        $poll = $response->getPoll();
-
-        /**
-         * For the moment, using a kind of icky-looking schema that happens to
-         * work with out code for generating both Atom and JSON forms, though
-         * I don't like it:
-         *
-         * <poll:response xmlns:poll="http://apinamespace.org/activitystreams/object/poll"
-         *                poll="http://..../poll/...."
-         *                selection="3" />
-         *
-         * "poll:response": {
-         *     "xmlns:poll": http://apinamespace.org/activitystreams/object/poll
-         *     "uri": "http://..../poll/...."
-         *     "selection": 3
-         * }
-         *
-         */
-        // @fixme there's no way to specify an XML node tree here, like <poll><option/><option/></poll>
-        // @fixme there's no way to specify a JSON array or multi-level tree unless you break the XML attribs
-        // @fixme XML node contents don't get shown in JSON
-        $data = array('xmlns:poll' => self::POLL_OBJECT,
-                      'poll'       => $poll->uri,
-                      'selection'  => intval($response->selection));
-        $object->extra[] = array('poll:response', $data, '');
+        if (!$response) {
+            common_log(LOG_DEBUG, "QQQ notice uri: $notice->uri");
+        } else {
+            $poll = $response->getPoll();
+            /**
+             * For the moment, using a kind of icky-looking schema that happens to
+             * work with out code for generating both Atom and JSON forms, though
+             * I don't like it:
+             *
+             * <poll:response xmlns:poll="http://apinamespace.org/activitystreams/object/poll"
+             *                poll="http://..../poll/...."
+             *                selection="3" />
+             *
+             * "poll:response": {
+             *     "xmlns:poll": http://apinamespace.org/activitystreams/object/poll
+             *     "uri": "http://..../poll/...."
+             *     "selection": 3
+             * }
+             *
+             */
+            // @fixme there's no way to specify an XML node tree here, like <poll><option/><option/></poll>
+            // @fixme there's no way to specify a JSON array or multi-level tree unless you break the XML attribs
+            // @fixme XML node contents don't get shown in JSON
+            $data = array('xmlns:poll' => self::POLL_OBJECT,
+                          'poll'       => $poll->uri,
+                          'selection'  => intval($response->selection));
+            $object->extra[] = array('poll:response', $data, '');
+        }
         return $object;
     }
 
index 03dd6f60b552104a91f853d6aa049ea839b44b4a..88e6ea890cb32cfea4b53c75d70b094bd8d5fa88 100644 (file)
@@ -141,6 +141,14 @@ class Poll_response extends Managed_DataObject
         return $this->getNotice()->bestUrl();
     }
 
+    /**
+     *
+     * @return Poll
+     */
+    function getPoll()
+    {
+        return Poll::staticGet('id', $this->poll_id);
+    }
     /**
      * Save a new poll notice
      *