Skip to content
Snippets Groups Projects
user avatar
Gabriel Engel authored
# By Diego Sampaio (8) and Rodrigo Nascimento (2)
# Via Gabriel Engel (3) and Rodrigo Nascimento (2)
* 'develop' of github.com:RocketChat/Rocket.Chat:
  Increase the delay to render color fields
  fix guest users default role
  standardize colors definition
  improved clean button color
  support named color for message attachments
  added request debug messages
  trim integration messages
  Try to parse all request bodies as JSON
  new password reset screen
  fix reset password - closes #1502
bab2ab3d
History

Rocket.Chat main library

This package contains the main libraries of Rocket.Chat.

APIs

Settings

This is an example to create settings:

RocketChat.settings.addGroup('Settings_Group', function() {
    this.add('SettingInGroup', 'default_value', { type: 'boolean', public: true });

    this.section('Group_Section', function() {
        this.add('Setting_Inside_Section', 'default_value', {
            type: 'boolean', 
            public: true, 
            enableQuery: { 
                _id: 'SettingInGroup', 
                value: true 
            }
        });
    });
});

RocketChat.settings.add type:

  • string - Stores a string value
    • Additional options:
      • multiline: boolean
  • int - Stores an integer value
  • boolean - Stores a boolean value
  • select - Creates an <select> element
    • Additional options:
      • values: Array of: { key: 'value', i18nLabel: 'Option_Label' }
  • color - Creates a color pick element
  • action - Executes a Method.call to value
    • Additional options:
      • actionText: Translatable value of the button
  • asset - Creates an upload field

RocketChat.settings.add options:

  • description - Description of the setting
  • public - Boolean to set if the setting should be sent to client or not
  • enableQuery - Only enable this setting if the correspondent setting has the value specified
  • alert - Shows an alert message with the given text

roomTypes

You can create your own room type using (on the client):

RocketChat.roomTypes.add('l', 5, {
    template: 'livechat',
    icon: 'icon-chat-empty',
    route: {
        name: 'live',
        path: '/live/:name',
        action(params, queryParams) {
            Session.set('showUserInfo');
            openRoom('l', params.name);
        },
        link(sub)  {
            return { name: sub.name }
        }
    },
    permissions: [ 'view-l-room' ]
});

You'll need publish information about the new room with (on the server):

RocketChat.roomTypes.setPublish('l', (identifier) => {
    return RocketChat.models.Rooms.findByTypeAndName('l', identifier, {
        fields: {
            name: 1,
            t: 1,
            cl: 1,
            u: 1,
            usernames: 1,
            v: 1
        }
    });
});

AccountBox

You can add items to the left upper corner drop menu:

AccountBox.addItem({
    name: 'Livechat',
    icon: 'icon-chat-empty',
    class: 'livechat-manager',
    route: {
        name: 'livechat-manager',
        path: '/livechat-manager',
        action(params, queryParams) {
            Session.set('openedRoom');
            BlazeLayout.render('main', {
                center: 'page-container',
                pageTitle: 'Live Chat Manager',
                pageTemplate: 'livechat-manager'
            });
        }
    },
    permissions: ['view-livechat-manager']
});

Functions

Methods

Publications