Skip to content

Commit

Permalink
Merge branch 'develop' of github.com:RocketChat/Rocket.Chat into adm/…
Browse files Browse the repository at this point in the history
…users_and_rooms

* 'develop' of github.com:RocketChat/Rocket.Chat:
  [FIX] Omnichannel SMS / WhatsApp integration errors due to missing location data (#17288)
  [FIX] User search on directory not working correctly (#17299)
  [FIX] Can not save Unread Tray Icon Alert user preference (#16288) (#16313)
  [FIX] Variable rendering problem on Import recent history page (#15997)
  [FIX] Admin panel custom sounds, multiple sound playback fix and added single play/pause button (#16215)
  [FIX] Discussions created from inside DMs were not working (#17282)
  [FIX] translation for nl (#16742)
  [FIX] No maxlength defined for custom user status (#16534)
  [FIX] Directory users email sort button (#16606)
  [FIX] In Create a New Channel, input should be focused on channel name instead of invite users (#16405)
  [FIX] Email not verified message (#16236)
  [FIX] Directory default tab (#17283)
  Update ru.i18n.json (#16869)
  [FIX] Avatar on sidebar when showing real names (#17286)
  Update Apps-Engine to stable version (#17287)
  [NEW][ENTERPRISE] Auto close abandoned Omnichannel rooms (#17055)
  Static props for Administration route components (#17285)
  [NEW] Default favorite channels (#16025)
  Apply $and helper to message template (#17280)
  • Loading branch information
gabriellsh committed Apr 14, 2020
2 parents 68d55a9 + e25afb4 commit ad7b0a5
Show file tree
Hide file tree
Showing 52 changed files with 528 additions and 84 deletions.
1 change: 1 addition & 0 deletions app/api/server/lib/rooms.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export async function findAdminRooms({ uid, filter, types = [], pagination: { of
unmuted: 1,
ro: 1,
default: 1,
favorite: 1,
featured: 1,
topic: 1,
msgs: 1,
Expand Down
2 changes: 1 addition & 1 deletion app/api/server/v1/channels.js
Original file line number Diff line number Diff line change
Expand Up @@ -758,7 +758,7 @@ API.v1.addRoute('channels.setDefault', { authRequired: true }, {
}

Meteor.runAsUser(this.userId, () => {
Meteor.call('saveRoomSettings', findResult._id, 'default', this.bodyParams.default.toString());
Meteor.call('saveRoomSettings', findResult._id, 'default', ['true', '1'].includes(this.bodyParams.default.toString().toLowerCase()));
});

return API.v1.success({
Expand Down
5 changes: 4 additions & 1 deletion app/channel-settings/server/methods/saveRoomSettings.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import { saveRoomTokenpass } from '../functions/saveRoomTokens';
import { saveStreamingOptions } from '../functions/saveStreamingOptions';
import { RoomSettingsEnum, roomTypes } from '../../../utils';

const fields = ['featured', 'roomName', 'roomTopic', 'roomAnnouncement', 'roomCustomFields', 'roomDescription', 'roomType', 'readOnly', 'reactWhenReadOnly', 'systemMessages', 'default', 'joinCode', 'tokenpass', 'streamingOptions', 'retentionEnabled', 'retentionMaxAge', 'retentionExcludePinned', 'retentionFilesOnly', 'retentionOverrideGlobal', 'encrypted'];
const fields = ['featured', 'roomName', 'roomTopic', 'roomAnnouncement', 'roomCustomFields', 'roomDescription', 'roomType', 'readOnly', 'reactWhenReadOnly', 'systemMessages', 'default', 'joinCode', 'tokenpass', 'streamingOptions', 'retentionEnabled', 'retentionMaxAge', 'retentionExcludePinned', 'retentionFilesOnly', 'retentionOverrideGlobal', 'encrypted', 'favorite'];
Meteor.methods({
saveRoomSettings(rid, settings, value) {
const userId = Meteor.userId();
Expand Down Expand Up @@ -221,6 +221,9 @@ Meteor.methods({
case 'encrypted':
Rooms.saveEncryptedById(rid, value);
break;
case 'favorite':
Rooms.saveFavoriteById(rid, value.favorite, value.defaultValue);
break;
}
});

Expand Down
7 changes: 5 additions & 2 deletions app/custom-sounds/client/admin/adminSounds.html
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,11 @@
</td>
<td width="20%">
<div class="rc-table-wrapper">
{{>icon _id=_id icon="play" block="icon-play-circled"}}
{{>icon _id=_id icon="pause" block="icon-pause-circled"}}
{{#if isPlaying _id}}
{{>icon _id=_id icon="pause" block="icon-pause-circled"}}
{{else}}
{{>icon _id=_id icon="play" block="icon-play-circled"}}
{{/if}}
{{>icon _id=_id icon="ban" block="icon-reset-circled"}}
</div>
</td>
Expand Down
18 changes: 16 additions & 2 deletions app/custom-sounds/client/admin/adminSounds.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ Template.adminSounds.helpers({
const instance = Template.instance();
return instance.filter && instance.filter.get();
},
isPlaying(_id) {
return Template.instance().isPlayingId.get() === _id;
},
customsounds() {
return Template.instance().sounds.get();
},
Expand Down Expand Up @@ -62,6 +65,7 @@ Template.adminSounds.onCreated(function() {
this.query = new ReactiveVar({});
this.isLoading = new ReactiveVar(false);
this.filter = new ReactiveVar('');
this.isPlayingId = new ReactiveVar('');

this.tabBar = new RocketChatTabBar();
this.tabBar.showGroup(FlowRouter.current().route.name);
Expand Down Expand Up @@ -138,18 +142,28 @@ Template.adminSounds.events({
t.filter.set(e.currentTarget.value);
t.offset.set(0);
},
'click .icon-play-circled'(e) {
'click .icon-play-circled'(e, t) {
e.preventDefault();
e.stopPropagation();
CustomSounds.play(this._id);
const audio = document.getElementById(t.isPlayingId.get());
if (audio) {
audio.pause();
}
document.getElementById(this._id).onended = () => {
t.isPlayingId.set('');
this.onended = null;
};
t.isPlayingId.set(this._id);
},
'click .icon-pause-circled'(e) {
'click .icon-pause-circled'(e, t) {
e.preventDefault();
e.stopPropagation();
const audio = document.getElementById(this._id);
if (audio && !audio.paused) {
audio.pause();
}
t.isPlayingId.set('');
},
'click .icon-reset-circled'(e) {
e.preventDefault();
Expand Down
4 changes: 3 additions & 1 deletion app/discussion/server/methods/createDiscussion.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { hasAtLeastOnePermission, canAccessRoom } from '../../../authorization/s
import { Messages, Rooms } from '../../../models/server';
import { createRoom, addUserToRoom, sendMessage, attachMessage } from '../../../lib/server';
import { settings } from '../../../settings/server';
import { roomTypes } from '../../../utils/server';

const getParentRoom = (rid) => {
const room = Rooms.findOne(rid);
Expand Down Expand Up @@ -86,7 +87,8 @@ const create = ({ prid, pmid, t_name, reply, users }) => {
// auto invite the replied message owner
const invitedUsers = message ? [message.u.username, ...users] : users;

const discussion = createRoom(p_room.t, name, user.username, [...new Set(invitedUsers)], false, {
const type = roomTypes.getConfig(p_room.t).getDiscussionType();
const discussion = createRoom(type, name, user.username, [...new Set(invitedUsers)], false, {
fname: t_name,
description: message.msg, // TODO discussions remove
topic: p_room.name, // TODO discussions remove
Expand Down
2 changes: 1 addition & 1 deletion app/importer/client/admin/importOperationSummary.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<template name="importOperationSummary">
<span style="font-weight: 600;">{{_ "Import_Type"}}:</span>
<span>{{ type}} [{{ importerKey}}]</span>
<span>{{_ type}} [{{ importerKey}}]</span>
<br/>

<span style="font-weight: 600;">{{_ "Last_Updated"}}:</span>
Expand Down
15 changes: 11 additions & 4 deletions app/lib/lib/roomTypes/direct.js
Original file line number Diff line number Diff line change
Expand Up @@ -186,16 +186,23 @@ export class DirectMessageRoomType extends RoomTypeConfig {
}

getAvatarPath(roomData, subData) {
if (!roomData && !subData) {
return '';
}

if (this.isGroupChat(roomData)) {
return getAvatarURL({ username: roomData.uids.length + roomData.usernames.join() });
}

if (roomData) {
return getUserAvatarURL(roomData.name || this.roomName(roomData));
const sub = subData || Subscriptions.findOne({ rid: roomData._id }, { fields: { name: 1 } });

if (sub && sub.name) {
return getUserAvatarURL(sub.name);
}

const sub = subData || Subscriptions.findOne({ rid: roomData._id }, { fields: { name: 1 } });
return getUserAvatarURL(sub.name || this.roomName(roomData));
if (roomData) {
return getUserAvatarURL(roomData.name || this.roomName(roomData)); // rooms should have no name for direct messages...
}
}

includeInDashboard() {
Expand Down
4 changes: 4 additions & 0 deletions app/lib/lib/roomTypes/public.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,4 +133,8 @@ export class PublicRoomType extends RoomTypeConfig {

return getAvatarURL({ username: `@${ this.roomName(roomData) }` });
}

getDiscussionType() {
return 'c';
}
}
1 change: 1 addition & 0 deletions app/lib/server/functions/addUserToDefaultChannels.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export const addUserToDefaultChannels = function(user, silenced) {
unread: 1,
userMentions: 1,
groupMentions: 0,
...room.favorite && { f: true },
});

// Insert user joined message
Expand Down
3 changes: 1 addition & 2 deletions app/lib/server/startup/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,8 @@ settings.addGroup('Accounts', function() {
type: 'boolean',
public: true,
});
this.add('Accounts_SearchFields', '', {
this.add('Accounts_SearchFields', 'username, name, bio', {
type: 'string',
public: true,
});
this.add('Accounts_Directory_DefaultView', 'channels', {
type: 'select',
Expand Down
2 changes: 1 addition & 1 deletion app/livechat/imports/server/rest/sms.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ const defineVisitor = (smsNumber) => {
};

const normalizeLocationSharing = (payload) => {
const { extra: { fromLatitude: latitude, fromLongitude: longitude } } = payload;
const { extra: { fromLatitude: latitude, fromLongitude: longitude } = { } } = payload;
if (!latitude || !longitude) {
return;
}
Expand Down
24 changes: 24 additions & 0 deletions app/livechat/server/hooks/markRoomNotResponded.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@

import { callbacks } from '../../../callbacks';
import { LivechatRooms } from '../../../models';

callbacks.add('afterSaveMessage', function(message, room) {
// skips this callback if the message was edited
if (!message || message.editedAt) {
return message;
}

// if the message has not a token, it was sent by the agent, so ignore it
if (!message.token) {
return message;
}

// check if room is yet awaiting for response
if (typeof room.t !== 'undefined' && room.t === 'l' && room.waitingResponse) {
return message;
}

LivechatRooms.setNotResponseByRoomId(room._id);

return message;
}, callbacks.priority.LOW, 'markRoomNotResponded');
2 changes: 1 addition & 1 deletion app/livechat/server/hooks/processRoomAbandonment.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,5 +58,5 @@ callbacks.add('livechat.closeRoom', (room) => {
return;
}
const secondsSinceLastAgentResponse = getSecondsSinceLastAgentResponse(room, agentLastMessage);
LivechatRooms.setVisitorInactivityInSecondsByRoomId(room._id, secondsSinceLastAgentResponse);
LivechatRooms.setVisitorInactivityInSecondsById(room._id, secondsSinceLastAgentResponse);
}, callbacks.priority.HIGH, 'process-room-abandonment');
1 change: 1 addition & 0 deletions app/livechat/server/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import './hooks/sendToCRM';
import './hooks/sendToFacebook';
import './hooks/processRoomAbandonment';
import './hooks/saveLastVisitorMessageTs';
import './hooks/markRoomNotResponded';
import './methods/addAgent';
import './methods/addManager';
import './methods/changeLivechatStatus';
Expand Down
17 changes: 16 additions & 1 deletion app/models/server/models/LivechatRooms.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export class LivechatRooms extends Base {
this.tryEnsureIndex({ 'metrics.chatDuration': 1 }, { sparse: true });
this.tryEnsureIndex({ 'metrics.serviceTimeDuration': 1 }, { sparse: true });
this.tryEnsureIndex({ 'metrics.visitorInactivity': 1 }, { sparse: true });
this.tryEnsureIndex({ 'omnichannel.predictedVisitorAbandonmentAt': 1 }, { sparse: true });
}

findLivechat(filter = {}, offset = 0, limit = 20) {
Expand Down Expand Up @@ -286,6 +287,20 @@ export class LivechatRooms extends Base {
});
}

setNotResponseByRoomId(roomId) {
return this.update({
_id: roomId,
t: 'l',
}, {
$set: {
waitingResponse: true,
},
$unset: {
responseBy: 1,
},
});
}

setAgentLastMessageTs(roomId) {
return this.update({
_id: roomId,
Expand Down Expand Up @@ -566,7 +581,7 @@ export class LivechatRooms extends Base {
return this.update(query, update);
}

setVisitorInactivityInSecondsByRoomId(roomId, visitorInactivity) {
setVisitorInactivityInSecondsById(roomId, visitorInactivity) {
const query = {
_id: roomId,
};
Expand Down
13 changes: 12 additions & 1 deletion app/models/server/models/Rooms.js
Original file line number Diff line number Diff line change
Expand Up @@ -907,13 +907,24 @@ export class Rooms extends Base {

const update = {
$set: {
default: defaultValue === 'true',
default: defaultValue,
},
};

return this.update(query, update);
}

saveFavoriteById(_id, favorite, defaultValue) {
const query = { _id };

const update = {
...favorite && defaultValue && { $set: { favorite } },
...(!favorite || !defaultValue) && { $unset: { favorite: 1 } },
};

return this.update(query, update);
}

saveRetentionEnabledById(_id, value) {
const query = { _id };

Expand Down
11 changes: 3 additions & 8 deletions app/models/server/models/Users.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export class Users extends Base {

this.tryEnsureIndex({ roles: 1 }, { sparse: 1 });
this.tryEnsureIndex({ name: 1 });
this.tryEnsureIndex({ name: 'text', username: 'text', bio: 'text' }, { default_language: 'none', language_override: 'documentLanguage' });
this.tryEnsureIndex({ bio: 1 });
this.tryEnsureIndex({ createdAt: 1 });
this.tryEnsureIndex({ lastLogin: 1 });
this.tryEnsureIndex({ status: 1 });
Expand Down Expand Up @@ -641,21 +641,16 @@ export class Users extends Base {
const searchFields = forcedSearchFields || settings.get('Accounts_SearchFields').trim().split(',');

const orStmt = _.reduce(searchFields, function(acc, el) {
el = el.trim();
if (el && !['name', 'username', 'bio'].includes(el)) {
acc.push({ [el]: termRegex });
}
acc.push({ [el.trim()]: termRegex });
return acc;
}, []);

const query = {
$and: [
{
active: true,
$or: [{
$text: { $search: searchTerm },
}, ...orStmt],
username: { $exists: true, $nin: exceptions },
$or: orStmt,
},
...extraQuery,
],
Expand Down
2 changes: 1 addition & 1 deletion app/ui-account/client/accountPreferences.html
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ <h1>{{_ "Notifications"}}</h1>
{{/if}}
</div>
</div>
<div class="input-line double-col" id="unreadAlert">
<div class="input-line double-col" id="desktopNotificationRequireInteraction">
<label class="setting-label">{{_ "Notification_RequireInteraction"}}</label>
<div class="setting-field">
<label><input type="radio" name="desktopNotificationRequireInteraction" value="true" checked="{{checked 'desktopNotificationRequireInteraction' true}}"/> {{_ "On"}}</label>
Expand Down
4 changes: 2 additions & 2 deletions app/ui-admin/client/components/AdministrationRouter.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ import React, { lazy, useMemo, Suspense } from 'react';
import { useAdminSideNav } from '../hooks/useAdminSideNav';
import PageSkeleton from './PageSkeleton';

function AdministrationRouter({ lazyRouteComponent }) {
function AdministrationRouter({ lazyRouteComponent, ...props }) {
useAdminSideNav();

const LazyRouteComponent = useMemo(() => lazy(lazyRouteComponent), [lazyRouteComponent]);

return <Suspense fallback={<PageSkeleton />}>
<LazyRouteComponent />
<LazyRouteComponent {...props} />
</Suspense>;
}

Expand Down
2 changes: 1 addition & 1 deletion app/ui-admin/client/rooms/adminRooms.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ Template.adminRooms.onCreated(function() {

ChannelSettings.addOption({
group: ['admin-room'],
id: 'make-default',
id: 'make-featured',
template: 'channelSettingsFeatured',
data() {
return {
Expand Down
3 changes: 3 additions & 0 deletions app/ui-admin/client/rooms/channelSettingsDefault.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
{{#if editing 'default'}}
<label><input type="radio" name="default" class="editing" value="true" checked="{{$eq roomDefault true}}" /> {{_ "True"}}</label>
<label><input type="radio" name="default" value="false" checked="{{$neq roomDefault true}}" /> {{_ "False"}}</label>
{{#if roomDefault}}
<label><input type="checkbox" name="favorite" checked="{{isFavorite}}" /> {{_ "Set_as_favorite"}}</label>
{{/if}}
<button type="button" class="button cancel">{{_ "Cancel"}}</button>
<button type="button" class="button primary save">{{_ "Save"}}</button>
{{else}}
Expand Down
Loading

0 comments on commit ad7b0a5

Please sign in to comment.