BP_REST_Messages_Endpoint::get_item_schema()

Get the message schema, conforming to JSON Schema.

Description

Return

(array)

Source

File: bp-messages/classes/class-bp-rest-messages-endpoint.php

1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
public function get_item_schema() {
    $schema = array(
        '$schema'    => 'http://json-schema.org/draft-04/schema#',
        'title'      => 'bp_messages',
        'type'       => 'object',
        'properties' => array(
            'id'                  => array(
                'context'     => array( 'view', 'edit' ),
                'description' => __( 'A unique numeric ID for the Thread.', 'buddyboss' ),
                'type'        => 'integer',
            ),
            'message_id'          => array(
                'context'     => array( 'view', 'edit' ),
                'description' => __( 'The ID of the latest message of the Thread.', 'buddyboss' ),
                'readonly'    => true,
                'type'        => 'integer',
            ),
            'last_sender_id'      => array(
                'context'     => array( 'view', 'edit' ),
                'description' => __( 'The ID of latest sender of the Thread.', 'buddyboss' ),
                'readonly'    => true,
                'type'        => 'integer',
            ),
            'subject'             => array(
                'context'     => array( 'view', 'edit' ),
                'description' => __( 'Title of the latest message of the Thread.', 'buddyboss' ),
                'type'        => 'object',
                'arg_options' => array(
                    'sanitize_callback' => null,
                    'validate_callback' => null,
                ),
                'properties'  => array(
                    'raw'      => array(
                        'description' => __( 'Title of the latest message of the Thread, as it exists in the database.', 'buddyboss' ),
                        'type'        => 'string',
                        'context'     => array( 'edit' ),
                        'default'     => false,
                    ),
                    'rendered' => array(
                        'description' => __( 'Title of the latest message of the Thread, transformed for display.', 'buddyboss' ),
                        'type'        => 'string',
                        'context'     => array( 'view', 'edit' ),
                        'readonly'    => true,
                        'default'     => false,
                    ),
                ),
            ),
            'excerpt'             => array(
                'context'     => array( 'view', 'edit' ),
                'description' => __( 'Summary of the latest message of the Thread.', 'buddyboss' ),
                'type'        => 'object',
                'readonly'    => true,
                'arg_options' => array(
                    'sanitize_callback' => null,
                    'validate_callback' => null,
                ),
                'properties'  => array(
                    'raw'      => array(
                        'description' => __( 'Summary for the latest message of the Thread, as it exists in the database.', 'buddyboss' ),
                        'type'        => 'string',
                        'context'     => array( 'edit' ),
                    ),
                    'rendered' => array(
                        'description' => __( 'HTML summary for the latest message of the Thread, transformed for display.', 'buddyboss' ),
                        'type'        => 'string',
                        'context'     => array( 'view', 'edit' ),
                    ),
                ),
            ),
            'message'             => array(
                'context'     => array( 'view', 'edit' ),
                'description' => __( 'Content of the latest message of the Thread.', 'buddyboss' ),
                'type'        => 'object',
                'required'    => true,
                'arg_options' => array(
                    'sanitize_callback' => null,
                    'validate_callback' => null,
                ),
                'properties'  => array(
                    'raw'      => array(
                        'description' => __( 'Content for the latest message of the Thread, as it exists in the database.', 'buddyboss' ),
                        'type'        => 'string',
                        'context'     => array( 'edit' ),
                    ),
                    'rendered' => array(
                        'description' => __( 'HTML content for the latest message of the Thread, transformed for display.', 'buddyboss' ),
                        'type'        => 'string',
                        'context'     => array( 'view', 'edit' ),
                        'readonly'    => true,
                    ),
                ),
            ),
            'date'                => array(
                'context'     => array( 'view', 'edit' ),
                'description' => __( "The date the latest message of the Thread, in the site's timezone.", 'buddyboss' ),
                'readonly'    => true,
                'type'        => 'string',
                'format'      => 'date-time',
            ),
            'start_date'          => array(
                'context'     => array( 'view', 'edit' ),
                'description' => __( "The date the first message of the Thread, in the site's timezone.", 'buddyboss' ),
                'readonly'    => true,
                'type'        => 'string',
                'format'      => 'date-time',
            ),
            'unread_count'        => array(
                'context'     => array( 'view', 'edit' ),
                'description' => __( 'Total count of unread messages into the Thread for the requested user.', 'buddyboss' ),
                'readonly'    => true,
                'type'        => 'integer',
            ),
            'sender_ids'          => array(
                'context'     => array( 'view', 'edit' ),
                'description' => __( 'The list of user IDs for all messages in the Thread.', 'buddyboss' ),
                'readonly'    => true,
                'type'        => 'array',
                'items'       => array(
                    'type' => 'integer',
                ),
            ),
            'current_user'        => array(
                'context'     => array( 'view', 'edit' ),
                'description' => __( 'Current Logged in user\'s ID.', 'buddyboss' ),
                'readonly'    => true,
                'type'        => 'integer',
            ),
            'avatar'              => array(
                'context'     => array( 'view', 'edit' ),
                'description' => __( 'Avatar URLs for the author of the activity.', 'buddyboss' ),
                'type'        => 'object',
                'readonly'    => true,
                'properties'  => array(
                    'full'  => array(
                        'context'     => array( 'view', 'edit' ),
                        /* translators: 1: Full avatar width in pixels. 2: Full avatar height in pixels */
                        'description' => sprintf( __( 'Avatar URL with full image size (%1$d x %2$d pixels).', 'buddyboss' ), number_format_i18n( bp_core_avatar_full_width() ), number_format_i18n( bp_core_avatar_full_height() ) ),
                        'type'        => 'string',
                        'format'      => 'uri',
                    ),
                    'thumb' => array(
                        'context'     => array( 'view', 'edit' ),
                        /* translators: 1: Thumb avatar width in pixels. 2: Thumb avatar height in pixels */
                        'description' => sprintf( __( 'Avatar URL with thumb image size (%1$d x %2$d pixels).', 'buddyboss' ), number_format_i18n( bp_core_avatar_thumb_width() ), number_format_i18n( bp_core_avatar_thumb_height() ) ),
                        'type'        => 'string',
                        'format'      => 'uri',
                    ),
                ),
            ),
            'is_group'            => array(
                'context'     => array( 'view', 'edit' ),
                'description' => __( 'Group ID if message sent from group.', 'buddyboss' ),
                'readonly'    => true,
                'type'        => 'integer',
            ),
            'is_group_thread'     => array(
                'context'     => array( 'view', 'edit' ),
                'description' => __( 'Whether is a group thread or not.', 'buddyboss' ),
                'readonly'    => true,
                'type'        => 'boolean',
            ),
            'group_name'          => array(
                'context'     => array( 'view', 'edit' ),
                'description' => __( 'Group name if thread created from group.  ', 'buddyboss' ),
                'readonly'    => true,
                'type'        => 'string',
            ),
            'group_link'          => array(
                'context'     => array( 'view', 'edit' ),
                'description' => __( 'The permalink to the Group on the site.', 'buddyboss' ),
                'type'        => 'string',
                'format'      => 'uri',
                'readonly'    => true,
            ),
            'group_message_users' => array(
                'context'     => array( 'view', 'edit' ),
                'description' => __( 'Thread for all group users or selected one.', 'buddyboss' ),
                'type'        => 'string',
            ),
            'group_message_type'  => array(
                'context'     => array( 'view', 'edit' ),
                'description' => __( 'Thread type its from all or private one.', 'buddyboss' ),
                'type'        => 'string',
            ),
            'group_message_from'  => array(
                'context'     => array( 'view', 'edit' ),
                'description' => __( 'Message from group or not.', 'buddyboss' ),
                'type'        => 'string',
            ),
            'recipients_count'    => array(
                'context'     => array( 'view', 'edit' ),
                'description' => __( 'Recipient users count.', 'buddyboss' ),
                'type'        => 'integer',
            ),
            'recipients'          => array(
                'context'     => array( 'view', 'edit' ),
                'description' => __( 'The list of recipient User Objects involved into the Thread.', 'buddyboss' ),
                'type'        => 'array',
                'items'       => array(
                    'type' => 'object',
                ),
            ),
            'messages'            => array(
                'context'     => array( 'view', 'edit' ),
                'description' => __( 'List of message objects for the thread.', 'buddyboss' ),
                'readonly'    => true,
                'type'        => 'array',
                'items'       => array(
                    'type' => 'object',
                ),
            ),
            'starred_message_ids' => array(
                'context'     => array( 'view', 'edit' ),
                'description' => __( 'List of starred message IDs.', 'buddyboss' ),
                'readonly'    => true,
                'type'        => 'array',
                'items'       => array(
                    'type' => 'integer',
                ),
                'default'     => array(),
            ),
        ),
    );
 
    /**
     * Filters the message schema.
     *
     * @param array $schema The endpoint schema.
     *
     * @since 0.1.0
     */
    return apply_filters( 'bp_rest_message_schema', $this->add_additional_fields_schema( $schema ) );
}

Changelog

Changelog
Version Description
0.1.0 Introduced.

Questions?

We're always happy to help with code or other questions you might have! Search our developer docs, contact support, or connect with our sales team.