API > Messages

Basic JavaScript object

Membership.api.messages

createConversation

Creates new conversation.

Parameters

  • users
    Array of user IDs with who is needed to create a conversation.
  • message
    A message which will be sent to users.

Result

Returns object which contains such properties: success in a case of success and html in a case of error success, message.

  • success
    Request status true in a case of success or false in a case of error.
  • html
    Object with properties:

    • conversationListItem Template render membership-by-supsystic/src/Membership/Messages/views/partials/conversations-list.twig
    • conversationMessages Template render membership-by-supsystic/src/Membership/Message/views/partials/conversations.twig
  • message
    Error message.

Example

Membership.api.messages.createConversation({
    users: [1, 2, 3],
    message: 'Hello'
});

getMessages

Gets messages in a cartain conversation.

Parameters

  • conversationId
    Conversation ID.
  • limit
    Maximum number of messages which has to be returned. By default 5, minumum value 1, maximum value 50.
  • `lastMessageIdMessage ID regarding to which list will be created.
  • direction
    If the parameter is equal to -1 request will return old messages, if it’s equal to 1 it will return only new messages regarding to parameterlastMessageId

Result

Returns object with properties success и html

  • success
    Request status true in a case of success or false in a case of error.
  • html
    Template render membership-by-supsystic/src/Membership/Messages/views/partials/messages.twig'

Example

Membership.api.messages.getMessages({
    conversationId: 1,
    limit: 5,
    lastMessageId: 10,
    direction: -1
});

checkUnreadMessages

Checks conversation of the current user if there are new messages.

Result

Returns object with properties success и html

  • success
    Request status true in a case of success or false in a case of error.
  • html
    Object with properties:

    • conversationListItem Template render membership-by-supsystic/src/Membership/Messages/views/partials/conversations-list.twig
    • conversationMessages Template render membership-by-supsystic/src/Membership/Message/views/partials/conversations.twig

Example

Membership.api.messages.checkUnreadMessages();

sendMessage

Send messages to all conversation participants.

Parameters

  • conversationId
    Conversation ID.
  • message
    A message which will be sent to users.

Result

Returns object which contains such properties: success in a case of success and html in a case of error success, message.

  • success
    Request status true in a case of success or false in a case of error.
  • html
    Template render membership-by-supsystic/src/Membership/Messages/views/partials/messages.twig
  • message
    Error message.

Example

Membership.api.messages.sendMessage({
    conversationId: 1,
    message: 'Hello'
});

sendMessageToUser

Send message to a certain user.

Parameters

  • userId
    User ID.
  • message
    A message which will be sent to user.

Result

Returns object which contains such properties: success in a case of success and html in a case of error success, message.

  • success
    Request status true in a case of success or false in a case of error.
  • html
    Object with properties:

    • conversationListItem Template render membership-by-supsystic/src/Membership/Messages/views/partials/conversations-list.twig
    • conversationMessages Template render membership-by-supsystic/src/Membership/Message/views/partials/conversations.twig
  • message
    Error message.

Example

Membership.api.messages.sendMessageToUser({
    userId: 1,
    message: 'Hello'
});

deleteMessages

Removes certain messages from a conversation.

Parameters

  • conversationId
    Conversation ID.
  • messages
    Array of messages IDs.

Result

Returns object which contains such properties: success in a case of success and html in a case of error success, message.

  • success
    Request status true in a case of success or false in a case of error.

Example

Membership.api.messages.deleteMessages({
    conversationId: 1,
    messages: [1, 2, 3]
});

deleteConversation

Removes certain conversation.

Parameters

  • conversationId
    Conversation ID.

Result

Returns object which contains such properties: success in a case of success and html in a case of error success, message.

  • success
    Request status true in a case of success or false in a case of error.

Example

Membership.api.messages.deleteConversation({
    conversationId: 1
});

blockUser

Blocks receiving messages from the specified user.

Parameters

  • userId
    User ID.

Result

Returns object with properties success и message.

  • success
    Request status true in a case of success or false in a case of error.
  • message
    Message about success blocking or error message.

Example

Membership.api.messages.blockUser({
    userId: 1
});

unblockUser

Unblocks receiving messages from the specified user.

Parameters

  • userId
    User ID.

Result

Returns object with properties success и message.

  • success
    Request status true in a case of success or false in a case of error.
  • message
    Message about success unblocking or error message.

Example

Membership.api.messages.unblockUser({
    userId: 1
});

Categories
Latest Articles