public void setConversationsRead ( final List < RespokeConversationReadStatus > updates , final Respoke . TaskCompletionListener completionListener ) { if ( ! isConnected ( ) ) { Respoke . postTaskError ( completionListener , "Can't complete request when not connected, " + "Please reconnect!" ) ; return ; } if ( ( updates == null ) || ( updates . size ( ) == 0 ) ) { Respoke . postTaskError ( completionListener , "At least 1 conversation must be specified" ) ; return ; } JSONObject body = new JSONObject ( ) ; JSONArray groupsJsonArray = new JSONArray ( ) ; try { // Add each status object to the array. for ( RespokeConversationReadStatus status : updates ) { JSONObject jsonStatus = new JSONObject ( ) ; jsonStatus . put ( "groupId" , status . groupId ) ; jsonStatus . put ( "timestamp" , status . timestamp . toString ( ) ) ; groupsJsonArray . put ( jsonStatus ) ; } // Set the array to the 'groups' property. body . put ( "groups" , groupsJsonArray ) ; } catch ( JSONException e ) { Respoke . postTaskError ( completionListener , "Error forming JSON body to send." ) ; return ; } String urlEndpoint = "/v1/endpoints/" + localEndpointID + "/conversations" ; signalingChannel . sendRESTMessage ( "put" , urlEndpoint , body , new RespokeSignalingChannel . RESTListener ( ) { @ Override public void onSuccess ( Object response ) { new Handler ( Looper . getMainLooper ( ) ) . post ( new Runnable ( ) { @ Override public void run ( ) { if ( completionListener != null ) { completionListener . onSuccess ( ) ; } } } ) ; } @ Override public void onError ( final String errorMessage ) { Respoke . postTaskError ( completionListener , errorMessage ) ; } } ) ; }
Mark messages in a conversation as having been read up to the given timestamp