<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[BuddyPress][14058] trunk: Document the Messages component v2 REST API routes</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { white-space: pre-line; overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta" style="font-size: 105%">
<dt style="float: left; width: 6em; font-weight: bold">Revision</dt> <dd><a style="font-weight: bold" href="http://buddypress.trac.wordpress.org/changeset/14058">14058</a><script type="application/ld+json">{"@context":"http://schema.org","@type":"EmailMessage","description":"Review this Commit","action":{"@type":"ViewAction","url":"http://buddypress.trac.wordpress.org/changeset/14058","name":"Review Commit"}}</script></dd>
<dt style="float: left; width: 6em; font-weight: bold">Author</dt> <dd>imath</dd>
<dt style="float: left; width: 6em; font-weight: bold">Date</dt> <dd>2024-10-24 18:29:17 +0000 (Thu, 24 Oct 2024)</dd>
</dl>
<pre style='padding-left: 1em; margin: 2em 0; border-left: 2px solid #ccc; line-height: 1.25; font-size: 105%; font-family: sans-serif'>Document the Messages component v2 REST API routes
Props espellcaste
See <a href="http://buddypress.trac.wordpress.org/ticket/9145">#9145</a>
Closes https://github.com/buddypress/buddypress/pull/388</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkdocsdeveloperexecutioncontextsrestapireferencemd">trunk/docs/developer/execution-contexts/rest-api/reference.md</a></li>
<li><a href="#trunkdocsdevelopermanifestjson">trunk/docs/developer/manifest.json</a></li>
<li><a href="#trunksrcbpmessagesclassesclassbpmessagesrestcontrollerphp">trunk/src/bp-messages/classes/class-bp-messages-rest-controller.php</a></li>
</ul>
<h3>Added Paths</h3>
<ul>
<li><a href="#trunkdocsdeveloperexecutioncontextsrestapimessagesmd">trunk/docs/developer/execution-contexts/rest-api/messages.md</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkdocsdeveloperexecutioncontextsrestapimessagesmd"></a>
<div class="addfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Added: trunk/docs/developer/execution-contexts/rest-api/messages.md</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/docs/developer/execution-contexts/rest-api/messages.md (rev 0)
+++ trunk/docs/developer/execution-contexts/rest-api/messages.md 2024-10-24 18:29:17 UTC (rev 14058)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -0,0 +1,282 @@
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+# Private Messaging REST API routes
+
+The Private Messaging component allow your users to talk to each other directly and in private. It’s not just limited to one-on-one discussions, private conversations can involve any number of members.
+
+> [!IMPORTANT]
+> The Private Messaging component is an optional one. This means the following endpoints will only be available if the component is active on the community site.
+
+## Schema
+
+The schema defines all the fields that exist for a Thread object.
+
+| Property | Description |
+| --- | --- |
+| `id` | A unique numeric ID for the Thread. <br />JSON data type: _integer_. <br />Read only. <br />Context: `view`, `edit`. |
+| `message_id` | The ID of the latest message of the Thread. <br />JSON data type: _integer_. <br />Read only. <br />Context: `view`, `edit`. |
+| `last_sender_id` | The ID of latest sender of the Thread. <br />JSON data type: _integer_. <br />Read only. <br />Context: `view`, `edit`. |
+| `subject` | Title of the latest message of the Thread. <br />JSON data type: _object_ (properties: `raw`, `rendered` ). <br />Context: `view`, `edit`. |
+| `excerpt` | Summary of the latest message of the Thread. <br />JSON data type: _object_ (properties: `raw`, `rendered` ). <br />Read only. <br />Context: `view`, `edit`. |
+| `message` | Content of the latest message of the Thread. <br />JSON data type: _object_ (properties: `raw`, `rendered` ). <br />**Required**. <br />Context: `view`, `edit`. |
+| `date` | Date of the latest message of the Thread, in the site's timezone. <br />JSON data type: _string_ \| _null_, format: _date-time_. <br />Read only. <br />Context: `view`, `edit`. |
+| `date_gmt` | Date of the latest message of the Thread, as GMT. <br />JSON data type: _string_ \| _null_, format: _date-time_. <br />Read only. <br />Context: `view`, `edit`. |
+| `unread_count` | Total count of unread messages into the Thread for the requested user. <br />JSON data type: _integer_. <br />Read only. <br />Context: `view`, `edit`. |
+| `sender_ids` | The list of user IDs for all messages in the Thread. <br />JSON data type: _array_. <br />Read only. <br />Context: `view`, `edit`. |
+| `recipients` | The list of Avatar[^1] URL objects (full, thumb) for the recipient involved into the Thread. <br />JSON data type: _array_. <br />Context: `view`, `edit`. |
+| `messages` | List of message objects for the thread. <br />JSON data type: _array_. <br />Read only. <br />Context: `view`, `edit`. |
+| `starred_message_ids` | List of starred message IDs. <br />JSON data type: _array_. <br />Read only. <br />Context: `view`, `edit`. |
+
+## List Activities
+
+Only logged in users will be able to fetch the threads they are involved in. Administrators can also fetch another user's threads.
+
+### Arguments
+
+| Name | Description |
+| --- | --- |
+| `context` | Scope under which the request is made; determines fields present in response. <br />JSON data type: _string_. <br/>Default: `view`. <br/>One of: `view`, `edit`. |
+| `page` | Current page of the threads collection. <br />JSON data type: _integer_. <br />Default: `1`. |
+| `per_page` | Maximum number of threads to be returned in result set. <br />JSON data type: _integer_. <br />Default: `10`. <br />Min.: `1`, Max.: `100`. |
+| `messages_page` | Current page of the messages collection. <br />JSON data type: _integer_. <br />Default: `1`. <br />Min.: `1`. |
+| `messages_per_page` | Maximum number of messages to be returned in result set. <br />JSON data type: _integer_. <br />Default: `10`. <br />Min.: `1`, Max.: `100`. |
+| `recipients_page` | Current page of the recipients collection. <br />JSON data type: _integer_. <br />Default: `1`. <br />Min.: `1`. |
+| `recipients_per_page` | Maximum number of recipients to be returned in result set. <br />JSON data type: _integer_. <br />Default: `10`. <br />Min.: `1`, Max.: `100`. |
+| `search` | Limit results to those matching a string. <br />JSON data type: _string_. |
+| `type` | Filter the result by thread status. <br />JSON data type: _string_. <br />One of: `read`, `unread`, `all`. <br />Default: `all`. |
+| `user_id` | Limit result set to activity items created by a specific user (ID). <br />JSON data type: _integer_. <br />Default: `0`. |
+| `box` | Filter the result by box. <br />JSON data type: _string_. <br />One of: `sentbox`, `inbox`, `starred`. <br />Default: `inbox`. |
+
+### Definition
+
+`GET /buddypress/v2/messages`
+
+### Example of use
+
+> [!WARNING]
+> The `requestHeaders` object needs to be set according to the WordPress REST API nonce. Read more about the [REST API authentification](./README.md#about-authentification).
+
+```javascript
+fetch( '/wp-json/buddypress/v2/messages?context=view&box=sentbox', {
+ method: 'GET',
+ headers: requestHeaders,
+} ).then( ( response ) => {
+ return response.json();
+} ).then( ( data ) => {
+ console.table( data );
+} );
+```
+
+### JSON Response
+
+- An array of objects representing the matching thread items on success.
+- An object containg the error code, data and message on failure.
+
+## Start a new Messages Thread or reply to an existing one
+
+Only logged in users will be able to init a new thread or reply to an existing one.
+
+### Arguments
+
+| Name | Description |
+| --- | --- |
+| `id` | A unique numeric ID for the Thread. Required when replying to an existing Thread. <br />JSON data type: _integer_. <br />Default: `0`. |
+| `message` | Content of the Message to add to the Thread. <br />JSON data type: _string_. <br />**Required**. |
+| `recipients` | The list of the recipients user IDs of the Message. <br />JSON data type: _array_. <br />**Required**. |
+| `sender_id` | The user ID of the Message sender. <br />JSON data type: _integer_. <br />Default: the ID of the logged in member. |
+| `subject` | Subject of the Message initializing the Thread. <br />JSON data type: _string_. <br />Default: `false`. |
+
+### Definition
+
+`POST /buddypress/v2/messages`
+
+### Example of use
+
+> [!WARNING]
+> The `requestHeaders` object needs to be set according to the WordPress REST API nonce. Read more about the [REST API authentification](./README.md#about-authentification).
+
+```javascript
+fetch( '/wp-json/buddypress/v2/messages', {
+ method: 'POST',
+ headers: requestHeaders,
+ body: JSON.stringify(
+ {
+ message: 'bapuu is the BuddyPress wapuu',
+ recipients: [ 2, 3 ],
+ }
+ ),
+} ).then( ( response ) => {
+ return response.json();
+} ).then( ( data ) => {
+ console.log( data );
+} );
+```
+
+### JSON Response
+
+- An object representing the created thread item or the thread reply on success.
+- An object containg the error code, data and message on failure.
+
+## Retrieve a specific Messages Thread
+
+Only logged in users will be able to fetch a thread they are involved in. Administrators can also fetch another user's thread.
+
+### Arguments
+
+| Name | Description |
+| --- | --- |
+| `id` | A unique numeric ID for the Thread. **Required**. <br />JSON data type: _integer_. |
+| `messages_page` | Current page of the messages collection. <br />JSON data type: _integer_. <br />Default: `1`. <br />Min.: `1`. |
+| `messages_per_page` | Maximum number of messages to be returned in result set. <br />JSON data type: _integer_. <br />Default: `10`. <br />Min.: `1`, Max.: `100`. |
+| `recipients_page` | Current page of the recipients collection. <br />JSON data type: _integer_. <br />Default: `1`. <br />Min.: `1`. |
+| `recipients_per_page` | Maximum number of recipients to be returned in result set. <br />JSON data type: _integer_. <br />Default: `10`. <br />Min.: `1`, Max.: `100`. |
+| `user_id` | The user ID to get the thread for. <br />JSON data type: _integer_. |
+| `order` | Order sort attribute ascending or descending. <br />JSON data type: _string_. <br />One of: `asc`, `desc`. <br />Default: `asc`. |
+
+### Definition
+
+`GET /buddypress/v2/messages/<id>`
+
+### Example of use
+
+> [!WARNING]
+> The `requestHeaders` object needs to be set according to the WordPress REST API nonce. Read more about the [REST API authentification](./README.md#about-authentification).
+
+```javascript
+fetch( '/wp-json/buddypress/v2/messages/2', {
+ method: 'GET',
+ headers: requestHeaders,
+} ).then( ( response ) => {
+ return response.json();
+} ).then( ( data ) => {
+ console.log( data );
+} );
+```
+
+### JSON Response
+
+- An object representing the requested thread.
+- An object containg the error code, data and message on failure.
+
+## Update metadata about a specific message of the Thread
+
+### Arguments
+
+| Name | Description |
+| --- | --- |
+| `id` | A unique numeric ID for the Thread. **Required**. <br />JSON data type: _integer_. |
+| `message_id` | By default the latest message of the thread will be updated. Specify this message ID to edit another message of the thread. <br />JSON data type: _integer_. |
+| `read` | Whether to mark the thread as read. <br />JSON data type: _boolean_. <br /> Default: `false` |
+| `unread` | Whether to mark the thread as unread. <br />JSON data type: _boolean_. <br /> Default: `false` |
+| `user_id` | The user ID to get the thread for. <br />JSON data type: _integer_. |
+
+### Definition
+
+`PUT /buddypress/v2/messages/<id>`
+
+### Example of use
+
+> [!WARNING]
+> The `requestHeaders` object needs to be set according to the WordPress REST API nonce. Read more about the [REST API authentification](./README.md#about-authentification).
+
+```javascript
+fetch( '/wp-json/buddypress/v2/messages/2', {
+ method: 'PUT',
+ headers: requestHeaders,
+ body: JSON.stringify(
+ {
+ user_id: 2,
+ read: true,
+ }
+ ),
+} ).then( ( response ) => {
+ return response.json();
+} ).then( ( data ) => {
+ console.log( data );
+} );
+```
+
+### JSON Response
+
+- An object representing the updated thread on success.
+- An object containg the error code, data and message on failure.
+
+## Delete a specific Messages Thread for a user
+
+> [!NOTE]
+> When users request to delete a Messages Thread, they are removed from the list of recipients. As soon as the recipients list is empty, the Messages Thread is fully deleted from the database.
+
+### Arguments
+
+| Name | Description |
+| --- | --- |
+| `id` | A unique numeric ID for the activity item. **Required**. <br />JSON data type: _integer_. |
+| `user_id` | The user ID to get the thread for. <br />JSON data type: _integer_. |
+
+### Definition
+
+`DELETE /buddypress/v2/messages/<id>`
+
+### Example of use
+
+> [!WARNING]
+> The `requestHeaders` object needs to be set according to the WordPress REST API nonce. Read more about the [REST API authentification](./README.md#about-authentification).
+
+```javascript
+fetch( '/wp-json/buddypress/v2/messages/2', {
+ method: 'DELETE',
+ headers: requestHeaders,
+ body: JSON.stringify(
+ {
+ user_id: 2,
+ }
+ ),
+} ).then( ( response ) => {
+ return response.json();
+} ).then( ( data ) => {
+ console.log( data );
+} );
+```
+
+### JSON Response
+
+- An object informing about the `deleted` status and the `previous` thread item on success.
+- An object containg the error code, data and message on failure.
+
+## Star or unstar a specific message of a Thread
+
+Logged in users can star/unstar a specific message of a Thread`.
+
+### Arguments
+
+| Name | Description |
+| --- | --- |
+| `id` | The ID of the a specific message of the Thread. **Required**. <br />JSON data type: _integer_. |
+
+> [!IMPORTANT]
+> The ID here is not a Messages Thread ID. It’s the ID of a specific message of the Messages Thread.
+
+### Definition
+
+`PUT /buddypress/v2/messages/starred/<id>`
+
+### Example of use
+
+> [!WARNING]
+> The `requestHeaders` object needs to be set according to the WordPress REST API nonce. Read more about the [REST API authentification](./README.md#about-authentification).
+
+```javascript
+fetch( '/wp-json/buddypress/v2/messages/starred/2', {
+ method: 'POST',
+ headers: requestHeaders,
+} ).then( ( response ) => {
+ return response.json();
+} ).then( ( data ) => {
+ console.log( data );
+} );
+```
+
+### JSON Response
+
+- An object representing the thread item on success.
+- An object containg the error code, data and message on failure.
+
+[^1]: This property is only available if the WordPress discussion settings allow avatars.
</ins></span></pre></div>
<a id="trunkdocsdeveloperexecutioncontextsrestapireferencemd"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/docs/developer/execution-contexts/rest-api/reference.md</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/docs/developer/execution-contexts/rest-api/reference.md 2024-10-22 23:04:18 UTC (rev 14057)
+++ trunk/docs/developer/execution-contexts/rest-api/reference.md 2024-10-24 18:29:17 UTC (rev 14058)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -28,7 +28,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> | Group Membership | `/buddypress/v2/groups/<group_id>/members` |
</span><span class="cx" style="display: block; padding: 0 10px"> | Group Membership Requests | `/buddypress/v2/groups/<group_id>/membership-request` |
</span><span class="cx" style="display: block; padding: 0 10px"> | Group Invites | `/buddypress/v2/groups/<group_id>/invites` |
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-| Private Messaging | `/buddypress/v2/messages` |
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+| [Private Messaging](./messages.md) | `/buddypress/v2/messages` |
</ins><span class="cx" style="display: block; padding: 0 10px"> | Screen Notifications | `/buddypress/v2/notifications` |
</span><span class="cx" style="display: block; padding: 0 10px"> | User Blogs | `/buddypress/v2/blogs` |
</span><span class="cx" style="display: block; padding: 0 10px"> | Blog Profile Photo | `/buddypress/v2/blogs/<id>/avatar` |
</span></span></pre></div>
<a id="trunkdocsdevelopermanifestjson"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/docs/developer/manifest.json</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/docs/developer/manifest.json 2024-10-22 23:04:18 UTC (rev 14057)
+++ trunk/docs/developer/manifest.json 2024-10-24 18:29:17 UTC (rev 14058)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -192,6 +192,12 @@
</span><span class="cx" style="display: block; padding: 0 10px"> "parent": "bp-rest-api-reference"
</span><span class="cx" style="display: block; padding: 0 10px"> },
</span><span class="cx" style="display: block; padding: 0 10px"> {
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ "title": "Private Messaging REST API routes",
+ "slug": "bp-rest-api-messages",
+ "markdown_source": "../developer/execution-contexts/rest-api/messages.md",
+ "parent": "bp-rest-api-reference"
+ },
+ {
</ins><span class="cx" style="display: block; padding: 0 10px"> "title": "BuddyPress Functions",
</span><span class="cx" style="display: block; padding: 0 10px"> "slug": "bp-functions",
</span><span class="cx" style="display: block; padding: 0 10px"> "markdown_source": "../developer/functions/README.md",
</span></span></pre></div>
<a id="trunksrcbpmessagesclassesclassbpmessagesrestcontrollerphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/bp-messages/classes/class-bp-messages-rest-controller.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/bp-messages/classes/class-bp-messages-rest-controller.php 2024-10-22 23:04:18 UTC (rev 14057)
+++ trunk/src/bp-messages/classes/class-bp-messages-rest-controller.php 2024-10-24 18:29:17 UTC (rev 14058)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -62,6 +62,12 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $this->namespace,
</span><span class="cx" style="display: block; padding: 0 10px"> $thread_endpoint,
</span><span class="cx" style="display: block; padding: 0 10px"> array(
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'args' => array(
+ 'id' => array(
+ 'description' => __( 'A unique numeric ID for the Thread.', 'buddypress' ),
+ 'type' => 'integer',
+ ),
+ ),
</ins><span class="cx" style="display: block; padding: 0 10px"> array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'methods' => WP_REST_Server::READABLE,
</span><span class="cx" style="display: block; padding: 0 10px"> 'callback' => array( $this, 'get_item' ),
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1116,13 +1122,13 @@
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function get_endpoint_args_for_item_schema( $method = WP_REST_Server::CREATABLE ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $args = parent::get_endpoint_args_for_item_schema( $method );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $args['id']['description'] = __( 'ID of the Messages Thread.', 'buddypress' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $args['id']['description'] = __( 'A unique numeric ID for the Thread.', 'buddypress' );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> if ( WP_REST_Server::CREATABLE === $method ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $key = 'create_item';
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Edit the Thread ID description and default properties.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $args['id']['description'] = __( 'ID of the Messages Thread. Required when replying to an existing Thread.', 'buddypress' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $args['id']['description'] = __( 'A unique numeric ID for the Thread. Required when replying to an existing Thread.', 'buddypress' );
</ins><span class="cx" style="display: block; padding: 0 10px"> $args['id']['default'] = 0;
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Add the sender_id argument.
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1155,7 +1161,18 @@
</span><span class="cx" style="display: block; padding: 0 10px"> unset( $args['subject']['properties'], $args['message']['properties'] );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> } else {
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ unset( $args['sender_id'], $args['subject'], $args['message'], $args['recipients'] );
+
+ $args['user_id'] = array(
+ 'description' => __( 'The user ID to get the thread for.', 'buddypress' ),
+ 'required' => false,
+ 'type' => 'integer',
+ 'sanitize_callback' => 'absint',
+ 'validate_callback' => 'rest_validate_request_arg',
+ );
+
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( WP_REST_Server::EDITABLE === $method ) {
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ unset( $args['message'], $args['recipients'], $args['subject'] );
</ins><span class="cx" style="display: block; padding: 0 10px"> $key = 'update_item';
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $args['read'] = array(
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1187,32 +1204,11 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> if ( WP_REST_Server::DELETABLE === $method ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $key = 'delete_item';
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-
- $args['user_id'] = array(
- 'description' => __( 'The user ID to remove from the thread', 'buddypress' ),
- 'required' => true,
- 'type' => 'integer',
- 'sanitize_callback' => 'absint',
- 'validate_callback' => 'rest_validate_request_arg',
- 'default' => bp_loggedin_user_id(),
- );
-
- unset( $args['sender_id'], $args['subject'], $args['message'], $args['recipients'] );
</del><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> if ( WP_REST_Server::READABLE === $method ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- unset( $args['sender_id'], $args['subject'], $args['message'], $args['recipients'] );
-
</del><span class="cx" style="display: block; padding: 0 10px"> $key = 'get_item';
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $args['user_id'] = array(
- 'description' => __( 'The user ID to get the thread for.', 'buddypress' ),
- 'required' => false,
- 'type' => 'integer',
- 'sanitize_callback' => 'absint',
- 'validate_callback' => 'rest_validate_request_arg',
- );
-
</del><span class="cx" style="display: block; padding: 0 10px"> $args['recipients_page'] = array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'description' => __( 'Current page of the recipients collection.', 'buddypress' ),
</span><span class="cx" style="display: block; padding: 0 10px"> 'type' => 'integer',
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1290,6 +1286,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> 'id' => array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'context' => array( 'view', 'edit' ),
</span><span class="cx" style="display: block; padding: 0 10px"> 'description' => __( 'A unique numeric ID for the Thread.', 'buddypress' ),
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'readonly' => true,
</ins><span class="cx" style="display: block; padding: 0 10px"> 'type' => 'integer',
</span><span class="cx" style="display: block; padding: 0 10px"> ),
</span><span class="cx" style="display: block; padding: 0 10px"> 'message_id' => array(
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1375,7 +1372,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> ),
</span><span class="cx" style="display: block; padding: 0 10px"> 'date' => array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'context' => array( 'view', 'edit' ),
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'description' => __( 'Dat of the latest message of the Thread, in the site\'s timezone.', 'buddypress' ),
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'description' => __( 'Date of the latest message of the Thread, in the site\'s timezone.', 'buddypress' ),
</ins><span class="cx" style="display: block; padding: 0 10px"> 'readonly' => true,
</span><span class="cx" style="display: block; padding: 0 10px"> 'type' => array( 'string', 'null' ),
</span><span class="cx" style="display: block; padding: 0 10px"> 'format' => 'date-time',
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1404,7 +1401,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> ),
</span><span class="cx" style="display: block; padding: 0 10px"> 'recipients' => array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'context' => array( 'view', 'edit' ),
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'description' => __( 'The list of recipient User Objects involved into the Thread.', 'buddypress' ),
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'description' => __( 'The list of Avatar URLs for the recipient involved into the Thread.', 'buddypress' ),
</ins><span class="cx" style="display: block; padding: 0 10px"> 'type' => 'array',
</span><span class="cx" style="display: block; padding: 0 10px"> 'items' => array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'type' => 'object',
</span></span></pre>
</div>
</div>
</body>
</html>