Skip to content

Commit

Permalink
Merge branch 'develop' into feature/rest-api-mentions-of-channel
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcosSpessatto committed Mar 26, 2018
2 parents 49c300c + f50679d commit 5287b16
Show file tree
Hide file tree
Showing 34 changed files with 325 additions and 287 deletions.
13 changes: 0 additions & 13 deletions client/routes/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,19 +95,6 @@ FlowRouter.route('/account/:group?', {
}]
});

FlowRouter.route('/history/private', {
name: 'privateHistory',

subscriptions(/*params, queryParams*/) {
this.register('privateHistory', Meteor.subscribe('privateHistory'));
},

action() {
Session.setDefault('historyFilter', '');
BlazeLayout.render('main', {center: 'privateHistory'});
}
});

FlowRouter.route('/terms-of-service', {
name: 'terms-of-service',

Expand Down
38 changes: 38 additions & 0 deletions packages/rocketchat-api/server/v1/channels.js
Original file line number Diff line number Diff line change
Expand Up @@ -847,4 +847,42 @@ RocketChat.API.v1.addRoute('channels.getAllUserMentionsByChannel', { authRequire
}
});

RocketChat.API.v1.addRoute('channels.notifications', { authRequired: true }, {
get() {
const { roomId } = this.requestParams();

if (!roomId) {
return RocketChat.API.v1.failure('The \'roomId\' param is required');
}

const subscription = RocketChat.models.Subscriptions.findOneByRoomIdAndUserId(roomId, this.userId, {
fields: {
_room: 0,
_user: 0,
$loki: 0
}
});

return RocketChat.API.v1.success({
subscription
});
},
post() {
const saveNotifications = (notifications, roomId) => {
Object.keys(notifications).map((notificationKey) => {
Meteor.runAsUser(this.userId, () => Meteor.call('saveNotificationSettings', roomId, notificationKey, notifications[notificationKey]));
});
};
const { roomId, notifications } = this.bodyParams;

if (!roomId) {
return RocketChat.API.v1.failure('The \'roomId\' param is required');
}

if (!notifications || Object.keys(notifications).length === 0) {
return RocketChat.API.v1.failure('The \'notifications\' param is required');
}

saveNotifications(notifications, roomId);
}
});
7 changes: 7 additions & 0 deletions packages/rocketchat-autolinker/client/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,14 @@ import s from 'underscore.string';

import Autolinker from 'autolinker';

function htmlDecode(input) {
const e = document.createElement('div');
e.innerHTML = input;
return e.childNodes.length === 0 ? '' : e.childNodes[0].nodeValue;
}

function AutoLinker(message) {
message.html = htmlDecode(message.html);
if (RocketChat.settings.get('AutoLinker') !== true) {
return message;
}
Expand Down
7 changes: 7 additions & 0 deletions packages/rocketchat-i18n/i18n/en.i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -553,6 +553,7 @@
"Display_offline_form": "Display Offline Form",
"Displays_action_text": "Displays action text",
"Do_not_display_unread_counter": "Do not display any counter of this channel",
"Do_you_want_to_accept": "Do you want to accept?",
"Do_you_want_to_change_to_s_question": "Do you want to change to <strong>%s</strong>?",
"Domain": "Domain",
"Domain_added": "domain Added",
Expand Down Expand Up @@ -1429,6 +1430,7 @@
"Offline_unavailable": "Offline unavailable",
"On": "On",
"Online": "Online",
"online": "online",
"Only_authorized_users_can_write_new_messages": "Only authorized users can write new messages",
"Only_On_Desktop": "Desktop mode (only sends with enter on desktop)",
"Only_you_can_see_this_message": "Only you can see this message",
Expand Down Expand Up @@ -2167,6 +2169,11 @@
"We_have_sent_registration_email": "We have sent you an email to confirm your registration. If you do not receive an email shortly, please come back and try again.",
"Webhook_URL": "Webhook URL",
"Webhooks": "Webhooks",
"WebRTC_direct_audio_call_from_%s": "Direct audio call from %s",
"WebRTC_direct_video_call_from_%s": "Direct video call from %s",
"WebRTC_group_audio_call_from_%s": "Group audio call from %s",
"WebRTC_group_video_call_from_%s": "Group video call from %s",
"WebRTC_monitor_call_from_%s": "Monitor call from %s",
"WebRTC_Enable_Channel": "Enable for Public Channels",
"WebRTC_Enable_Direct": "Enable for Direct Messages",
"WebRTC_Enable_Private": "Enable for Private Channels",
Expand Down
19 changes: 2 additions & 17 deletions packages/rocketchat-lib/client/MessageAction.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,25 +103,10 @@ Meteor.startup(function() {
action() {
const message = this._arguments[1];
const {input} = chatMessages[message.rid];
const url = RocketChat.MessageAction.getPermaLink(message._id);
const roomInfo = RocketChat.models.Rooms.findOne(message.rid, { fields: { t: 1 } });
let text = `[ ](${ url }) `;
let inputValue = '';

if (roomInfo.t !== 'd' && message.u.username !== Meteor.user().username) {
text += `@${ message.u.username } `;
}

if (input.value && !input.value.endsWith(' ')) {
inputValue += ' ';
}
inputValue += text;

$(input)
.focus()
.val(inputValue)
.trigger('change')
.trigger('input');
.data('reply', message)
.trigger('dataChange');
},
condition(message) {
if (RocketChat.models.Subscriptions.findOne({rid: message.rid}) == null) {
Expand Down
43 changes: 25 additions & 18 deletions packages/rocketchat-lib/server/models/Subscriptions.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,16 @@ class ModelSubscriptions extends RocketChat.models._Base {


// FIND ONE
findOneByRoomIdAndUserId(roomId, userId) {
findOneByRoomIdAndUserId(roomId, userId, options) {
if (this.useCache) {
return this.cache.findByIndex('rid,u._id', [roomId, userId]).fetch();
return this.cache.findByIndex('rid,u._id', [roomId, userId], options).fetch();
}
const query = {
rid: roomId,
'u._id': userId
};

return this.findOne(query);
return this.findOne(query, options);
}

findOneByRoomNameAndUserId(roomName, userId) {
Expand All @@ -61,7 +61,7 @@ class ModelSubscriptions extends RocketChat.models._Base {
}

const query =
{'u._id': userId};
{ 'u._id': userId };

return this.find(query, options);
}
Expand Down Expand Up @@ -123,7 +123,7 @@ class ModelSubscriptions extends RocketChat.models._Base {
}

const query =
{rid: roomId};
{ rid: roomId };

return this.find(query, options);
}
Expand All @@ -140,7 +140,9 @@ class ModelSubscriptions extends RocketChat.models._Base {
}

getLastSeen(options) {
if (options == null) { options = {}; }
if (options == null) {
options = {};
}
const query = { ls: { $exists: 1 } };
options.sort = { ls: -1 };
options.limit = 1;
Expand Down Expand Up @@ -198,7 +200,7 @@ class ModelSubscriptions extends RocketChat.models._Base {
// UPDATE
archiveByRoomId(roomId) {
const query =
{rid: roomId};
{ rid: roomId };

const update = {
$set: {
Expand All @@ -213,7 +215,7 @@ class ModelSubscriptions extends RocketChat.models._Base {

unarchiveByRoomId(roomId) {
const query =
{rid: roomId};
{ rid: roomId };

const update = {
$set: {
Expand Down Expand Up @@ -311,7 +313,9 @@ class ModelSubscriptions extends RocketChat.models._Base {
}

setFavoriteByRoomIdAndUserId(roomId, userId, favorite) {
if (favorite == null) { favorite = true; }
if (favorite == null) {
favorite = true;
}
const query = {
rid: roomId,
'u._id': userId
Expand All @@ -328,7 +332,7 @@ class ModelSubscriptions extends RocketChat.models._Base {

updateNameAndAlertByRoomId(roomId, name, fname) {
const query =
{rid: roomId};
{ rid: roomId };

const update = {
$set: {
Expand All @@ -343,7 +347,7 @@ class ModelSubscriptions extends RocketChat.models._Base {

updateNameByRoomId(roomId, name) {
const query =
{rid: roomId};
{ rid: roomId };

const update = {
$set: {
Expand All @@ -356,7 +360,7 @@ class ModelSubscriptions extends RocketChat.models._Base {

setUserUsernameByUserId(userId, username) {
const query =
{'u._id': userId};
{ 'u._id': userId };

const update = {
$set: {
Expand All @@ -383,7 +387,9 @@ class ModelSubscriptions extends RocketChat.models._Base {
}

incUnreadForRoomIdExcludingUserId(roomId, userId, inc) {
if (inc == null) { inc = 1; }
if (inc == null) {
inc = 1;
}
const query = {
rid: roomId,
'u._id': {
Expand Down Expand Up @@ -447,6 +453,7 @@ class ModelSubscriptions extends RocketChat.models._Base {

return this.update(query, update, { multi: true });
}

setAlertForRoomIdExcludingUserId(roomId, userId) {
const query = {
rid: roomId,
Expand Down Expand Up @@ -522,7 +529,7 @@ class ModelSubscriptions extends RocketChat.models._Base {

updateTypeByRoomId(roomId, type) {
const query =
{rid: roomId};
{ rid: roomId };

const update = {
$set: {
Expand All @@ -535,7 +542,7 @@ class ModelSubscriptions extends RocketChat.models._Base {

addRoleById(_id, role) {
const query =
{_id};
{ _id };

const update = {
$addToSet: {
Expand All @@ -548,7 +555,7 @@ class ModelSubscriptions extends RocketChat.models._Base {

removeRoleById(_id, role) {
const query =
{_id};
{ _id };

const update = {
$pull: {
Expand Down Expand Up @@ -604,14 +611,14 @@ class ModelSubscriptions extends RocketChat.models._Base {
// REMOVE
removeByUserId(userId) {
const query =
{'u._id': userId};
{ 'u._id': userId };

return this.remove(query);
}

removeByRoomId(roomId) {
const query =
{rid: roomId};
{ rid: roomId };

return this.remove(query);
}
Expand Down
4 changes: 3 additions & 1 deletion packages/rocketchat-livechat/.app/client/views/messages.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,9 @@ Template.messages.helpers({
agentData.email = agent.emails[0].address;
}

if (agent.customFields && agent.customFields.phone) {
if (agent.phone && agent.phone.length > 0) {
agentData.phone = agent.phone[0].phoneNumber;
} else if (agent.customFields && agent.customFields.phone) {
agentData.phone = agent.customFields.phone;
}

Expand Down
1 change: 1 addition & 0 deletions packages/rocketchat-livechat/server/models/Users.js
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ RocketChat.models.Users.getAgentInfo = function(agentId) {
fields: {
name: 1,
username: 1,
phone: 1,
customFields: 1
}
};
Expand Down
Loading

0 comments on commit 5287b16

Please sign in to comment.