Skip to content

Commit

Permalink
Merge branch 'develop' of github.com:RocketChat/Rocket.Chat into mobi…
Browse files Browse the repository at this point in the history
…le-sidenav
  • Loading branch information
ggazzo committed Aug 24, 2017
2 parents 4c7344a + 8e998c0 commit 3078910
Show file tree
Hide file tree
Showing 47 changed files with 743 additions and 548 deletions.
2 changes: 1 addition & 1 deletion .meteor/versions
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ rocketchat:[email protected]
rocketchat:[email protected]
rocketchat:[email protected]
rocketchat:[email protected]
rocketchat:[email protected].1
rocketchat:[email protected].2
rocketchat:[email protected]
rocketchat:[email protected]
rocketchat:[email protected]
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -121,3 +121,4 @@
"wolfy87-eventemitter": "^5.2.2"
}
}

27 changes: 27 additions & 0 deletions packages/rocketchat-api/server/v1/groups.js
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,33 @@ RocketChat.API.v1.addRoute('groups.list', { authRequired: true }, {
}
});


RocketChat.API.v1.addRoute('groups.listAll', { authRequired: true }, {
get() {
if (!RocketChat.authz.hasPermission(this.userId, 'view-room-administration')) {
return RocketChat.API.v1.unauthorized();
}
const { offset, count } = this.getPaginationItems();
const { sort, fields } = this.parseJsonQuery();
let rooms = RocketChat.models.Rooms.findByType('p').fetch();
const totalCount = rooms.length;

rooms = RocketChat.models.Rooms.processQueryOptionsOnResult(rooms, {
sort: sort ? sort : { name: 1 },
skip: offset,
limit: count,
fields: Object.assign({}, fields, RocketChat.API.v1.defaultFieldsToExclude)
});

return RocketChat.API.v1.success({
groups: rooms,
offset,
count: rooms.length,
total: totalCount
});
}
});

RocketChat.API.v1.addRoute('groups.members', { authRequired: true }, {
get() {
const findResult = findPrivateGroupByIdOrName({ params: this.requestParams(), userId: this.userId });
Expand Down
3 changes: 2 additions & 1 deletion packages/rocketchat-authorization/server/startup.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@ Meteor.startup(function() {
{ _id: 'view-room-administration', roles : ['admin'] },
{ _id: 'view-statistics', roles : ['admin'] },
{ _id: 'view-user-administration', roles : ['admin'] },
{ _id: 'preview-c-room', roles : ['admin', 'user', 'anonymous'] }
{ _id: 'preview-c-room', roles : ['admin', 'user', 'anonymous'] },
{ _id: 'view-outside-room', roles : ['admin', 'owner', 'moderator', 'user'] }
];

for (const permission of permissions) {
Expand Down
3 changes: 1 addition & 2 deletions packages/rocketchat-autotranslate/server/autotranslate.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,7 @@ class AutoTranslate {
let count = message.tokens.length;

message.html = message.msg;
RocketChat.MarkdownCode.handle_codeblocks(message);
RocketChat.MarkdownCode.handle_inlinecode(message);
message = RocketChat.Markdown.parse(message);
message.msg = message.html;

for (const tokenIndex in message.tokens) {
Expand Down
2 changes: 1 addition & 1 deletion packages/rocketchat-file-upload/server/lib/proxy.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ WebApp.connectHandlers.stack.unshift({
const options = {
hostname: instance.extraInformation.host,
port: instance.extraInformation.port,
path: req.url,
path: req.originalUrl,
method: 'POST'
};

Expand Down
11 changes: 10 additions & 1 deletion packages/rocketchat-i18n/i18n/en.i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -954,7 +954,7 @@
"LDAP_Sync_User_Data": "Sync Data",
"LDAP_Sync_User_Data_Description": "Keep user data in sync with server on login (eg: name, email).",
"LDAP_Sync_User_Data_FieldMap": "User Data Field Map",
"LDAP_Sync_User_Data_FieldMap_Description": "Configure how user account fields (like email) are populated from a record in LDAP (once found). <br/>As an example, `{\"cn\":\"name\", \"mail\":\"email\"}` will choose a person's human readable name from the cn attribute, and their email from the mail attribute. Additionally it is possible to use variables, for example: `{ \"#{givenName} #{sn}\": \"name\", \"mail\": \"email\" }` uses a combination of the user's first name and last name for the rocket chat `name` field.<br/>Available fields in Rocket.Chat: `name`, and `email`.",
"LDAP_Sync_User_Data_FieldMap_Description": "Configure how user account fields (like email) are populated from a record in LDAP (once found). <br/>As an example, `{\"cn\":\"name\", \"mail\":\"email\"}` will choose a person's human readable name from the cn attribute, and their email from the mail attribute. Additionally it is possible to use variables, for example: `{ \"#{givenName} #{sn}\": \"name\", \"mail\": \"email\" }` uses a combination of the user's first name and last name for the rocket chat `name` field.<br/>Available fields in Rocket.Chat: `name`, `email` and `customFields`.",
"LDAP_Sync_Users": "Sync Users",
"LDAP_Test_Connection": "Test Connection",
"LDAP_Unique_Identifier_Field": "Unique Identifier Field",
Expand Down Expand Up @@ -1044,9 +1044,17 @@
"MapView_GMapsAPIKey_Description": "This can be obtained from the Google Developers Console for free.",
"Mark_as_read": "Mark as read",
"Mark_as_unread": "Mark as unread",
"Markdown_Parser": "Markdown Parser",
"Original": "Original",
"Markdown_Headers": "Allow Markdown headers in messages",
"Markdown_SupportSchemesForLink": "Markdown Support Schemes for Link",
"Markdown_SupportSchemesForLink_Description": "Comma-separated list of allowed schemes",
"Markdown_Marked_GFM": "Enable Marked GFM",
"Markdown_Marked_Tables": "Enable Marked Tables",
"Markdown_Marked_Breaks": "Enable Marked Breaks",
"Markdown_Marked_Pedantic": "Enable Marked Pedantic",
"Markdown_Marked_SmartLists": "Enable Marked Smart Lists",
"Markdown_Marked_Smartypants": "Enable Marked Smartypants",
"Max_length_is": "Max length is %s",
"Members_List": "Members List",
"Mentions": "Mentions",
Expand Down Expand Up @@ -1388,6 +1396,7 @@
"view-privileged-setting": "View Privileged Setting",
"view-privileged-setting_description": "Permission to view settings",
"view-other-user-channels": "View Other User Channels",
"view-outside-room": "View Outside Room",
"view-other-user-channels_description": "Permission to view channels owned by other users",
"view-room-administration": "View Room Administration",
"view-room-administration_description": "Permission to view public, private and direct message statistics. Does not include the ability to view conversations or archives",
Expand Down
12 changes: 10 additions & 2 deletions packages/rocketchat-i18n/i18n/ja.i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -657,9 +657,17 @@
"Managing_assets": "資産を管理します",
"Managing_integrations": "統合管理",
"Mark_as_read": "既読にする",
"Markdown_Headers": "Markdown ヘッダー",
"Markdown_SupportSchemesForLink": "Markdown リンクでサポートするスキーマ",
"Markdown_Parser": "Markdown パーサー",
"Original": "オリジナル",
"Markdown_Headers": "ヘッダーを有効にする",
"Markdown_SupportSchemesForLink": "リンクでサポートするスキーマリスト",
"Markdown_SupportSchemesForLink_Description": "許可するスキーマをカンマ区切りで記述してください。",
"Markdown_Marked_GFM": "Marked GFM を有効にする",
"Markdown_Marked_Tables": "Marked Tables を有効にする",
"Markdown_Marked_Breaks": "Marked Breaks を有効にする",
"Markdown_Marked_Pedantic": "Marked Pedantic を有効にする",
"Markdown_Marked_SmartLists": "Marked Smart Lists を有効にする",
"Markdown_Marked_Smartypants": "Marked Smartypants を有効にする",
"Members_List": "メンバーリスト",
"Mentions": "メンション",
"Mentions_default": "メンション (デフォルト)",
Expand Down
2 changes: 1 addition & 1 deletion packages/rocketchat-i18n/i18n/pt-BR.i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -656,7 +656,7 @@
"LDAP_Sync_User_Data": "Manter dados dos usuários sincronizados",
"LDAP_Sync_User_Data_Description": "Mantenha seus dados de usuário em sincronia logando no servidor (ex.: nome, email).",
"LDAP_Sync_User_Data_FieldMap": "Mapeamento de campos do usuário",
"LDAP_Sync_User_Data_FieldMap_Description": "Configure como os campos da conta de usuário (tipo email) serão populados no LDAP (quando encontrados). <br />Por exemplo, `{\"cn\":\"name\", \"mail\":\"email\"}` irá selecionar o nome do usuário do atributo cn, e o seu e-mail do atributo mail. <br/>Os campos disponíveis incluem `name` e `email`.",
"LDAP_Sync_User_Data_FieldMap_Description": "Configure como os campos da conta de usuário (tipo email) serão populados no LDAP (quando encontrados). <br />Por exemplo, `{\"cn\":\"name\", \"mail\":\"email\"}` irá selecionar o nome do usuário do atributo cn, e o seu e-mail do atributo mail. <br/>Os campos disponíveis incluem `name`, `email` e `customFields`.",
"LDAP_Sync_Users": "Sincronizar Usuários",
"LDAP_Test_Connection": "Testar Conexão",
"LDAP_Unique_Identifier_Field": "Campo Identificador Único",
Expand Down
2 changes: 1 addition & 1 deletion packages/rocketchat-i18n/i18n/pt.i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -700,7 +700,7 @@
"LDAP_Sync_User_Data": "Manter dados dos usuários sincronizados",
"LDAP_Sync_User_Data_Description": "Mantenha seus dados de usuário em sincronia logando no servidor (ex.: nome, email).",
"LDAP_Sync_User_Data_FieldMap": "Mapeamento de campos do usuário",
"LDAP_Sync_User_Data_FieldMap_Description": "Configure como os campos da conta de usuário (tipo email) serão populados no LDAP (quando encontrados). <br />Por exemplo, `{\"cn\":\"name\", \"mail\":\"email\"}` irá selecionar o nome do usuário do atributo cn, e o seu e-mail do atributo mail. <br/>Os campos disponíveis incluem `name` e `email`.",
"LDAP_Sync_User_Data_FieldMap_Description": "Configure como os campos da conta de usuário (tipo email) serão populados no LDAP (quando encontrados). <br />Por exemplo, `{\"cn\":\"name\", \"mail\":\"email\"}` irá selecionar o nome do usuário do atributo cn, e o seu e-mail do atributo mail. <br/>Os campos disponíveis incluem `name`, `email` e `customFields`.",
"LDAP_Sync_Users": "Sincronizar Usuários",
"LDAP_Test_Connection": "Testar Conexão",
"LDAP_Unique_Identifier_Field": "Campo Identificador Único",
Expand Down
16 changes: 11 additions & 5 deletions packages/rocketchat-ldap/server/sync.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ getDataToSyncUserData = function getDataToSyncUserData(ldapUser, user) {
const userData = {};

if (syncUserData && syncUserDataFieldMap) {
const whitelistedUserFields = ['email', 'name', 'customFields'];
const fieldMap = JSON.parse(syncUserDataFieldMap);
const emailList = [];
_.map(fieldMap, function(userField, ldapField) {
Expand All @@ -84,14 +85,19 @@ getDataToSyncUserData = function getDataToSyncUserData(ldapUser, user) {
}
break;

case 'name':
default:
if (!_.find(whitelistedUserFields, (el) => el === userField.split('.')[0])) {
logger.debug(`user attribute not whitelisted: ${ userField }`);
return;
}

const tmpLdapField = RocketChat.templateVarHandler(ldapField, ldapUser.object);
const userFieldValue = _.reduce(userField.split('.'), (acc, el) => acc[el], user);

if (tmpLdapField && user.name !== tmpLdapField) {
userData.name = tmpLdapField;
logger.debug(`user.name changed to: ${ tmpLdapField }`);
if (tmpLdapField && userFieldValue !== tmpLdapField) {
userData[userField] = tmpLdapField;
logger.debug(`user.${ userField } changed to: ${ tmpLdapField }`);
}
break;
}
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<header class="sidebar__header">
{{> accountBox lighten=true modifier="--livechat"}}
<button class="sidebar-flex__back-button" data-action="back">
{{> icon block="sidebar-flex__back-icon" icon="arrow-back"}}
{{> icon block="sidebar-flex__back-icon" icon="back"}}
<span>{{_ "Back_to_chat"}}</span>
</button>
</header>
Expand Down
1 change: 1 addition & 0 deletions packages/rocketchat-markdown/.npm/package/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules
7 changes: 7 additions & 0 deletions packages/rocketchat-markdown/.npm/package/README
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
This directory and the files immediately inside it are automatically generated
when you change this package's NPM dependencies. Commit the files in this
directory (npm-shrinkwrap.json, .gitignore, and this README) to source control
so that others run the same versions of sub-dependencies.

You should NOT check in the node_modules directory that Meteor automatically
creates; if you are using git, the .gitignore file tells git to ignore it.
14 changes: 14 additions & 0 deletions packages/rocketchat-markdown/.npm/package/npm-shrinkwrap.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

102 changes: 21 additions & 81 deletions packages/rocketchat-markdown/markdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,92 +2,32 @@
* Markdown is a named function that will parse markdown syntax
* @param {Object} message - The message object
*/
import { Meteor } from 'meteor/meteor';
import { Blaze } from 'meteor/blaze';
import { RocketChat } from 'meteor/rocketchat:lib';

import { marked } from './parser/marked/marked.js';
import { original } from './parser/original/original.js';

const parsers = {
original,
marked
};

class MarkdownClass {
parse(text) {
return this.parseNotEscaped(_.escapeHTML(text));
const message = {
html: _.escapeHTML(text)
};
return this.parseNotEscaped(message).html;
}

parseNotEscaped(msg, message) {
if (message && message.tokens == null) {
message.tokens = [];
parseNotEscaped(message) {
const parser = RocketChat.settings.get('Markdown_Parser');
if (typeof parsers[parser] === 'function') {
return parsers[parser](message);
}

const schemes = RocketChat.settings.get('Markdown_SupportSchemesForLink').split(',').join('|');

if (RocketChat.settings.get('Markdown_Headers')) {
// Support # Text for h1
msg = msg.replace(/^# (([\S\w\d-_\/\*\.,\\][ \u00a0\u1680\u180e\u2000-\u200a\u2028\u2029\u202f\u205f\u3000\ufeff]?)+)/gm, '<h1>$1</h1>');

// Support # Text for h2
msg = msg.replace(/^## (([\S\w\d-_\/\*\.,\\][ \u00a0\u1680\u180e\u2000-\u200a\u2028\u2029\u202f\u205f\u3000\ufeff]?)+)/gm, '<h2>$1</h2>');

// Support # Text for h3
msg = msg.replace(/^### (([\S\w\d-_\/\*\.,\\][ \u00a0\u1680\u180e\u2000-\u200a\u2028\u2029\u202f\u205f\u3000\ufeff]?)+)/gm, '<h3>$1</h3>');

// Support # Text for h4
msg = msg.replace(/^#### (([\S\w\d-_\/\*\.,\\][ \u00a0\u1680\u180e\u2000-\u200a\u2028\u2029\u202f\u205f\u3000\ufeff]?)+)/gm, '<h4>$1</h4>');
}

// Support *text* to make bold
msg = msg.replace(/(^|&gt;|[ >_~`])\*{1,2}([^\*\r\n]+)\*{1,2}([<_~`]|\B|\b|$)/gm, '$1<span class="copyonly">*</span><strong>$2</strong><span class="copyonly">*</span>$3');

// Support _text_ to make italics
msg = msg.replace(/(^|&gt;|[ >*~`])\_([^\_\r\n]+)\_([<*~`]|\B|\b|$)/gm, '$1<span class="copyonly">_</span><em>$2</em><span class="copyonly">_</span>$3');

// Support ~text~ to strike through text
msg = msg.replace(/(^|&gt;|[ >_*`])\~{1,2}([^~\r\n]+)\~{1,2}([<_*`]|\B|\b|$)/gm, '$1<span class="copyonly">~</span><strike>$2</strike><span class="copyonly">~</span>$3');

// Support for block quote
// >>>
// Text
// <<<
msg = msg.replace(/(?:&gt;){3}\n+([\s\S]*?)\n+(?:&lt;){3}/g, '<blockquote class="background-transparent-darker-before"><span class="copyonly">&gt;&gt;&gt;</span>$1<span class="copyonly">&lt;&lt;&lt;</span></blockquote>');

// Support >Text for quote
msg = msg.replace(/^&gt;(.*)$/gm, '<blockquote class="background-transparent-darker-before"><span class="copyonly">&gt;</span>$1</blockquote>');

// Remove white-space around blockquote (prevent <br>). Because blockquote is block element.
msg = msg.replace(/\s*<blockquote class="background-transparent-darker-before">/gm, '<blockquote class="background-transparent-darker-before">');
msg = msg.replace(/<\/blockquote>\s*/gm, '</blockquote>');

// Remove new-line between blockquotes.
msg = msg.replace(/<\/blockquote>\n<blockquote/gm, '</blockquote><blockquote');

// Support ![alt text](http://image url)
msg = msg.replace(new RegExp(`!\\[([^\\]]+)\\]\\(((?:${ schemes }):\\/\\/[^\\)]+)\\)`, 'gm'), function(match, title, url) {
const target = url.indexOf(Meteor.absoluteUrl()) === 0 ? '' : '_blank';
const html = `<a href="${ _.escapeHTML(url) }" title="${ _.escapeHTML(title) }" target="${ _.escapeHTML(target) }" rel="noopener noreferrer"><div class="inline-image" style="background-image: url(${ _.escapeHTML(url) });"></div></a>`;

if (message && message.tokens) {
const token = `=!=${ Random.id() }=!=`;

message.tokens.push({
token,
text: html
});

return token;
}

return html;
});

// Support [Text](http://link)
msg = msg.replace(new RegExp(`\\[([^\\]]+)\\]\\(((?:${ schemes }):\\/\\/[^\\)]+)\\)`, 'gm'), function(match, title, url) {
const target = url.indexOf(Meteor.absoluteUrl()) === 0 ? '' : '_blank';
return `<a href="${ _.escapeHTML(url) }" target="${ _.escapeHTML(target) }" rel="noopener noreferrer">${ _.escapeHTML(title) }</a>`;
});

// Support <http://link|Text>
msg = msg.replace(new RegExp(`(?:<|&lt;)((?:${ schemes }):\\/\\/[^\\|]+)\\|(.+?)(?=>|&gt;)(?:>|&gt;)`, 'gm'), (match, url, title) => {
const target = url.indexOf(Meteor.absoluteUrl()) === 0 ? '' : '_blank';
return `<a href="${ _.escapeHTML(url) }" target="${ _.escapeHTML(target) }" rel="noopener noreferrer">${ _.escapeHTML(title) }</a>`;
});

if (typeof window !== 'undefined' && window !== null ? window.rocketDebug : undefined) { console.log('Markdown', msg); }

return msg;
return parsers['original'](message);
}
}

Expand All @@ -97,7 +37,7 @@ RocketChat.Markdown = Markdown;
// renderMessage already did html escape
const MarkdownMessage = (message) => {
if (_.trim(message != null ? message.html : undefined)) {
message.html = Markdown.parseNotEscaped(message.html, message);
message = Markdown.parseNotEscaped(message);
}

return message;
Expand Down
Loading

0 comments on commit 3078910

Please sign in to comment.