Class Socialveo\WebApi\Controllers\ChatController

InheritanceSocialveo\WebApi\Controllers\ChatController » Socialveo\WebApi\Controllers\RestApiController » Phalcon\Mvc\Controller
Uses TraitsSocialveo\Core\Translatable

Class ChatController

Public Methods

Hide inherited methods

MethodDescriptionDefined By
_handleException() Handle exceptions Socialveo\WebApi\Controllers\RestApiController
_t() Gets translations Socialveo\Core\Translatable
afterExecuteRoute() After execute route, change return value to json Socialveo\WebApi\Controllers\RestApiController
beforeExecuteRoute() Before execute route, remove extra params Socialveo\WebApi\Controllers\RestApiController
checkClientCredentials() Checks client credentials Socialveo\WebApi\Controllers\RestApiController
createDialogAction() Create dialog to user Socialveo\WebApi\Controllers\ChatController
createMessageAction() Create a message Socialveo\WebApi\Controllers\ChatController
decrypt() Decrypt value Socialveo\WebApi\Controllers\RestApiController
dialogAction() Get dialog Socialveo\WebApi\Controllers\ChatController
dialogUsersAction() Returns users of dialog Socialveo\WebApi\Controllers\ChatController
encrypt() Encrypt value Socialveo\WebApi\Controllers\RestApiController
getArrayFromParam() Returns array from params Socialveo\WebApi\Controllers\RestApiController
getLanguage() Gets language code Socialveo\WebApi\Controllers\RestApiController
getParams() Gets request params for Socialveo::filteredFind() Socialveo\WebApi\Controllers\RestApiController
getRequestData() Returns request data Socialveo\WebApi\Controllers\RestApiController
getRequiredParam() Get required param Socialveo\WebApi\Controllers\RestApiController
getToken() Get token Socialveo\WebApi\Controllers\RestApiController
getTranslation() Gets translations Socialveo\WebApi\Controllers\RestApiController
handleError() Handle errors Socialveo\WebApi\Controllers\RestApiController
handleException() Handle exceptions Socialveo\WebApi\Controllers\RestApiController
initialize() Initialize controller Socialveo\WebApi\Controllers\RestApiController
invalidMethodAction() Action trigger when invalid action tried run Socialveo\WebApi\Controllers\RestApiController
inviteAction() Add user to group chat dialog Socialveo\WebApi\Controllers\ChatController
leaveDialogAction() Leave chat dialog Socialveo\WebApi\Controllers\ChatController
listAllMessagesAction() Returns messages Socialveo\WebApi\Controllers\ChatController
listDialogsAction() Get user chat dialogs Socialveo\WebApi\Controllers\ChatController
listMessagesAction() Returns messages of the dialog Socialveo\WebApi\Controllers\ChatController
messageAction() Returns message Socialveo\WebApi\Controllers\ChatController
notFoundAction() Not found action Socialveo\WebApi\Controllers\RestApiController
posts() Gets posts Socialveo\WebApi\Controllers\RestApiController
replaceParam() Replace param Socialveo\WebApi\Controllers\RestApiController
respondWithItem() Response with item // * @deprecated Socialveo\WebApi\Controllers\RestApiController
sendJsonContent() Send response as json content and exit Socialveo\WebApi\Controllers\RestApiController
sendJsonContentRaw() Send json content Socialveo\WebApi\Controllers\RestApiController
sendJsonContentRawStatic() Send json content static Socialveo\WebApi\Controllers\RestApiController
setDefaultParam() Set default option Socialveo\WebApi\Controllers\RestApiController
t() Gets translations Socialveo\Core\Translatable
touchDialogAction() Touch dialog (marks dialog as read, removes notifications about unread messages) Socialveo\WebApi\Controllers\ChatController
unreadMessagesAction() Get unread messages of dialog Socialveo\WebApi\Controllers\ChatController
unsetParam() Unset get param Socialveo\WebApi\Controllers\RestApiController
userDialogAction() Get or create (if it not exists) private dialog with user Socialveo\WebApi\Controllers\ChatController

Protected Methods

Hide inherited methods

MethodDescriptionDefined By
checkAccess() Checks during the init of controller whether user is a guest. Socialveo\WebApi\Controllers\RestApiController
log() Log full request data for debug Socialveo\WebApi\Controllers\RestApiController
objectsToArray() Convert objects to arrays Socialveo\WebApi\Controllers\RestApiController
privateDialogFor() Get or create private dialog for user Socialveo\WebApi\Controllers\ChatController

Method Details

createDialogAction() public method

Create dialog to user

/chat/dialogs/create

Method: POST

Access: Logged && UserHasAccessUuids

Parameters:

user_uuids required string or array coma separated user uuids or array
language optional string language code

Affects: MessagesDialogs , Notification

Returns: MessagesDialogs

Note. For avoiding multiple private chats between users, private chat will be created only once for each user.

Sample response:

{
    "status": "OK",
    "data":[
        "type": "messages_dialogs",
        "uuid": "9f01a8d8-6f85-11e7-9eb6-54bef75c7a3f",
        "user_uuid": "a479b438-14a8-11e6-ac83-54bef75c7a3f",
        "to_user_uuid": "a479b438-14a8-11e6-ac83-54bef75c7a3f",
        ...
    ],
    "timestamp": 1234567890
}

public mixed createDialogAction ( )
throws Exception
createMessageAction() public method

Create a message

/chat/dialogs/({dialog_uuid})/messages/create

Method: POST

Access: LoggedUserHasAccess

Parameters:

{dialog_uuid} required string dialog uuid
attributes optional mixed Messages attributes
language optional string language code

Affects: Messages

Returns: Messages

Sample response:

{
    "status": "OK",
    "data":[
        "type": "messages",
        "uuid": "9f01a8d8-6f85-11e7-9eb6-54bef75c7a3f",
        "user_uuid": "a479b438-14a8-11e6-ac83-54bef75c7a3f",
        "to_user_uuid": "a479b438-14a8-11e6-ac83-54bef75c7a3f",
        ...
    ],
    "timestamp": 1234567890
}

public mixed createMessageAction ( $dialog_uuid )
$dialog_uuid string

Dialog uuuid

throws Exception
dialogAction() public method

Get dialog

/chat/dialogs/{dialog_uuid}

Method: GET

Access: Logged && UserHasAccess

Parameters:

{dialog_uuid} required string dialog uuid
language optional string language code

Returns: MessagesDialogs

Sample response:

{
    "status": "OK",
    "data":[
        "type": "messages_dialogs",
        "uuid": "9f01a8d8-6f85-11e7-9eb6-54bef75c7a3f",
        "user_uuid": "a479b438-14a8-11e6-ac83-54bef75c7a3f",
        "to_user_uuid": "a479b438-14a8-11e6-ac83-54bef75c7a3f",
        ...
    ],
    "timestamp": 1234567890
}

public mixed dialogAction ( $dialog_uuid )
$dialog_uuid string

Dialog uuid

dialogUsersAction() public method

Returns users of dialog

/chat/dialogs/{dialog_uuid}/users

Method: GET

Access: Logged && UserHasAccess

Parameters:

{dialog_uuid} required string dialog uuid
language optional string language code

Returns: User []

Sample response:

{
    "status": "OK",
    "data":[
        "type": "messages_dialogs",
        "uuid": "9f01a8d8-6f85-11e7-9eb6-54bef75c7a3f",
        "user_uuid": "a479b438-14a8-11e6-ac83-54bef75c7a3f",
        "to_user_uuid": "a479b438-14a8-11e6-ac83-54bef75c7a3f",
        ...
    ],
    "timestamp": 1234567890
}

public mixed dialogUsersAction ( $dialog_uuid )
$dialog_uuid string

Dialog uuid

inviteAction() public method

Add user to group chat dialog

/chat/dialogs/{dialog_uuid}/users/add

Method: POST

Access: Logged && UserHasAccess && UserHasAccessUuids

Parameters:

{dialog_uuid} required string dialog uuid
user_uuids[] required string or array coma separated user uuids or array
language optional string language code

Returns: MessagesDialogs

Sample response:

{
    "status": "OK",
    "data":[
        "type": "messages_dialogs",
        "uuid": "9f01a8d8-6f85-11e7-9eb6-54bef75c7a3f",
        "user_uuid": "a479b438-14a8-11e6-ac83-54bef75c7a3f",
        "to_user_uuid": "a479b438-14a8-11e6-ac83-54bef75c7a3f",
        ...
    ],
    "timestamp": 1234567890
}

public mixed inviteAction ( $dialog_uuid )
$dialog_uuid string

Dialog uuid

throws Exception
leaveDialogAction() public method

Leave chat dialog

/chat/dialogs/{dialog_uuid}/leave

Method: POST

Access: Logged && UserHasAccess

Parameters:

{dialog_uuid} required string dialog uuid
language optional string language code

Returns: MessagesDialogs

Sample response:

{
    "status": "OK",
    "timestamp": 1234567890
}

public mixed leaveDialogAction ( $dialog_uuid )
$dialog_uuid string

Dialog uuid

listAllMessagesAction() public method

Returns messages

Notice. This action is disabled, the reasons can be: not implemented, unsafe, duplicated or deprecated (autodetect: disabled in the router)
/chat/messages

Method: GET

Access: Logged

Parameters:

{dialog_uuid} required string dialog uuid
page or offset optional integer page start or offset
limit optional integer page limit
sortby[property]=order optional array sort by property value, order either desc or asc
filterby[property][operator]=value optional array filter (limit results) by given property, operator eq (=), gt (>), ge(>=), lt(<), le(<=), ne(<>), like
language optional string language code

Filter by: Messages

Returns: Messages []

Sample response:

{
    "status": "OK",
    "data":[
        {"type": "messages", "uuid": "cd2a302a-6f8c-11e7-925e-54bef75c7a3f", "user_uuid": "4622f77e-27f8-11e6-98d1-54bef75c7a3f",…},
        {"type": "messages", "uuid": "ced02cae-6f8c-11e7-827f-54bef75c7a3f", "user_uuid": "4622f77e-27f8-11e6-98d1-54bef75c7a3f",…},
        {"type": "messages", "uuid": "d396b8fc-6f8c-11e7-ae4e-54bef75c7a3f", "user_uuid": "4622f77e-27f8-11e6-98d1-54bef75c7a3f",…},
        {"type": "messages", "uuid": "d77f22ba-6f8c-11e7-b484-54bef75c7a3f", "user_uuid": "4622f77e-27f8-11e6-98d1-54bef75c7a3f",…}
        ...
    ],
    "count":{"offset": 0, "limit": 10, "total": 5},
    "timestamp": 1234567890
}

public mixed listAllMessagesAction ( )
listDialogsAction() public method

Get user chat dialogs

/chat/dialogs

Method: GET

Access: Logged

Parameters:

page or offset optional integer page start or offset
limit optional integer page limit
sortby[property]=order optional array sort by property value, order either desc or asc
filterby[property][operator]=value optional array filter (limit results) by given property, operator eq (=), gt (>), ge(>=), lt(<), le(<=), ne(<>), like
language optional string language code

Filter by: MessagesDialogs

Returns: MessagesDialogs []

Sample response:

{
    "status": "OK",
    "data":[
        {"type": "messages_dialogs", "uuid": "ee5074c6-4822-11e7-86ee-54bef75c7a3f", "user_uuid": "a479b438-14a8-11e6-ac83-54bef75c7a3f",…},
        {"type": "messages_dialogs", "uuid": "d196d738-d53d-11e6-9795-54bef75c7a3f", "user_uuid": "a479b438-14a8-11e6-ac83-54bef75c7a3f",…},
        {"type": "messages_dialogs", "uuid": "9e5137b0-d53d-11e6-98db-54bef75c7a3f", "user_uuid": "a479b438-14a8-11e6-ac83-54bef75c7a3f",…},
        {"type": "messages_dialogs", "uuid": "8c248c70-d53a-11e6-81a9-54bef75c7a3f", "user_uuid": "a479b438-14a8-11e6-ac83-54bef75c7a3f",…},
        ...
    ],
    "count":{"offset": 0, "limit": 10, "total": 12},
    "timestamp": 1234567890
}

public mixed listDialogsAction ( )
listMessagesAction() public method

Returns messages of the dialog

/chat/dialogs/({dialog_uuid})/messages

Method: GET

Access: Logged && UserHasAccess

Parameters:

{dialog_uuid} required string dialog uuid
page or offset optional integer page start or offset
limit optional integer page limit
sortby[property]=order optional array sort by property value, order either desc or asc
filterby[property][operator]=value optional array filter (limit results) by given property, operator eq (=), gt (>), ge(>=), lt(<), le(<=), ne(<>), like
language optional string language code

Filter by: Messages

Returns: Messages []

Sample response:

{
    "status": "OK",
    "data":[
        {"type": "messages", "uuid": "cd2a302a-6f8c-11e7-925e-54bef75c7a3f", "user_uuid": "4622f77e-27f8-11e6-98d1-54bef75c7a3f",…},
        {"type": "messages", "uuid": "ced02cae-6f8c-11e7-827f-54bef75c7a3f", "user_uuid": "4622f77e-27f8-11e6-98d1-54bef75c7a3f",…},
        {"type": "messages", "uuid": "d396b8fc-6f8c-11e7-ae4e-54bef75c7a3f", "user_uuid": "4622f77e-27f8-11e6-98d1-54bef75c7a3f",…},
        {"type": "messages", "uuid": "d77f22ba-6f8c-11e7-b484-54bef75c7a3f", "user_uuid": "4622f77e-27f8-11e6-98d1-54bef75c7a3f",…}
        ...
    ],
    "count":{"offset": 0, "limit": 10, "total": 5},
    "timestamp": 1234567890
}

public mixed listMessagesAction ( $dialog_uuid )
$dialog_uuid string
throws Exception
messageAction() public method

Returns message

/chat/messages/{message_uuid}

Method: GET

Access: Logged && UserHasAccess

Parameters:

{message_uuid} required string message uuid
language optional string language code

Returns: Messages

Sample response:

{
    "status": "OK",
    "data":[
        "type": "messages",
        "uuid": "9f01a8d8-6f85-11e7-9eb6-54bef75c7a3f",
        "user_uuid": "a479b438-14a8-11e6-ac83-54bef75c7a3f",
        "to_user_uuid": "a479b438-14a8-11e6-ac83-54bef75c7a3f",
        ...
    ],
    "timestamp": 1234567890
}

public mixed messageAction ( $message_uuid )
$message_uuid string

Message uuid

privateDialogFor() protected method

Get or create private dialog for user

protected Phalcon\Http\Response|Phalcon\Http\ResponseInterface privateDialogFor ( $interlocutor, $touch false )
$interlocutor Socialveo\Core\models\User
$touch boolean

[optional]

throws Exception
touchDialogAction() public method

Touch dialog (marks dialog as read, removes notifications about unread messages)

/chat/dialogs/{dialog_uuid}/touch

Method: POST

Access: Logged && UserHasAccess

Parameters:

{dialog_uuid} required string dialog uuid
language optional string language code

Affects: MessagesDialogs , Notification

Returns: MessagesDialogs

Sample response:

{
    "status": "OK",
    "data":[
        "type": "messages_dialogs",
        "uuid": "9f01a8d8-6f85-11e7-9eb6-54bef75c7a3f",
        "user_uuid": "a479b438-14a8-11e6-ac83-54bef75c7a3f",
        "to_user_uuid": "a479b438-14a8-11e6-ac83-54bef75c7a3f",
        ...
    ],
    "timestamp": 1234567890
}

public mixed touchDialogAction ( $dialog_uuid )
$dialog_uuid string

Dialog uuid

unreadMessagesAction() public method

Get unread messages of dialog

/chat/dialogs/{dialog_uuid}/messages/unread

Method: GET

Access: Logged && UserHasAccess

Parameters:

{dialog_uuid} required string dialog uuid
language optional string language code

Returns: Messages []

Sample response:

{
    "status": "OK",
    "data":[
         {"type": "message", "uuid": "cd2a302a-6f8c-11e7-925e-54bef75c7a3f", "user_uuid": "4622f77e-27f8-11e6-98d1-54bef75c7a3f",…},
         {"type": "message", "uuid": "ced02cae-6f8c-11e7-827f-54bef75c7a3f", "user_uuid": "4622f77e-27f8-11e6-98d1-54bef75c7a3f",…},
         {"type": "message", "uuid": "d396b8fc-6f8c-11e7-ae4e-54bef75c7a3f", "user_uuid": "4622f77e-27f8-11e6-98d1-54bef75c7a3f",…},
         {"type": "message", "uuid": "d77f22ba-6f8c-11e7-b484-54bef75c7a3f", "user_uuid": "4622f77e-27f8-11e6-98d1-54bef75c7a3f",…}
         ...
     ],
     "count":{ "total": 12 },
    "timestamp": 1234567890
}

public mixed unreadMessagesAction ( $dialog_uuid )
$dialog_uuid string
throws Exception
userDialogAction() public method

Get or create (if it not exists) private dialog with user

/chat/dialogs/users/{user_uuid}

Method: POST

Access: Logged && UserHasAccess

Parameters:

{user_uuid} required string user uuid
language optional string language code

Affects: MessagesDialogs , Notification

Returns: MessagesDialogs

Sample response:

{
    "status": "OK",
    "data":[
        "type": "messages_dialogs",
        "uuid": "9f01a8d8-6f85-11e7-9eb6-54bef75c7a3f",
        "user_uuid": "a479b438-14a8-11e6-ac83-54bef75c7a3f",
        "to_user_uuid": "a479b438-14a8-11e6-ac83-54bef75c7a3f",
        ...
    ],
    "timestamp": 1234567890
}

public mixed userDialogAction ( $user_uuid )
$user_uuid string

User uuid

throws Exception