]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
Merge branch '0.9.x' into 1.0.x
authorCraig Andrews <candrews@integralblue.com>
Tue, 16 Feb 2010 15:25:57 +0000 (10:25 -0500)
committerCraig Andrews <candrews@integralblue.com>
Tue, 16 Feb 2010 15:25:57 +0000 (10:25 -0500)
Conflicts:
lib/queuemanager.php

1  2 
actions/showstream.php
classes/User.php
classes/statusnet.ini
db/statusnet.sql
lib/queuemanager.php
lib/statusnet.php
lib/util.php

diff --combined actions/showstream.php
index 9586761045d8cd50d5aaeaceea7cbea2ac887e0c,f9407e35a1f7890189b817c39dd8900c2c6a1f33..5a9add36ce14ef1caae088324000d94beb2999ad
@@@ -131,14 -131,14 +131,14 @@@ class ShowstreamAction extends ProfileA
                       new Feed(Feed::RSS2,
                                common_local_url('ApiTimelineUser',
                                                 array(
-                                                     'id' => $this->user->nickname,
+                                                     'id' => $this->user->id,
                                                      'format' => 'rss')),
                                sprintf(_('Notice feed for %s (RSS 2.0)'),
                                        $this->user->nickname)),
                       new Feed(Feed::ATOM,
                                common_local_url('ApiTimelineUser',
                                                 array(
-                                                     'id' => $this->user->nickname,
+                                                     'id' => $this->user->id,
                                                      'format' => 'atom')),
                                sprintf(_('Notice feed for %s (Atom)'),
                                        $this->user->nickname)),
          if ($this->user->emailmicroid && $this->user->email && $this->profile->profileurl) {
              $id = new Microid('mailto:'.$this->user->email,
                                $this->selfUrl());
 -            $this->element('meta', array('name' => 'microid',
 -                                         'content' => $id->toString()));
 -        }
 -        if ($this->user->jabbermicroid && $this->user->jabber && $this->profile->profileurl) {
 -            $id = new Microid('xmpp:'.$this->user->jabber,
 -                              $this->selfUrl());
              $this->element('meta', array('name' => 'microid',
                                           'content' => $id->toString()));
          }
diff --combined classes/User.php
index e7cecf9757dfc2c9da0175abac5289d7308b2e60,72c3f39e947e507d191bae34a2a9ed1b674e02fa..1c967b527b100b577d3cd6ea22e962a22295bc16
@@@ -48,6 -48,11 +48,6 @@@ class User extends Memcached_DataObjec
      public $language;                        // varchar(50)
      public $timezone;                        // varchar(50)
      public $emailpost;                       // tinyint(1)   default_1
 -    public $jabber;                          // varchar(255)  unique_key
 -    public $jabbernotify;                    // tinyint(1)
 -    public $jabberreplies;                   // tinyint(1)
 -    public $jabbermicroid;                   // tinyint(1)   default_1
 -    public $updatefrompresence;              // tinyint(1)
      public $sms;                             // varchar(64)  unique_key
      public $carrier;                         // int(4)
      public $smsnotify;                       // tinyint(1)
@@@ -87,7 -92,7 +87,7 @@@
      function updateKeys(&$orig)
      {
          $parts = array();
 -        foreach (array('nickname', 'email', 'jabber', 'incomingemail', 'sms', 'carrier', 'smsemail', 'language', 'timezone') as $k) {
 +        foreach (array('nickname', 'email', 'incomingemail', 'sms', 'carrier', 'smsemail', 'language', 'timezone') as $k) {
              if (strcmp($this->$k, $orig->$k) != 0) {
                  $parts[] = $k . ' = ' . $this->_quote($this->$k);
              }
  
      function noticesWithFriends($offset=0, $limit=NOTICES_PER_PAGE, $since_id=0, $before_id=0, $since=null)
      {
-         $ids = Inbox::stream($this->id, $offset, $limit, $since_id, $before_id, $since, false);
-         return Notice::getStreamByIds($ids);
+         return Inbox::streamNotices($this->id, $offset, $limit, $since_id, $before_id, $since, false);
      }
  
      function noticeInbox($offset=0, $limit=NOTICES_PER_PAGE, $since_id=0, $before_id=0, $since=null)
      {
-         $ids = Inbox::stream($this->id, $offset, $limit, $since_id, $before_id, $since, true);
-         return Notice::getStreamByIds($ids);
+         return Inbox::streamNotices($this->id, $offset, $limit, $since_id, $before_id, $since, true);
      }
  
      function friendsTimeline($offset=0, $limit=NOTICES_PER_PAGE, $since_id=0, $before_id=0, $since=null)
      {
-         $ids = Inbox::stream($this->id, $offset, $limit, $since_id, $before_id, $since, false);
-         return Notice::getStreamByIds($ids);
+         return Inbox::streamNotices($this->id, $offset, $limit, $since_id, $before_id, $since, false);
      }
  
      function ownFriendsTimeline($offset=0, $limit=NOTICES_PER_PAGE, $since_id=0, $before_id=0, $since=null)
      {
-         $ids = Inbox::stream($this->id, $offset, $limit, $since_id, $before_id, $since, true);
-         return Notice::getStreamByIds($ids);
+         return Inbox::streamNotices($this->id, $offset, $limit, $since_id, $before_id, $since, true);
      }
  
      function blowFavesCache()
diff --combined classes/statusnet.ini
index 9916384fd95f1f0ba082902446f50e78f1df47b4,5f8da7cf51bd5bcf80131eb8b74d362bd38fc2a3..bcff744bdffd133f1439a7a69bc15d324a6b82d5
@@@ -353,7 -353,7 +353,7 @@@ notice_id = 
  id = 129
  owner = 129
  consumer_key = 130
- name = 2
+ name = 130
  description = 2
  icon = 130
  source_url = 2
@@@ -541,6 -541,11 +541,6 @@@ emailmicroid = 1
  language = 2
  timezone = 2
  emailpost = 17
 -jabber = 2
 -jabbernotify = 17
 -jabberreplies = 17
 -jabbermicroid = 17
 -updatefrompresence = 17
  sms = 2
  carrier = 1
  smsnotify = 17
@@@ -560,6 -565,7 +560,6 @@@ id = 
  nickname = U
  email = U
  incomingemail = U
 -jabber = U
  sms = U
  uri = U
  
@@@ -580,6 -586,7 +580,7 @@@ modified = 38
  
  [user_group__keys]
  id = N
+ nickname = U
  
  [user_openid]
  canonical = 130
@@@ -611,19 -618,3 +612,19 @@@ modified = 38
  [user_location_prefs__keys]
  user_id = K
  
 +[user_im_prefs]
 +user_id = 129
 +screenname = 130
 +transport = 130
 +notify = 17
 +replies = 17
 +microid = 17
 +updatefrompresence = 17
 +created = 142
 +modified = 384
 +
 +[user_im_prefs__keys]
 +user_id = K
 +transport = K
 +transport = U
 +screenname = U
diff --combined db/statusnet.sql
index 7cb6ad0644010664c3158a98c8a3e51cb6cbf63e,343464801662d0fd7ff37828632952214f873fb5..0cf0572565fb7318f427d299d25bafee479a6223
@@@ -62,6 -62,11 +62,6 @@@ create table user 
      language varchar(50) comment 'preferred language',
      timezone varchar(50) comment 'timezone',
      emailpost tinyint default 1 comment 'Post by email',
 -    jabber varchar(255) unique key comment 'jabber ID for notices',
 -    jabbernotify tinyint default 0 comment 'whether to send notices to jabber',
 -    jabberreplies tinyint default 0 comment 'whether to send notices to jabber on replies',
 -    jabbermicroid tinyint default 1 comment 'whether to publish xmpp microid',
 -    updatefrompresence tinyint default 0 comment 'whether to record updates from Jabber presence notices',
      sms varchar(64) unique key comment 'sms phone number',
      carrier integer comment 'foreign key to sms_carrier' references sms_carrier (id),
      smsnotify tinyint default 0 comment 'whether to send notices to SMS',
@@@ -209,7 -214,7 +209,7 @@@ create table oauth_application 
      id integer auto_increment primary key comment 'unique identifier',
      owner integer not null comment 'owner of the application' references profile (id),
      consumer_key varchar(255) not null comment 'application consumer key' references consumer (consumer_key),
-     name varchar(255) unique key comment 'name of the application',
+     name varchar(255) not null unique key comment 'name of the application',
      description varchar(255) comment 'description of the application',
      icon varchar(255) not null comment 'application icon',
      source_url varchar(255) comment 'application homepage - used for source link',
@@@ -254,9 -259,9 +254,9 @@@ create table oid_nonces 
  create table confirm_address (
      code varchar(32) not null primary key comment 'good random code',
      user_id integer not null comment 'user who requested confirmation' references user (id),
 -    address varchar(255) not null comment 'address (email, Jabber, SMS, etc.)',
 +    address varchar(255) not null comment 'address (email, xmpp, SMS, etc.)',
      address_extra varchar(255) not null comment 'carrier ID, for SMS',
 -    address_type varchar(8) not null comment 'address type ("email", "jabber", "sms")',
 +    address_type varchar(8) not null comment 'address type ("email", "xmpp", "sms")',
      claimed datetime comment 'date this was claimed for queueing',
      sent datetime comment 'date this was sent for queueing',
      modified timestamp comment 'date this record was modified'
@@@ -271,7 -276,7 +271,7 @@@ create table remember_me 
  create table queue_item (
      id integer auto_increment primary key comment 'unique identifier',
      frame blob not null comment 'data: object reference or opaque string',
 -    transport varchar(8) not null comment 'queue for what? "email", "jabber", "sms", "irc", ...',
 +    transport varchar(8) not null comment 'queue for what? "email", "xmpp", "sms", "irc", ...',
      created datetime not null comment 'date this record was created',
      claimed datetime comment 'date this item was claimed',
  
@@@ -343,7 -348,7 +343,7 @@@ create table invitation 
       code varchar(32) not null primary key comment 'random code for an invitation',
       user_id int not null comment 'who sent the invitation' references user (id),
       address varchar(255) not null comment 'invitation sent to',
 -     address_type varchar(8) not null comment 'address type ("email", "jabber", "sms")',
 +     address_type varchar(8) not null comment 'address type ("email", "xmpp", "sms")',
       created datetime not null comment 'date this record was created',
  
       index invitation_address_idx (address, address_type),
@@@ -628,18 -633,3 +628,18 @@@ create table inbox 
      constraint primary key (user_id)
  
  ) ENGINE=InnoDB CHARACTER SET utf8 COLLATE utf8_bin;
 +
 +create table user_im_prefs (
 +    user_id integer not null comment 'user' references user (id),
 +    screenname varchar(255) not null comment 'screenname on this service',
 +    transport varchar(255) not null comment 'transport (ex xmpp, aim)',
 +    notify tinyint(1) not null default 0 comment 'Notify when a new notice is sent',
 +    replies tinyint(1) not null default 0 comment 'Send replies  from people not subscribed to',
 +    microid tinyint(1) not null default 1 comment 'Publish a MicroID',
 +    updatefrompresence tinyint(1) not null default 0 comment 'Send replies  from people not subscribed to.',
 +    created timestamp not null DEFAULT CURRENT_TIMESTAMP comment 'date this record was created',
 +    modified timestamp comment 'date this record was modified',
 +
 +    constraint primary key (user_id, transport),
 +    constraint unique key `transport_screenname_key` ( `transport` , `screenname` )
 +);
diff --combined lib/queuemanager.php
index a0b13fe556f6a93596c91580084ab9352080d1dc,64bb52e106ee7289bf03934ebb32b145f33315d5..162c9f3757d422aa95e07c37c32688fe5edc1386
@@@ -155,26 -155,51 +155,26 @@@ abstract class QueueManager extends IoM
      }
  
      /**
 -     * Encode an object or variable for queued storage.
 -     * Notice objects are currently stored as an id reference;
 -     * other items are serialized.
 +     * Encode an object for queued storage.
       *
-      * @param mixed $object
+      * @param mixed $item
       * @return string
       */
-     protected function encode($object)
+     protected function encode($item)
      {
 -        if ($item instanceof Notice) {
 -            // Backwards compat
 -            return $item->id;
 -        } else {
 -            return serialize($item);
 -        }
 +        return serialize($object);
      }
  
      /**
       * Decode an object from queued storage.
-      * Accepts back-compat notice reference entries and strings for now.
+      * Accepts notice reference entries and serialized items.
       *
       * @param string
       * @return mixed
       */
      protected function decode($frame)
      {
 -        if (is_numeric($frame)) {
 -            // Back-compat for notices...
 -            return Notice::staticGet(intval($frame));
 -        } elseif (substr($frame, 0, 1) == '<') {
 -            // Back-compat for XML source
 -            return $frame;
 -        } else {
 -            // Deserialize!
 -            #$old = error_reporting();
 -            #error_reporting($old & ~E_NOTICE);
 -            $out = unserialize($frame);
 -            #error_reporting($old);
 -
 -            if ($out === false && $frame !== 'b:0;') {
 -                common_log(LOG_ERR, "Couldn't unserialize queued frame: $frame");
 -                return false;
 -            }
 -            return $out;
 -        }
 +        return unserialize($frame);
      }
  
      /**
                  $this->connect('sms', 'SmsQueueHandler');
              }
  
 -            // XMPP output handlers...
 -            $this->connect('jabber', 'JabberQueueHandler');
 -            $this->connect('public', 'PublicQueueHandler');
 -            // @fixme this should get an actual queue
 -            //$this->connect('confirm', 'XmppConfirmHandler');
 -
              // For compat with old plugins not registering their own handlers.
              $this->connect('plugin', 'PluginQueueHandler');
 -
 -            $this->connect('xmppout', 'XmppOutQueueHandler', 'xmppdaemon');
 -
          }
          Event::handle('EndInitializeQueueManager', array($this));
      }
          $group = 'queuedaemon';
          if ($this->master) {
              // hack hack
 -            if ($this->master instanceof XmppMaster) {
 -                return 'xmppdaemon';
 +            if ($this->master instanceof ImMaster) {
 +                return 'imdaemon';
              }
          }
          return $group;
diff --combined lib/statusnet.php
index 2654ba5736ade358644a368534f48878f8eaf1bb,4f82fdaa6cb64ee22372393124c002d5536f63fd..3951d9251b89ad0014860f0dbd263f24552b6d3c
@@@ -30,6 -30,7 +30,7 @@@ global $config, $_server, $_path
  class StatusNet
  {
      protected static $have_config;
+     protected static $is_api;
  
      /**
       * Configure and instantiate a plugin into the current configuration.
          return self::$have_config;
      }
  
+     public function isApi()
+     {
+         return self::$is_api;
+     }
+     
+     public function setApi($mode)
+     {
+         self::$is_api = $mode;
+     }
      /**
       * Build default configuration array
       * @return array
          }
  
          // Backwards compatibility
 -
          if (array_key_exists('memcached', $config)) {
              if ($config['memcached']['enabled']) {
                  addPlugin('Memcache', array('servers' => $config['memcached']['server']));
                  $config['cache']['base'] = $config['memcached']['base'];
              }
          }
 +        if (array_key_exists('xmpp', $config)) {
 +            if ($config['xmpp']['enabled']) {
 +                addPlugin('xmpp', array(
 +                    'server' => $config['xmpp']['server'],
 +                    'port' => $config['xmpp']['port'],
 +                    'user' => $config['xmpp']['user'],
 +                    'resource' => $config['xmpp']['resource'],
 +                    'encryption' => $config['xmpp']['encryption'],
 +                    'password' => $config['xmpp']['password'],
 +                    'host' => $config['xmpp']['host'],
 +                    'debug' => $config['xmpp']['debug'],
 +                    'public' => $config['xmpp']['public']
 +                ));
 +            }
 +        }
      }
  }
  
diff --combined lib/util.php
index 9a24d268db7caccad26f1b7979f57a2f5511e006,8c46f5e355829b2ada8ffd7171444fed385483a8..3f20e2ec75382a2b7e0b8a8936a2f8fc67b738dd
@@@ -367,7 -367,8 +367,8 @@@ function common_current_user(
  
      if ($_cur === false) {
  
-         if (isset($_REQUEST[session_name()]) || (isset($_SESSION['userid']) && $_SESSION['userid'])) {
+         if (isset($_COOKIE[session_name()]) || isset($_GET[session_name()])
+             || (isset($_SESSION['userid']) && $_SESSION['userid'])) {
              common_ensure_session();
              $id = isset($_SESSION['userid']) ? $_SESSION['userid'] : false;
              if ($id) {
@@@ -658,6 -659,9 +659,9 @@@ function common_valid_profile_tag($str
  function common_at_link($sender_id, $nickname)
  {
      $sender = Profile::staticGet($sender_id);
+     if (!$sender) {
+         return $nickname;
+     }
      $recipient = common_relative_profile($sender, common_canonical_nickname($nickname));
      if ($recipient) {
          $user = User::staticGet('id', $recipient->id);
@@@ -687,7 -691,7 +691,7 @@@ function common_group_link($sender_id, 
  {
      $sender = Profile::staticGet($sender_id);
      $group = User_group::getForNickname($nickname);
-     if ($group && $sender->isMember($group)) {
+     if ($sender && $group && $sender->isMember($group)) {
          $attrs = array('href' => $group->permalink(),
                         'class' => 'url');
          if (!empty($group->fullname)) {
@@@ -998,10 -1002,19 +1002,10 @@@ function common_enqueue_notice($notice
      }
      
  
 -    $xmpp = common_config('xmpp', 'enabled');
 -
 -    if ($xmpp) {
 -        $transports[] = 'jabber';
 -    }
 -
      // @fixme move these checks into QueueManager and/or individual handlers
      if ($notice->is_local == Notice::LOCAL_PUBLIC ||
          $notice->is_local == Notice::LOCAL_NONPUBLIC) {
          $transports = array_merge($transports, $localTransports);
 -        if ($xmpp) {
 -            $transports[] = 'public';
 -        }
      }
  
      if (Event::handle('StartEnqueueNotice', array($notice, &$transports))) {