Skip to content
Closed
143 changes: 114 additions & 29 deletions packages/rocketchat-google-vision/.npm/package/npm-shrinkwrap.json

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

3 changes: 2 additions & 1 deletion packages/rocketchat-i18n/i18n/en.i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -1652,6 +1652,7 @@
"Should_exists_a_user_with_this_username": "The user must already exist.",
"Show_agent_email": "Show agent email",
"Show_all": "Show All",
"Show_hidden_rooms_when_unread_messages": "Show hidden rooms when unread messages",
"Show_room_counter_on_sidebar": "Show room counter on sidebar",
"Show_more": "Show more",
"show_offline_users": "show offline users",
Expand Down Expand Up @@ -2122,4 +2123,4 @@
"your_message_optional": "your message (optional)",
"Your_password_is_wrong": "Your password is wrong!",
"Your_push_was_sent_to_s_devices": "Your push was sent to %s devices"
}
}
3 changes: 2 additions & 1 deletion packages/rocketchat-i18n/i18n/es.i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -1113,6 +1113,7 @@
"Should_be_a_URL_of_an_image": "Debe de ser un URL de una imagen. ",
"Should_exists_a_user_with_this_username": "Ya debe existir el usuario.",
"Show_all": "Mostrar todo",
"Show_hidden_rooms_when_unread_messages": "Mostrar salas ocultas al recibir mensajes",
"Show_more": "Mostrar más",
"show_offline_users": "Mostrar usuarios desconectados",
"Show_only_online": "Mostrar sólo en linea",
Expand Down Expand Up @@ -1385,4 +1386,4 @@
"Your_mail_was_sent_to_s": "Su correo electrónico fue enviado a %s",
"Your_password_is_wrong": "Su contraseña es incorrecta!",
"Your_push_was_sent_to_s_devices": "Su push fue enviado a los dispositivos %s"
}
}
1 change: 1 addition & 0 deletions packages/rocketchat-i18n/i18n/pt-BR.i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -1045,6 +1045,7 @@
"Should_be_a_URL_of_an_image": "Deve ser uma URL de uma imagem.",
"Should_exists_a_user_with_this_username": "O usuário já deve existir.",
"Show_all": "Mostrar tudo",
"Show_hidden_rooms_when_unread_messages": "Mostrar salas escondidas ao receber mensagens",
"Show_more": "Mostrar mais",
"show_offline_users": "mostrar usuários offline",
"Show_only_online": "Mostrar apenas online",
Expand Down
1 change: 1 addition & 0 deletions packages/rocketchat-i18n/i18n/pt.i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -1066,6 +1066,7 @@
"Should_be_a_URL_of_an_image": "Deve ser uma URL de uma imagem.",
"Should_exists_a_user_with_this_username": "O usuário já deve existir.",
"Show_all": "Mostrar tudo",
"Show_hidden_rooms_when_unread_messages": "Mostrar salas escondidas ao receber mensagens",
"Show_more": "Mostrar mais",
"show_offline_users": "mostrar usuários offline",
"Show_only_online": "Mostrar apenas online",
Expand Down
17 changes: 16 additions & 1 deletion packages/rocketchat-lib/server/lib/notifyUsersOnMessage.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,10 +105,25 @@ RocketChat.callbacks.add('afterSaveMessage', function(message, room) {
// Update all the room activity tracker fields
RocketChat.models.Rooms.incMsgCountAndSetLastMessageById(message.rid, 1, message.ts, RocketChat.settings.get('Store_Last_Message') && message);

// Update all other subscriptions to alert their owners but witout incrementing
// Update all other subscriptions to alert their owners but without incrementing
// the unread counter, as it is only for mentions and direct messages
RocketChat.models.Subscriptions.setAlertForRoomIdExcludingUserId(message.rid, message.u._id);

const subscriptions = RocketChat.models.Subscriptions.findByRoomIdAndNotUserId(message.rid, message.u._id).fetch();

let user = {};
let openRoom;

subscriptions.forEach(subscription => {
user = RocketChat.models.Users.findOneById(subscription.u._id);

openRoom = user && user.settings && user.settings.preferences && user.settings.preferences.showHiddenRoomsWhenUnreadMessages;

if (typeof openRoom === 'undefined' || openRoom === true) {
RocketChat.models.Subscriptions.setOpenRoomBySubscriptionId(subscription._id);
}
});

return message;

}, RocketChat.callbacks.priority.LOW, 'notifyUsersOnMessage');
18 changes: 14 additions & 4 deletions packages/rocketchat-lib/server/models/Subscriptions.js
Original file line number Diff line number Diff line change
Expand Up @@ -418,27 +418,37 @@ class ModelSubscriptions extends RocketChat.models._Base {

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

setAlertForRoomIdExcludingUserId(roomId, userId) {
const query = {
rid: roomId,
'u._id': {
$ne: userId
},
$or: [
{ alert: { $ne: true } },
{ open: { $ne: true } }
{ alert: { $ne: true } }
]
};

const update = {
$set: {
alert: true,
open: true
alert: true
}
};

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

setOpenRoomBySubscriptionId(_id) {
const update = {
$set: {
open: true
}
};

return this.update(_id, update);
}

setBlockedByRoomId(rid, blocked, blocker) {
const query = {
rid,
Expand Down
8 changes: 8 additions & 0 deletions packages/rocketchat-ui-account/client/accountPreferences.html
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,14 @@ <h1>{{_ "Messages"}}</h1>
</div>
{{/with}}

<div class="input-line double-col" id="showHiddenRoomsWhenUnreadMessages">
<label>{{_ "Show_hidden_rooms_when_unread_messages"}}</label>
<div>
<label><input type="radio" name="showHiddenRoomsWhenUnreadMessages" value="1" checked="{{checked 'showHiddenRoomsWhenUnreadMessages' true true}}"/> {{_ "True"}}</label>
<label><input type="radio" name="showHiddenRoomsWhenUnreadMessages" value="0" checked="{{checked 'showHiddenRoomsWhenUnreadMessages' false}}"/> {{_ "False"}}</label>
</div>
</div>

<div class="input-line double-col" id="sendOnEnter">
<label>{{_ "Enter_Behaviour"}}</label>
<div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ Template.accountPreferences.onCreated(function() {
data.mergeChannels = $('#mergeChannels').find('input:checked').val();
data.sendOnEnter = $('#sendOnEnter').find('select').val();
data.roomsListExhibitionMode = $('select[name=roomsListExhibitionMode]').val();
data.showHiddenRoomsWhenUnreadMessages = $('input[name=showHiddenRoomsWhenUnreadMessages]:checked').val();
data.autoImageLoad = $('input[name=autoImageLoad]:checked').val();
data.emailNotificationMode = $('select[name=emailNotificationMode]').val();
data.desktopNotificationDuration = $('input[name=desktopNotificationDuration]').val();
Expand Down
4 changes: 4 additions & 0 deletions server/methods/saveUserPreferences.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ Meteor.methods({
preferences.unreadAlert = settings.unreadAlert === '1' ? true : false;
}

if (settings.showHiddenRoomsWhenUnreadMessages) {
preferences.showHiddenRoomsWhenUnreadMessages = settings.showHiddenRoomsWhenUnreadMessages === '1';
}

if (settings.notificationsSoundVolume) {
preferences.notificationsSoundVolume = settings.notificationsSoundVolume;
}
Expand Down