]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - lib/oauthstore.php
use the new maxNoticeLength and maxUrlLength functionality introduced in commit 14adb...
[quix0rs-gnu-social.git] / lib / oauthstore.php
index 87d8cf2137b197718d93b4d5803502e5c50f867f..a6a6de7505c946bbdd0a24b7760dea3ff8abb940 100644 (file)
@@ -1,7 +1,7 @@
 <?php
 /*
- * Laconica - a distributed open-source microblogging tool
- * Copyright (C) 2008, 2009, Control Yourself, Inc.
+ * StatusNet - the distributed open-source microblogging tool
+ * Copyright (C) 2008, 2009, StatusNet, Inc.
  *
  * This program is free software: you can redistribute it and/or modify
  * it under the terms of the GNU Affero General Public License as published by
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 
-if (!defined('LACONICA')) {
-    exit(1);
-}
+if (!defined('STATUSNET') && !defined('LACONICA')) { exit(1); }
 
 require_once 'libomb/datastore.php';
 
-class LaconicaDataStore extends OMB_Datastore
+class StatusNetOAuthDataStore extends OAuthDataStore
 {
 
     // We keep a record of who's contacted us
@@ -67,7 +65,7 @@ class LaconicaDataStore extends OMB_Datastore
     {
         $n = new Nonce();
         $n->consumer_key = $consumer->key;
-        $n->ts = $timestamp;
+        $n->ts = common_sql_date($timestamp);
         $n->nonce = $nonce;
         if ($n->find(true)) {
             return true;
@@ -158,7 +156,6 @@ class LaconicaDataStore extends OMB_Datastore
         return $this->new_access_token($consumer);
     }
 
-
     /**
      * Revoke specified OAuth token
      *
@@ -354,7 +351,7 @@ class LaconicaDataStore extends OMB_Datastore
             $author = User::staticGet('uri', $author_uri);
         }
         if (!$author) {
-            throw new Exception('No such user');
+            throw new Exception('No such user.');
         }
 
         common_log(LOG_DEBUG, print_r($author, true), __FILE__);
@@ -362,13 +359,9 @@ class LaconicaDataStore extends OMB_Datastore
         $notice = Notice::saveNew($author->id,
                                   $omb_notice->getContent(),
                                   'omb',
-                                  false,
-                                  null,
-                                  $omb_notice->getIdentifierURI());
-        if (is_string($notice)) {
-            throw new Exception($notice);
-        }
-        common_broadcast_notice($notice, true);
+                                  array('is_local' => Notice::REMOTE_OMB,
+                                        'uri' => $omb_notice->getIdentifierURI()));
+
     }
 
     /**
@@ -397,7 +390,7 @@ class LaconicaDataStore extends OMB_Datastore
         $sub->subscribed = $user->id;
 
         if (!$sub->find(true)) {
-            return 0;
+            return array();
         }
 
         /* Since we do not use OMB_Service_Provider’s action methods, there
@@ -412,7 +405,7 @@ class LaconicaDataStore extends OMB_Datastore
             $user = User::staticGet('uri', $uri);
         }
         if (!$user) {
-            throw new Exception('No such user');
+            throw new Exception('No such user.');
         }
         return $user;
     }
@@ -467,6 +460,11 @@ class LaconicaDataStore extends OMB_Datastore
         $subscribed = $this->_getAnyProfile($subscribed_user_uri);
         $subscriber = $this->_getAnyProfile($subscriber_uri);
 
+        if (!$subscriber->hasRight(Right::SUBSCRIBE)) {
+            common_log(LOG_INFO, __METHOD__ . ": remote subscriber banned ($subscriber_uri subbing to $subscribed_user_uri)");
+            return _('You have been banned from subscribing.');
+        }
+
         $sub->subscribed = $subscribed->id;
         $sub->subscriber = $subscriber->id;