Fixed REST API - Profile posts missing attachment support

If you mean that GET profile-posts/{id}/ is missing attachments in the way that GET threads/{id}/?with_posts=1 would include them as properties of each post, this is now resolved.

If that's not what you mean, let me know.
 
If that's not what you mean, let me know.

Ah, no sorry - the POST profile-post-comments, POST profile-post-comments/{id}/, POST profile-posts, and POST profile-posts/{id}/ endpoints are missing the attachment_key parameter to associate attachments when creating / editing profile posts / comments
 
Sorry, I misread your initial report. Support for attachment_key on all of those actions is now available.
Diff:
Index: src/XF/Api/Controller/ProfilePost.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/src/XF/Api/Controller/ProfilePost.php b/src/XF/Api/Controller/ProfilePost.php
--- a/src/XF/Api/Controller/ProfilePost.php    (revision 6ce00c8cec20a3ace2f52da0f080383f0d3e8816)
+++ b/src/XF/Api/Controller/ProfilePost.php    (revision f2cc4406f471f1c052bfb1ec2703537a9a2cee8c)
@@ -127,6 +127,7 @@
      * @api-in str $message
      * @api-in bool $author_alert
      * @api-in bool $author_alert_reason
+     * @api-in str $attachment_key API attachment key to upload files. Attachment key context type must be profile_post with context[profile_post_id] set to this profile post ID.
      *
      * @api-out true $success
      * @api-out ProfilePost $profile_post
@@ -169,7 +170,8 @@
         $input = $this->filter([
             'message' => '?str',
             'author_alert' => 'bool',
-            'author_alert_reason' => 'str'
+            'author_alert_reason' => 'str',
+            'attachment_key' => 'str'
         ]);
 
         /** @var \XF\Service\ProfilePost\Editor $editor */
@@ -180,6 +182,14 @@
             $editor->setMessage($input['message']);
         }
 
+        if (\XF::isApiBypassingPermissions() || $profilePost->canUploadAndManageAttachments())
+        {
+            $hash = $this->getAttachmentTempHashFromKey($input['attachment_key'],
+                'profile_post',
+                ['profile_post_id' => $profilePost->profile_post_id]);
+            $editor->setAttachmentHash($hash);
+        }
+
         if ($input['author_alert'] && $profilePost->canSendModeratorActionAlert())
         {
             $editor->setSendAlert(true, $input['author_alert_reason']);
Index: src/XF/Api/Controller/ProfilePostComment.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/src/XF/Api/Controller/ProfilePostComment.php b/src/XF/Api/Controller/ProfilePostComment.php
--- a/src/XF/Api/Controller/ProfilePostComment.php    (revision 6ce00c8cec20a3ace2f52da0f080383f0d3e8816)
+++ b/src/XF/Api/Controller/ProfilePostComment.php    (revision f2cc4406f471f1c052bfb1ec2703537a9a2cee8c)
@@ -37,6 +37,7 @@
      * @api-in str $message
      * @api-in bool $author_alert
      * @api-in bool $author_alert_reason
+     * @api-in str $attachment_key API attachment key to upload files. Attachment key context type must be profile_post_comment with context[profile_post_comment_id] set to this profile post comment ID.
      *
      * @api-out true $success
      * @api-out ProfilePostComment $comment
@@ -79,7 +80,8 @@
         $input = $this->filter([
             'message' => '?str',
             'author_alert' => 'bool',
-            'author_alert_reason' => 'str'
+            'author_alert_reason' => 'str',
+            'attachment_key' => 'str'
         ]);
 
         /** @var \XF\Service\ProfilePostComment\Editor $editor */
@@ -90,6 +92,14 @@
             $editor->setMessage($input['message']);
         }
 
+        if (\XF::isApiBypassingPermissions() || $comment->ProfilePost->canUploadAndManageAttachments())
+        {
+            $hash = $this->getAttachmentTempHashFromKey($input['attachment_key'],
+                'profile_post_comment',
+                ['profile_post_comment_id' => $comment->profile_post_comment_id]);
+            $editor->setAttachmentHash($hash);
+        }
+
         if ($input['author_alert'] && $comment->canSendModeratorActionAlert())
         {
             $editor->setSendAlert(true, $input['author_alert_reason']);
@@ -144,7 +154,7 @@
 
         return $this->apiSuccess();
     }
-   
+
     /**
      * @api-desc Reacts to the specified profile post comment
      *
@@ -153,7 +163,7 @@
     public function actionPostReact(ParameterBag $params)
     {
         $comment = $this->assertViewableProfilePostComment($params->profile_post_comment_id);
-       
+
         /** @var \XF\Api\ControllerPlugin\Reaction $reactPlugin */
         $reactPlugin = $this->plugin('XF:Api:Reaction');
         return $reactPlugin->actionReact($comment);
Index: src/XF/Api/Controller/ProfilePostComments.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/src/XF/Api/Controller/ProfilePostComments.php b/src/XF/Api/Controller/ProfilePostComments.php
--- a/src/XF/Api/Controller/ProfilePostComments.php    (revision 6ce00c8cec20a3ace2f52da0f080383f0d3e8816)
+++ b/src/XF/Api/Controller/ProfilePostComments.php    (revision f2cc4406f471f1c052bfb1ec2703537a9a2cee8c)
@@ -20,6 +20,7 @@
      *
      * @api-in int $profile_post_id <req> The ID of the profile post this comment will be attached to.
      * @api-in str $message <req>
+     * @api-in str $attachment_key API attachment key to upload files. Attachment key context type must be profile_post_comment with context[profile_post_id] set to this profile post ID.
      *
      * @api-out true $success
      * @api-out ProfilePostComment $comment
@@ -73,6 +74,15 @@
         $message = $this->filter('message', 'str');
         $creator->setContent($message);
 
+        if (\XF::isApiBypassingPermissions() || $profilePost->canUploadAndManageAttachments())
+        {
+            $attachmentKey = $this->filter('attachment_key', 'str');
+            $hash = $this->getAttachmentTempHashFromKey($attachmentKey,
+                'profile_post_comment',
+                ['profile_post_id' => $profilePost->profile_post_id]);
+            $creator->setAttachmentHash($hash);
+        }
+
         return $creator;
     }
 
Index: src/XF/Api/Controller/ProfilePosts.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/src/XF/Api/Controller/ProfilePosts.php b/src/XF/Api/Controller/ProfilePosts.php
--- a/src/XF/Api/Controller/ProfilePosts.php    (revision 6ce00c8cec20a3ace2f52da0f080383f0d3e8816)
+++ b/src/XF/Api/Controller/ProfilePosts.php    (revision f2cc4406f471f1c052bfb1ec2703537a9a2cee8c)
@@ -20,6 +20,7 @@
      *
      * @api-in int $user_id <req> The ID of the user whose profile this will be posted on.
      * @api-in str $message <req>
+     * @api-in str $attachment_key API attachment key to upload files. Attachment key context type must be profile_post with context[profile_user_id] set to this user ID.
      *
      * @api-out true $success
      * @api-out ProfilePost $profile_post
@@ -76,6 +77,15 @@
         $message = $this->filter('message', 'str');
         $creator->setContent($message);
 
+        if (\XF::isApiBypassingPermissions() || $user->canUploadAndManageAttachments())
+        {
+            $attachmentKey = $this->filter('attachment_key', 'str');
+            $hash = $this->getAttachmentTempHashFromKey($attachmentKey,
+                'profile_post',
+                ['profile_user_id' => $user->user_id]);
+            $creator->setAttachmentHash($hash);
+        }
+
         return $creator;
     }
 
Back
Top Bottom