]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - plugins/TwitterBridge/Notice_to_status.php
Show photos on all of a user's pages
[quix0rs-gnu-social.git] / plugins / TwitterBridge / Notice_to_status.php
index ecd4905dcc0d2979ee9794c6a0bfc0ecf0be6bd7..3b8f816cfc85e3cb028b779e57853f5501a6e84c 100644 (file)
@@ -144,6 +144,7 @@ class Notice_to_status extends Memcached_DataObject
 
     /**
      * Save a mapping between a notice and a status
+     * Warning: status_id values may not fit in 32-bit integers.
      *
      * @param integer $notice_id ID of the notice in StatusNet
      * @param integer $status_id ID of the status in Twitter
@@ -153,6 +154,26 @@ class Notice_to_status extends Memcached_DataObject
 
     static function saveNew($notice_id, $status_id)
     {
+        if (empty($notice_id)) {
+            throw new Exception("Invalid notice_id $notice_id");
+        }
+        $n2s = Notice_to_status::staticGet('notice_id', $notice_id);
+
+        if (!empty($n2s)) {
+            return $n2s;
+        }
+
+        if (empty($status_id)) {
+            throw new Exception("Invalid status_id $status_id");
+        }
+        $n2s = Notice_to_status::staticGet('status_id', $status_id);
+
+        if (!empty($n2s)) {
+            return $n2s;
+        }
+
+        common_debug("Mapping notice {$notice_id} to Twitter status {$status_id}");
+
         $n2s = new Notice_to_status();
 
         $n2s->notice_id = $notice_id;