]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - actions/newnotice.php
Merge branch 'fix-author-fallback' into 'nightly'
[quix0rs-gnu-social.git] / actions / newnotice.php
index f874e6f9cb3b268c1bc6fc5b9e847e0878e058d7..6ee209206110ccbfcca611837a08e2e2f82aee1b 100644 (file)
@@ -95,13 +95,28 @@ class NewnoticeAction extends FormAction
     {
         assert($this->scoped instanceof Profile); // XXX: maybe an error instead...
         $user = $this->scoped->getUser();
-        $content = $this->trimmed('status_textarea');
+        $content = $this->formOpts['content'];
         $options = array('source' => 'web');
         Event::handle('StartSaveNewNoticeWeb', array($this, $user, &$content, &$options));
 
-        if (empty($content)) {
-            // TRANS: Client error displayed trying to send a notice without content.
-            $this->clientError(_('No content!'));
+        $upload = null;
+        try {
+            // throws exception on failure
+            $upload = MediaFile::fromUpload('attach', $this->scoped);
+            if (Event::handle('StartSaveNewNoticeAppendAttachment', array($this, $upload, &$content, &$options))) {
+                $content .= ($content==='' ? '' : ' ') . $upload->shortUrl();
+            }
+            Event::handle('EndSaveNewNoticeAppendAttachment', array($this, $upload, &$content, &$options));
+
+            // We could check content length here if the URL was added, but I'll just let it slide for now...
+
+            $act->enclosures[] = $upload->getEnclosure();
+        } catch (NoUploadedMediaException $e) {
+            // 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!'));
+            }
         }
 
         $inter = new CommandInterpreter();
@@ -129,22 +144,6 @@ class NewnoticeAction extends FormAction
         $act->time = time();
         $act->actor = $this->scoped->asActivityObject();
 
-        $upload = null;
-        try {
-            // throws exception on failure
-            $upload = MediaFile::fromUpload('attach', $this->scoped);
-            if (Event::handle('StartSaveNewNoticeAppendAttachment', array($this, $upload, &$content, &$options))) {
-                $content .= ' ' . $upload->shortUrl();
-            }
-            Event::handle('EndSaveNewNoticeAppendAttachment', array($this, $upload, &$content, &$options));
-
-            // We could check content length here if the URL was added, but I'll just let it slide for now...
-
-            $act->enclosures[] = $upload->getEnclosure();
-        } catch (NoUploadedMediaException $e) {
-            // simply no attached media to the new notice
-        }
-
         // Reject notice if it is too long (without the HTML)
         // This is done after MediaFile::fromUpload etc. just to act the same as the ApiStatusesUpdateAction
         if (Notice::contentTooLong($content)) {
@@ -189,7 +188,10 @@ 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_find_attentions($content, $this->scoped, $parent);
+            $act->context->attention = common_get_attentions($content, $this->scoped, $parent);
+
+            // $options gets filled with possible scoping settings
+            ToSelector::fillActivity($this, $act, $options);
 
             $actobj = new ActivityObject();
             $actobj->type = ActivityObject::NOTE;