]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - actions/newnotice.php
Merge branch 'nightly' into 'nightly'
[quix0rs-gnu-social.git] / actions / newnotice.php
index 298361d6003a614a2be287ffbdd9c2bc66fe3672..170e5bcdf8f519de4fbc596985b532e6ed41fcbb 100644 (file)
@@ -47,6 +47,8 @@ class NewnoticeAction extends FormAction
 {
     protected $form = 'Notice';
 
+    protected $inreplyto = null;
+
     /**
      * Title of the page
      *
@@ -75,6 +77,11 @@ class NewnoticeAction extends FormAction
             }
         }
 
+        if ($this->int('inreplyto')) {
+            // Throws exception if the inreplyto Notice is given but not found.
+            $this->inreplyto = Notice::getByID($this->int('inreplyto'));
+        }
+
         // Backwards compatibility for "share this" widget things.
         // If no 'content', use 'status_textarea'
         $this->formOpts['content'] = $this->trimmed('content') ?: $this->trimmed('status_textarea');
@@ -115,7 +122,7 @@ class NewnoticeAction extends FormAction
             // simply no attached media to the new notice
             if (empty($content)) {
                 // TRANS: Client error displayed trying to send a notice without content.
-                $this->clientError(_('No content!'));
+                throw new ClientException(_('No content!'));
             }
         }
 
@@ -132,13 +139,6 @@ class NewnoticeAction extends FormAction
             return;
         }
 
-        if ($this->int('inreplyto')) {
-            // Throws exception if the inreplyto Notice is given but not found.
-            $parent = Notice::getByID($this->int('inreplyto'));
-        } else {
-            $parent = null;
-        }
-
         $act = new Activity();
         $act->verb = ActivityVerb::POST;
         $act->time = time();
@@ -157,9 +157,9 @@ class NewnoticeAction extends FormAction
 
         $act->context = new ActivityContext();
 
-        if ($parent instanceof Notice) {
-            $act->context->replyToID = $parent->getUri();
-            $act->context->replyToUrl = $parent->getUrl(true);  // maybe we don't have to send true here to force a URL?
+        if ($this->inreplyto instanceof Notice) {
+            $act->context->replyToID = $this->inreplyto->getUri();
+            $act->context->replyToUrl = $this->inreplyto->getUrl(true);  // maybe we don't have to send true here to force a URL?
         }
 
         if ($this->scoped->shareLocation()) {
@@ -188,11 +188,14 @@ class NewnoticeAction extends FormAction
 
             // FIXME: We should be able to get the attentions from common_render_content!
             // and maybe even directly save whether they're local or not!
-            $act->context->attention = common_get_attentions($content, $this->scoped, $parent);
+            $act->context->attention = common_get_attentions($content, $this->scoped, $this->inreplyto);
+
+            // $options gets filled with possible scoping settings
+            ToSelector::fillActivity($this, $act, $options);
 
             $actobj = new ActivityObject();
             $actobj->type = ActivityObject::NOTE;
-            $actobj->content = common_render_content($content, $this->scoped, $parent);
+            $actobj->content = common_render_content($content, $this->scoped, $this->inreplyto);
 
             // Finally add the activity object to our activity
             $act->objects[] = $actobj;
@@ -221,6 +224,9 @@ class NewnoticeAction extends FormAction
         if ($this->getInfo() && $this->stored instanceof Notice) {
             $this->showNotice($this->stored);
         } elseif (!$this->getError()) {
+            if (!GNUsocial::isAjax() && $this->inreplyto instanceof Notice) {
+                $this->showNotice($this->inreplyto);
+            }
             parent::showContent();
         }
     }