Skip to:
Content

BuddyPress.org

Changeset 14058


Ignore:
Timestamp:
10/24/2024 06:29:17 PM (8 months ago)
Author:
imath
Message:

Document the Messages component v2 REST API routes

Props espellcaste

See #9145
Closes https://github.com/buddypress/buddypress/pull/388

Location:
trunk
Files:
1 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/docs/developer/execution-contexts/rest-api/reference.md

    r14047 r14058  
    2929| Group Membership Requests | `/buddypress/v2/groups/<group_id>/membership-request` |
    3030| Group Invites | `/buddypress/v2/groups/<group_id>/invites` |
    31 | Private Messaging | `/buddypress/v2/messages` |
     31| [Private Messaging](./messages.md) | `/buddypress/v2/messages` |
    3232| Screen Notifications | `/buddypress/v2/notifications` |
    3333| User Blogs | `/buddypress/v2/blogs` |
  • trunk/docs/developer/manifest.json

    r14047 r14058  
    193193    },
    194194    {
     195        "title": "Private Messaging REST API routes",
     196        "slug": "bp-rest-api-messages",
     197        "markdown_source": "../developer/execution-contexts/rest-api/messages.md",
     198        "parent": "bp-rest-api-reference"
     199    },
     200    {
    195201        "title": "BuddyPress Functions",
    196202        "slug": "bp-functions",
  • trunk/src/bp-messages/classes/class-bp-messages-rest-controller.php

    r14037 r14058  
    6363            $thread_endpoint,
    6464            array(
     65                'args'        => array(
     66                    'id' => array(
     67                        'description' => __( 'A unique numeric ID for the Thread.', 'buddypress' ),
     68                        'type'        => 'integer',
     69                    ),
     70                ),
    6571                array(
    6672                    'methods'             => WP_REST_Server::READABLE,
     
    11171123    public function get_endpoint_args_for_item_schema( $method = WP_REST_Server::CREATABLE ) {
    11181124        $args                      = parent::get_endpoint_args_for_item_schema( $method );
    1119         $args['id']['description'] = __( 'ID of the Messages Thread.', 'buddypress' );
     1125        $args['id']['description'] = __( 'A unique numeric ID for the Thread.', 'buddypress' );
    11201126
    11211127        if ( WP_REST_Server::CREATABLE === $method ) {
     
    11231129
    11241130            // Edit the Thread ID description and default properties.
    1125             $args['id']['description'] = __( 'ID of the Messages Thread. Required when replying to an existing Thread.', 'buddypress' );
     1131            $args['id']['description'] = __( 'A unique numeric ID for the Thread. Required when replying to an existing Thread.', 'buddypress' );
    11261132            $args['id']['default']     = 0;
    11271133
     
    11561162
    11571163        } else {
     1164            unset( $args['sender_id'], $args['subject'], $args['message'], $args['recipients'] );
     1165
     1166            $args['user_id'] = array(
     1167                'description'       => __( 'The user ID to get the thread for.', 'buddypress' ),
     1168                'required'          => false,
     1169                'type'              => 'integer',
     1170                'sanitize_callback' => 'absint',
     1171                'validate_callback' => 'rest_validate_request_arg',
     1172            );
     1173
    11581174            if ( WP_REST_Server::EDITABLE === $method ) {
     1175                unset( $args['message'], $args['recipients'], $args['subject'] );
    11591176                $key = 'update_item';
    11601177
     
    11881205            if ( WP_REST_Server::DELETABLE === $method ) {
    11891206                $key = 'delete_item';
    1190 
    1191                 $args['user_id'] = array(
    1192                     'description'       => __( 'The user ID to remove from the thread', 'buddypress' ),
    1193                     'required'          => true,
    1194                     'type'              => 'integer',
    1195                     'sanitize_callback' => 'absint',
    1196                     'validate_callback' => 'rest_validate_request_arg',
    1197                     'default'           => bp_loggedin_user_id(),
    1198                 );
    1199 
    1200                 unset( $args['sender_id'], $args['subject'], $args['message'], $args['recipients'] );
    12011207            }
    12021208
    12031209            if ( WP_REST_Server::READABLE === $method ) {
    1204                 unset( $args['sender_id'], $args['subject'], $args['message'], $args['recipients'] );
    1205 
    12061210                $key = 'get_item';
    1207 
    1208                 $args['user_id'] = array(
    1209                     'description'       => __( 'The user ID to get the thread for.', 'buddypress' ),
    1210                     'required'          => false,
    1211                     'type'              => 'integer',
    1212                     'sanitize_callback' => 'absint',
    1213                     'validate_callback' => 'rest_validate_request_arg',
    1214                 );
    12151211
    12161212                $args['recipients_page'] = array(
     
    12911287                        'context'     => array( 'view', 'edit' ),
    12921288                        'description' => __( 'A unique numeric ID for the Thread.', 'buddypress' ),
     1289                        'readonly'    => true,
    12931290                        'type'        => 'integer',
    12941291                    ),
     
    13761373                    'date'                => array(
    13771374                        'context'     => array( 'view', 'edit' ),
    1378                         'description' => __( 'Dat of the latest message of the Thread, in the site\'s timezone.', 'buddypress' ),
     1375                        'description' => __( 'Date of the latest message of the Thread, in the site\'s timezone.', 'buddypress' ),
    13791376                        'readonly'    => true,
    13801377                        'type'        => array( 'string', 'null' ),
     
    14051402                    'recipients'          => array(
    14061403                        'context'     => array( 'view', 'edit' ),
    1407                         'description' => __( 'The list of recipient User Objects involved into the Thread.', 'buddypress' ),
     1404                        'description' => __( 'The list of Avatar URLs for the recipient involved into the Thread.', 'buddypress' ),
    14081405                        'type'        => 'array',
    14091406                        'items'       => array(
Note: See TracChangeset for help on using the changeset viewer.