]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
Merge branch '0.7.x' into 0.8.x
authorEvan Prodromou <evan@controlyourself.ca>
Fri, 3 Apr 2009 19:36:16 +0000 (15:36 -0400)
committerEvan Prodromou <evan@controlyourself.ca>
Fri, 3 Apr 2009 19:36:16 +0000 (15:36 -0400)
1  2 
lib/util.php

diff --combined lib/util.php
index b0d1174551ebd09f03e23d3e9d93c55d6ccc1ebf,73410e2891b98dd1166eb8cd4e3db6c3057a64f9..ad1044fa23fc405cf2f21558b8d27cad9578a954
@@@ -723,7 -723,7 +723,7 @@@ function common_local_url($action, $arg
  {
      static $sensitive = array('login', 'register', 'passwordsettings',
                                'twittersettings', 'finishopenidlogin',
-                               'api');
+                               'finishaddopenid', 'api');
  
      $r = Router::get();
      $path = $r->build($action, $args, $params, $fragment);
@@@ -876,76 -876,18 +876,76 @@@ function common_broadcast_notice($notic
  
  function common_enqueue_notice($notice)
  {
 -    foreach (array('jabber', 'omb', 'sms', 'public', 'twitter', 'facebook', 'ping') as $transport) {
 -        $qi = new Queue_item();
 -        $qi->notice_id = $notice->id;
 -        $qi->transport = $transport;
 -        $qi->created = $notice->created;
 -        $result = $qi->insert();
 -        if (!$result) {
 -            $last_error = &PEAR::getStaticProperty('DB_DataObject','lastError');
 -            common_log(LOG_ERR, 'DB error inserting queue item: ' . $last_error->message);
 -            return false;
 +    if (common_config('queue','subsystem') == 'stomp') {
 +      // use an external message queue system via STOMP
 +      require_once("Stomp.php");
 +      $con = new Stomp(common_config('queue','stomp_server'));
 +      if (!$con->connect()) {
 +              common_log(LOG_ERR, 'Failed to connect to queue server');
 +              return false;
 +      }
 +      $queue_basename = common_config('queue','queue_basename');
 +      foreach (array('jabber', 'omb', 'sms', 'public', 'twitter', 'facebook', 'ping') as $transport) {
 +              if (!$con->send(
 +                      '/queue/'.$queue_basename.'-'.$transport, // QUEUE
 +                      $notice->id,            // BODY of the message
 +                      array (                 // HEADERS of the msg
 +                      'created' => $notice->created
 +                      ))) {
 +                      common_log(LOG_ERR, 'Error sending to '.$transport.' queue');
 +                      return false;
 +              }
 +        common_log(LOG_DEBUG, 'complete remote queueing notice ID = ' . $notice->id . ' for ' . $transport);
 +      }
 +
 +      //send tags as headers, so they can be used as JMS selectors
 +        common_log(LOG_DEBUG, 'searching for tags ' . $notice->id);
 +        $tags = array();
 +      $tag = new Notice_tag();
 +        $tag->notice_id = $notice->id;
 +        if ($tag->find()) {
 +            while ($tag->fetch()) {
 +              common_log(LOG_DEBUG, 'tag found = ' . $tag->tag);
 +              array_push($tags,$tag->tag);
 +            }
 +        }
 +        $tag->free();
 +
 +      $con->send('/topic/laconica.'.$notice->profile_id,
 +                      $notice->content,
 +                      array(
 +                              'profile_id' => $notice->profile_id,
 +                              'created' => $notice->created,
 +                              'tags' => implode($tags,' - ')
 +                              )
 +                      );
 +        common_log(LOG_DEBUG, 'sent to personal topic ' . $notice->id);
 +      $con->send('/topic/laconica.allusers',
 +                      $notice->content,
 +                      array(
 +                              'profile_id' => $notice->profile_id,
 +                              'created' => $notice->created,
 +                              'tags' => implode($tags,' - ')
 +                              )
 +                      );
 +        common_log(LOG_DEBUG, 'sent to catch-all topic ' . $notice->id);
 +      $result = true;
 +    }
 +    else {
 +      // in any other case, 'internal'
 +      foreach (array('jabber', 'omb', 'sms', 'public', 'twitter', 'facebook', 'ping') as $transport) {
 +              $qi = new Queue_item();
 +              $qi->notice_id = $notice->id;
 +              $qi->transport = $transport;
 +              $qi->created = $notice->created;
 +              $result = $qi->insert();
 +              if (!$result) {
 +                  $last_error = &PEAR::getStaticProperty('DB_DataObject','lastError');
 +                  common_log(LOG_ERR, 'DB error inserting queue item: ' . $last_error->message);
 +                  return false;
 +              }
 +              common_log(LOG_DEBUG, 'complete queueing notice ID = ' . $notice->id . ' for ' . $transport);
          }
 -        common_log(LOG_DEBUG, 'complete queueing notice ID = ' . $notice->id . ' for ' . $transport);
      }
      return $result;
  }