]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - plugins/OStatus/lib/salmonaction.php
Merge branch 'profile' into 'nightly'
[quix0rs-gnu-social.git] / plugins / OStatus / lib / salmonaction.php
index 6855fd1b180af27c9a2de155503fab2451c0df48..4d2144c30056aa7a6512d5626c80e9683acc2f1b 100644 (file)
@@ -31,6 +31,8 @@ class SalmonAction extends Action
     protected $oprofile = null; // Ostatus_profile of the actor
     protected $actor    = null; // Profile object of the actor
 
+    var $format   = 'text'; // error messages will be printed in plaintext
+
     var $xml      = null;
     var $activity = null;
     var $target   = null;
@@ -43,7 +45,7 @@ class SalmonAction extends Action
 
         if (!isset($_SERVER['CONTENT_TYPE'])) {
             // TRANS: Client error. Do not translate "Content-type"
-            $this->clientError(_m('Salmon requires a Content-type header.'));
+            throw new ClientException(_m('Salmon requires a Content-type header.'));
         }
         $envxml = null;
         switch ($_SERVER['CONTENT_TYPE']) {
@@ -83,6 +85,8 @@ class SalmonAction extends Action
         // Cryptographic verification test, throws exception on failure
         $magic_env->verify($this->actor);
 
+        common_debug('Salmon slap is carrying activity URI=='._ve($this->activity->id));
+
         return true;
     }
 
@@ -98,6 +102,7 @@ class SalmonAction extends Action
         assert($this->target instanceof Profile);
 
         common_log(LOG_DEBUG, "Got a " . $this->activity->verb);
+
         try {
             $options = [ 'source' => 'ostatus' ];
             common_debug('Save salmon slap directly with Notice::saveActivity for actor=='.$this->actor->getID());
@@ -109,6 +114,9 @@ class SalmonAction extends Action
             // duplicate? Maybe someone's database is out of sync?
             // Let's just accept it and move on.
             common_log(LOG_INFO, 'Salmon slap carried an event which had already been fulfilled.');
+            return true;
+        } catch (NoticeSaveException $e) {
+            common_debug('Notice::saveActivity did not save our '._ve($this->activity->verb).' activity, trying old-fashioned salmon saving.');
         }
 
         try {