Merge remote-tracking branch 'origin/develop' into add-file-upload-notification

pull/7559/head
Martin Schoeler 9 years ago
commit a8d0a2dd47
  1. 32
      example-build-run.sh
  2. 16
      example-build.sh
  3. 11
      packages/rocketchat-api/server/v1/channels.js
  4. 4
      packages/rocketchat-api/server/v1/users.js
  5. 2
      packages/rocketchat-i18n/i18n/en.i18n.json
  6. 4
      packages/rocketchat-integrations/server/lib/triggerHandler.js
  7. 5
      packages/rocketchat-lib/client/lib/roomExit.js
  8. 3
      packages/rocketchat-lib/server/models/Users.js
  9. 4
      packages/rocketchat-lib/server/startup/settings.js
  10. 2
      packages/rocketchat-livechat/server/lib/Livechat.js
  11. 3
      packages/rocketchat-mentions-flextab/client/actionButton.js
  12. 3
      packages/rocketchat-message-pin/client/actionButton.js
  13. 3
      packages/rocketchat-message-star/client/actionButton.js
  14. 3
      packages/rocketchat-ui-flextab/client/tabs/messageSearch.js
  15. 9
      packages/rocketchat-ui/client/lib/RoomHistoryManager.js
  16. 44
      packages/rocketchat-ui/client/views/app/room.js
  17. 10
      server/methods/createDirectMessage.js
  18. 3
      server/startup/avatar.js

@ -0,0 +1,32 @@
#!/bin/bash
set -x
set -euvo pipefail
IFS=$'\n\t'
# Requies Node.js version 4.x
# Do not run as root
DEPLOY_DIR=/var/www/rocket.chat
### BUILD
meteor npm install
# on the very first build, meteor build command should fail due to a bug on emojione package (related to phantomjs installation)
# the command below forces the error to happen before build command (not needed on subsequent builds)
set +e
meteor add rocketchat:lib
set -e
meteor build --server-only --directory $DEPLOY_DIR
### RUN
cd $DEPLOY_DIR/bundle/programs/server
npm install
cd $DEPLOY_DIR/bundle
NODE_ENV=production \
PORT=3000 \
ROOT_URL=http://localhost:3000 \
MONGO_URL=mongodb://localhost:27017/rocketchat \
MONGO_OPLOG_URL=mongodb://localhost:27017/local \
node main.js

@ -1,16 +0,0 @@
#!/bin/bash
set -x
set -euvo pipefail
IFS=$'\n\t'
# Build
export NODE_ENV=production
meteor add rocketchat:internal-hubot
meteor build --server https://demo.rocket.chat --directory /var/www/rocket.chat
# Run
export METEOR_SETTINGS=$(cat settings.json)
cd /var/www/rocket.chat/bundle/programs/server
npm install
cd /var/www/rocket.chat/current
pm2 startOrRestart /var/www/rocket.chat/current/pm2.json

@ -332,13 +332,22 @@ RocketChat.API.v1.addRoute('channels.leave', { authRequired: true }, {
RocketChat.API.v1.addRoute('channels.list', { authRequired: true }, {
get: {
//This is like this only to provide an example of how we routes can be defined :X
//This is defined as such only to provide an example of how the routes can be defined :X
action() {
const { offset, count } = this.getPaginationItems();
const { sort, fields, query } = this.parseJsonQuery();
const ourQuery = Object.assign({}, query, { t: 'c' });
//Special check for the permissions
if (RocketChat.authz.hasPermission(this.userId, 'view-joined-room')) {
ourQuery.usernames = {
$in: [ this.user.username ]
};
} else if (!RocketChat.authz.hasPermission(this.userId, 'view-c-room')) {
return RocketChat.API.v1.unauthorized();
}
const rooms = RocketChat.models.Rooms.find(ourQuery, {
sort: sort ? sort : { name: 1 },
skip: offset,

@ -105,6 +105,10 @@ RocketChat.API.v1.addRoute('users.info', { authRequired: true }, {
RocketChat.API.v1.addRoute('users.list', { authRequired: true }, {
get() {
if (!RocketChat.authz.hasPermission(this.userId, 'view-d-room')) {
return RocketChat.API.v1.unauthorized();
}
const { offset, count } = this.getPaginationItems();
const { sort, fields, query } = this.parseJsonQuery();

@ -330,6 +330,8 @@
"Clear_all_unreads_question": "Clear all unreads?",
"Click_here": "Click here",
"Click_here_for_more_info": "Click here for more info",
"UI_Click_Direct_Message": "Click to Create Direct Message",
"UI_Click_Direct_Message_Description": "Skip opening profile tab, instead go straight to conversation",
"Client_ID": "Client ID",
"Client_Secret": "Client Secret",
"Clients_will_refresh_in_a_few_seconds": "Clients will refresh in a few seconds",

@ -165,8 +165,8 @@ RocketChat.integrations.triggerHandler = new class RocketChatIntegrationHandler
}
let tmpRoom;
if (nameOrId || trigger.targetRoom) {
tmpRoom = RocketChat.getRoomByNameOrIdWithOptionToJoin({ currentUserId: user._id, nameOrId: nameOrId || trigger.targetRoom, errorOnEmpty: false }) || room;
if (nameOrId || trigger.targetRoom || message.channel) {
tmpRoom = RocketChat.getRoomByNameOrIdWithOptionToJoin({ currentUserId: user._id, nameOrId: nameOrId || message.channel || trigger.targetRoom, errorOnEmpty: false }) || room;
} else {
tmpRoom = room;
}

@ -1,5 +1,10 @@
/*globals currentTracker */
this.roomExit = function() {
// 7370 - Close flex-tab when opening a room on mobile UI
if (window.matchMedia('(max-width: 500px)').matches) {
const templateData = Blaze.getData(document.querySelector('.flex-tab'));
templateData && templateData.tabBar && templateData.tabBar.close();
}
RocketChat.callbacks.run('roomExit');
BlazeLayout.render('main', {
center: 'none'

@ -148,6 +148,9 @@ class ModelUsers extends RocketChat.models._Base {
},
{
name: termRegex
},
{
'emails.address': termRegex
}
]
},

@ -1036,6 +1036,10 @@ RocketChat.settings.addGroup('Layout', function() {
type: 'boolean',
'public': true
});
this.add('UI_Click_Direct_Message', false, {
type: 'boolean',
'public': true
});
});
});

@ -127,7 +127,7 @@ RocketChat.Livechat = {
if (this.connection) {
userData.userAgent = this.connection.httpHeaders['user-agent'];
userData.ip = this.connection.httpHeaders['x-real-ip'] || this.connection.clientAddress;
userData.ip = this.connection.httpHeaders['x-real-ip'] || this.connection.httpHeaders['x-forwarded-for'] || this.connection.clientAddress;
userData.host = this.connection.httpHeaders.host;
}

@ -7,6 +7,9 @@ Meteor.startup(function() {
action() {
const message = this._arguments[1];
RocketChat.MessageAction.hideDropDown();
if (window.matchMedia('(max-width: 500px)').matches) {
Template.instance().tabBar.close();
}
return RoomHistoryManager.getSurroundingMessages(message, 50);
},
validation(message) {

@ -62,6 +62,9 @@ Meteor.startup(function() {
action() {
const message = this._arguments[1];
RocketChat.MessageAction.hideDropDown();
if (window.matchMedia('(max-width: 500px)').matches) {
Template.instance().tabBar.close();
}
return RoomHistoryManager.getSurroundingMessages(message, 50);
},
validation(message) {

@ -54,6 +54,9 @@ Meteor.startup(function() {
action() {
const message = this._arguments[1];
RocketChat.MessageAction.hideDropDown();
if (window.matchMedia('(max-width: 500px)').matches) {
Template.instance().tabBar.close();
}
return RoomHistoryManager.getSurroundingMessages(message, 50);
},
validation(message) {

@ -9,6 +9,9 @@ Meteor.startup(function() {
action() {
const message = this._arguments[1];
RocketChat.MessageAction.hideDropDown();
if (window.matchMedia('(max-width: 500px)').matches) {
Template.instance().tabBar.close();
}
return RoomHistoryManager.getSurroundingMessages(message, 50);
},
order: 100

@ -51,11 +51,12 @@ export const RoomHistoryManager = new class {
typeName = (curRoomDoc != null ? curRoomDoc.t : undefined) + (curRoomDoc != null ? curRoomDoc.name : undefined);
}
return Meteor.call('loadHistory', rid, ts, limit, ls, function(err, result) {
Meteor.call('loadHistory', rid, ts, limit, ls, function(err, result) {
if (err) {
return;
}
let previousHeight;
const {messages = []} = result;
room.unreadNotLoaded.set(result.unreadNotLoaded);
room.firstUnread.set(result.firstUnread);
@ -64,7 +65,7 @@ export const RoomHistoryManager = new class {
previousHeight = wrapper.scrollHeight;
}
result.messages.forEach(item => {
messages.forEach(item => {
if (item.t !== 'command') {
const roles = [
(item.u && item.u._id && UserRoles.findOne(item.u._id, { fields: { roles: 1 }})) || {},
@ -87,8 +88,8 @@ export const RoomHistoryManager = new class {
room.isLoading.set(false);
if (room.loaded == null) { room.loaded = 0; }
room.loaded += result.messages.length;
if (result.messages.length < limit) {
room.loaded += messages.length;
if (messages.length < limit) {
return room.hasMore.set(false);
}
});

@ -10,7 +10,23 @@ const isSubscribed = _id => ChatSubscription.find({ rid: _id }).count() > 0;
const favoritesEnabled = () => RocketChat.settings.get('Favorite_Rooms');
const userCanDrop = _id => !RocketChat.roomTypes.readOnly(_id, Meteor.user());
const openProfileTab = (e, instance, data) => {
const roomData = Session.get(`roomData${ data.rid }`);
if (RocketChat.Layout.isEmbedded()) {
fireGlobalEvent('click-user-card-message', { username: data.u.username });
e.preventDefault();
e.stopPropagation();
return;
}
if (['c', 'p', 'd'].includes(roomData.t)) {
instance.setUserDetail(data.u.username);
}
instance.tabBar.setTemplate('membersList');
return instance.tabBar.open();
};
Template.room.helpers({
isTranslated() {
const sub = ChatSubscription.findOne({ rid: this._id }, { fields: { autoTranslate: 1, autoTranslateLanguage: 1 } });
@ -458,21 +474,23 @@ Template.room.events({
if (!Meteor.userId() || !this._arguments) {
return;
}
const roomData = Session.get(`roomData${ this._arguments[1].rid }`);
if (RocketChat.Layout.isEmbedded()) {
fireGlobalEvent('click-user-card-message', { username: this._arguments[1].u.username });
e.preventDefault();
e.stopPropagation();
return;
}
if (RocketChat.settings.get('UI_Click_Direct_Message')) {
return Meteor.call('createDirectMessage', this._arguments[1].u.username, (error, result) => {
if (error) {
if (error.isClientSafe) {
openProfileTab(e, instance, this._arguments[1]);
} else {
return handleError(error);
}
}
if (['c', 'p', 'd'].includes(roomData.t)) {
instance.setUserDetail(this._arguments[1].u.username);
if ((result != null ? result.rid : undefined) != null) {
return FlowRouter.go('direct', { username: this._arguments[1].u.username }, FlowRouter.current().queryParams);
}
});
} else {
openProfileTab(e, instance, this._arguments[1]);
}
instance.tabBar.setTemplate('membersList');
return instance.tabBar.open();
},
'scroll .wrapper': _.throttle(function(e) {

@ -109,10 +109,8 @@ Meteor.methods({
}
});
DDPRateLimiter.addRule({
type: 'method',
name: 'createDirectMessage',
connectionId() {
return true;
RocketChat.RateLimiter.limitMethod('createDirectMessage', 10, 60000, {
userId(userId) {
return !RocketChat.authz.hasPermission(userId, 'send-many-messages');
}
}, 10, 60000);
});

@ -86,7 +86,8 @@ Meteor.startup(function() {
initials = initials.toUpperCase();
}
const svg = `<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n<svg xmlns=\"http://www.w3.org/2000/svg\" pointer-events=\"none\" width=\"50\" height=\"50\" style=\"width: 50px; height: 50px; background-color: ${ color };\">\n <text text-anchor=\"middle\" y=\"50%\" x=\"50%\" dy=\"0.36em\" pointer-events=\"auto\" fill=\"#ffffff\" font-family=\"Helvetica, Arial, Lucida Grande, sans-serif\" style=\"font-weight: 400; font-size: 28px;\">\n ${ initials }\n </text>\n</svg>`;
const svg = `<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n<svg xmlns=\"http://www.w3.org/2000/svg\" pointer-events=\"none\" width=\"50\" height=\"50\">\n<rect height="50" width="50" fill=\"${ color }\"/>\n<text text-anchor=\"middle\" y=\"50%\" x=\"50%\" dy=\"0.36em\" pointer-events=\"auto\" fill=\"#ffffff\" font-family=\"Helvetica, Arial, Lucida Grande, sans-serif\" font-weight="400" font-size="28">\n${ initials }\n</text>\n</svg>`;
res.write(svg);
res.end();

Loading…
Cancel
Save