Skip to content

Commit

Permalink
Merge branch 'develop' of github.com:RocketChat/Rocket.Chat into ui-k…
Browse files Browse the repository at this point in the history
…it.2.0-turbo

* 'develop' of github.com:RocketChat/Rocket.Chat:
  Regression: Fix app user status change for non-existing user (#16458)
  [FIX] `stdout` streamer infinite loop (#16452)
  Regression: Fix sending a message not scrolling to bottom (#16451)
  LingoHub based on develop (#16450)
  [IMPROVE] Changes App user's status when the app was enabled/disabled (#16392)
  [IMPROVE] Log as info level when Method Rate Limiters are reached (#16446)
  Use GitHub Actions to store builds (#16443)
  [NEW] Sort the Omnichannel Chat list according to the user preferences (#16437)
  Regression: recent opened rooms being marked as read (#16442)
  [FIX] Option to make a channel default  (#16433)
  [NEW] Setting to only send plain text emails (#16065)
  Regression: Fix status bar margins (#16438)
  • Loading branch information
ggazzo committed Feb 4, 2020
2 parents 1f7cf4f + e4ebac7 commit 1b06f24
Show file tree
Hide file tree
Showing 33 changed files with 903 additions and 168 deletions.
42 changes: 23 additions & 19 deletions .github/workflows/build_and_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -146,13 +146,17 @@ jobs:
cd /tmp
tar czf Rocket.Chat.test.tar.gz ./build-test
- name: Store builds
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
run: |
aws s3 cp /tmp/Rocket.Chat.test.tar.gz s3://rocketchatbuild/builds/$GITHUB_SHA/
aws s3 cp /tmp/build/Rocket.Chat.tar.gz s3://rocketchatbuild/builds/$GITHUB_SHA/
- name: Store build for tests
uses: actions/upload-artifact@v1
with:
name: build-test
path: /tmp/Rocket.Chat.test.tar.gz

- name: Store build
uses: actions/upload-artifact@v1
with:
name: build
path: /tmp/build

test:
runs-on: ubuntu-16.04
Expand All @@ -170,10 +174,10 @@ jobs:
mongoDBVersion: ${{ matrix.mongodb-version }} --noprealloc --smallfiles --replSet=rs0

- name: Restore build for tests
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
run: aws s3 cp s3://rocketchatbuild/builds/$GITHUB_SHA/Rocket.Chat.test.tar.gz /tmp/
uses: actions/download-artifact@v1
with:
name: build-test
path: /tmp

- name: Decompress build
run: |
Expand Down Expand Up @@ -349,10 +353,10 @@ jobs:
- uses: actions/checkout@v1

- name: Restore build
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
run: aws s3 cp s3://rocketchatbuild/builds/$GITHUB_SHA/Rocket.Chat.tar.gz /tmp/build/
uses: actions/download-artifact@v1
with:
name: build
path: /tmp/build

- name: Publish assets
env:
Expand Down Expand Up @@ -401,10 +405,10 @@ jobs:
- uses: actions/checkout@v1

- name: Restore build
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
run: aws s3 cp s3://rocketchatbuild/builds/$GITHUB_SHA/Rocket.Chat.tar.gz /tmp/build/
uses: actions/download-artifact@v1
with:
name: build
path: /tmp/build

- name: Unpack build
env:
Expand Down
18 changes: 18 additions & 0 deletions app/apps/server/bridges/activation.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
import { STATUS_MAP } from '../../../../imports/users-presence/server/activeUsers';
import { Users } from '../../../models/server';
import { Notifications } from '../../../notifications/server';

export class AppActivationBridge {
constructor(orch) {
this.orch = orch;
Expand All @@ -16,6 +20,20 @@ export class AppActivationBridge {
}

async appStatusChanged(app, status) {
const user = Users.findOneByAppId(app.getID(), { fields: { username: 1 } });

if (user) {
const { _id, username } = user;
const userStatus = ['auto_enabled', 'manually_enabled'].includes(status) ? 'online' : 'offline';

Users.updateStatusById(_id, userStatus);
Notifications.notifyLogged('user-status', [
_id,
username,
STATUS_MAP[userStatus],
]);
}

await this.orch.getNotifier().appStatusUpdated(app.getID(), status);
}
}
8 changes: 8 additions & 0 deletions app/lib/server/startup/email.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ import { settings } from '../../../settings';

settings.addGroup('Email', function() {
this.section('Style', function() {
this.add('email_plain_text_only', false, {
type: 'boolean',
});

this.add('email_style', `html, body, .body { font-family: -apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,Oxygen,Ubuntu,Cantarell,'Helvetica Neue','Apple Color Emoji','Segoe UI Emoji','Segoe UI Symbol','Meiryo UI',Arial,sans-serif; }
body, .body {
Expand Down Expand Up @@ -103,6 +107,10 @@ settings.addGroup('Email', function() {
multiline: true,
i18nLabel: 'email_style_label',
i18nDescription: 'email_style_description',
enableQuery: {
_id: 'email_plain_text_only',
value: false,
},
});
});

Expand Down
7 changes: 5 additions & 2 deletions app/lib/server/startup/rateLimiter.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ import { RateLimiter } from 'meteor/rate-limit';

import { settings } from '../../../settings';
import { metrics } from '../../../metrics';
import { Logger } from '../../../logger';

const logger = new Logger('RateLimiter', {});

// Get initial set of names already registered for rules
const names = new Set(Object.values(DDPRateLimiter.printRules())
Expand Down Expand Up @@ -107,8 +110,8 @@ const ruleIds = {};

const callback = (message, name) => (reply, input) => {
if (reply.allowed === false) {
console.warn('DDP RATE LIMIT:', message);
console.warn(JSON.stringify({ ...reply, ...input }, null, 2));
logger.info('DDP RATE LIMIT:', message);
logger.info(JSON.stringify({ ...reply, ...input }, null, 2));
metrics.ddpRateLimitExceeded.inc({
limit_name: name,
user_id: input.userId,
Expand Down
14 changes: 5 additions & 9 deletions app/livechat/client/views/sideNav/livechat.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,20 +37,16 @@ Template.livechat.helpers({
open: true,
};

const user = Users.findOne(Meteor.userId(), {
fields: { 'settings.preferences.sidebarShowUnread': 1 },
});
const user = Meteor.userId();

if (getUserPreference(user, 'sidebarShowUnread')) {
query.alert = { $ne: true };
}

return ChatSubscription.find(query, {
sort: {
t: 1,
fname: 1,
},
});
const sortBy = getUserPreference(user, 'sidebarSortby');
const sort = sortBy === 'activity' ? { _updatedAt: - 1 } : { fname: 1 };

return ChatSubscription.find(query, { sort });
},

inquiries() {
Expand Down
2 changes: 1 addition & 1 deletion app/logger/server/streamer.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ stdoutStreamer.allowRead(function() {

Meteor.startup(() => {
const handler = (string, item) => {
stdoutStreamer.emit('stdout', {
stdoutStreamer.emitWithoutBroadcast('stdout', {
...item,
});
};
Expand Down
12 changes: 11 additions & 1 deletion app/mailer/server/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,13 @@ export const replaceEscaped = (str, data = {}) => replace(str, {
return ret;
}, {}),
});
export const wrap = (html, data = {}) => replaceEscaped(body.replace('{{body}}', html), data);
export const wrap = (html, data = {}) => {
if (settings.get('email_plain_text_only')) {
return replace(html, data);
}

return replaceEscaped(body.replace('{{body}}', html), data);
};
export const inlinecss = (html) => juice.inlineContent(html, Settings.get('email_style'));
export const getTemplate = (template, fn, escape = true) => {
let html = '';
Expand Down Expand Up @@ -103,6 +109,10 @@ export const sendNoWrap = ({ to, from, replyTo, subject, html, text, headers })
text = stripHtml(html);
}

if (settings.get('email_plain_text_only')) {
html = undefined;
}

Meteor.defer(() => Email.send({ to, from, replyTo, subject, html, text, headers }));
};

Expand Down
16 changes: 16 additions & 0 deletions app/models/server/models/Users.js
Original file line number Diff line number Diff line change
Expand Up @@ -429,6 +429,12 @@ export class Users extends Base {
return this.find(query, options);
}

findOneByAppId(appId, options) {
const query = { appId };

return this.findOne(query, options);
}

findOneByImportId(_id, options) {
return this.findOne({ importIds: _id }, options);
}
Expand Down Expand Up @@ -843,6 +849,16 @@ export class Users extends Base {
return this.update(_id, update);
}

updateStatusById(_id, status) {
const update = {
$set: {
status,
},
};

return this.update(_id, update);
}

setServiceId(_id, serviceName, serviceId) {
const update = { $set: {} };

Expand Down
1 change: 1 addition & 0 deletions app/theme/client/imports/general/base_old.css
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@
top: 0;

width: 100%;
margin-top: 0 !important;
padding: 2px;

border-width: 0 0 1px;
Expand Down
4 changes: 2 additions & 2 deletions app/ui-admin/client/rooms/adminRooms.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,8 @@ Template.adminRooms.onCreated(function() {
template: 'channelSettingsDefault',
data() {
return {
session: Session.get('adminRoomsSelected'),
data: instance.tabBarData.get(),
room: instance.tabBarData.get().room,
onSuccess: instance.tabBarData.get().onSuccess,
};
},
validation() {
Expand Down
2 changes: 1 addition & 1 deletion app/ui-admin/client/rooms/channelSettingsDefault.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ Template.channelSettingsDefault.events({
'click .save'(e, t) {
e.preventDefault();

Meteor.call('saveRoomSettings', this.rid, 'default', $('input[name=default]:checked').val(), (err/* , result*/) => {
Meteor.call('saveRoomSettings', Template.instance().room.get()._id, 'default', $('input[name=default]:checked').val(), (err/* , result*/) => {
if (err) {
return handleError(err);
}
Expand Down
2 changes: 1 addition & 1 deletion app/ui-utils/client/lib/RoomManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ export const RoomManager = new function() {
// Do not load command messages into channel
if (msg.t !== 'command') {
const subscription = ChatSubscription.findOne({ rid: record.rid }, { reactive: false });
const isNew = !ChatMessage.findOne(msg._id);
const isNew = !ChatMessage.findOne({ _id: msg._id, temp: { $ne: true } });
upsertMessage({ msg, subscription });

msg.room = {
Expand Down
3 changes: 3 additions & 0 deletions app/ui/client/views/app/room.js
Original file line number Diff line number Diff line change
Expand Up @@ -1276,6 +1276,9 @@ Template.room.onRendered(function() {
}, 300);

const read = _.debounce(function() {
if (rid !== Session.get('openedRoom')) {
return;
}
readMessage.read(rid);
}, 500);

Expand Down
2 changes: 1 addition & 1 deletion imports/users-presence/server/activeUsers.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { UserPresenceEvents } from 'meteor/konecty:user-presence';
import { Notifications } from '../../../app/notifications/server';

// mirror of object in /imports/startup/client/listenActiveUsers.js - keep updated
const STATUS_MAP = {
export const STATUS_MAP = {
offline: 0,
online: 1,
away: 2,
Expand Down
2 changes: 1 addition & 1 deletion packages/rocketchat-i18n/i18n/ca.i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -2958,7 +2958,7 @@
"You_are_logged_in_as": "Sessió iniciada com",
"You_are_not_authorized_to_view_this_page": "No està autoritzat a veure aquesta pàgina.",
"You_can_change_a_different_avatar_too": "Es pot ignorar l'avatar d'aquesta integració.",
"You_can_search_using_RegExp_eg": "Es pot cercar utilitzant expressions regulars, p. ex: <code class='code-colors inline'>/^text$/i</code>",
"You_can_search_using_RegExp_eg": "Podeu fer cerques mitjançant <a href=\"https://en.wikipedia.org/wiki/Regular_expression\" target=\"_blank\">Expressió regular </a>. per exemple. <code class=\"code-colors inline\">/ ^ text $ / i </code>",
"You_can_use_an_emoji_as_avatar": "També es pot utilitzar un emoji com a avatar.",
"You_can_use_webhooks_to_easily_integrate_livechat_with_your_CRM": "Es poden utilitzar webhooks per a integrar fàcilment el xat en viu amb el teu CRM.",
"You_cant_leave_a_livechat_room_Please_use_the_close_button": "No es pot abandonar una sala de xat en viu. Si us plau, utilitzi el botó de tancar.",
Expand Down
1 change: 0 additions & 1 deletion packages/rocketchat-i18n/i18n/cs.i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -2838,7 +2838,6 @@
"set-moderator_description": "Právo nastavit uživatele jako moderátora místnosti",
"set-owner": "Nastavit vlastníka",
"set-owner_description": "Právo nastavit uživatele jako vlastníka místnosti",
"Set_random_password": "Nastavit náhodné heslo",
"set-react-when-readonly": "Reagovat na zprávy v místnostech ke čtení",
"set-react-when-readonly_description": "Právo reagovat na zprávy v místnostech pouze ke čtení",
"set-readonly": "Nastavit pouze ke čtení",
Expand Down
2 changes: 1 addition & 1 deletion packages/rocketchat-i18n/i18n/de-AT.i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -2700,7 +2700,7 @@
"Username_cant_be_empty": "Sie müssen einen Benutzernamen angeben.",
"Username_Change_Disabled": "Der Administrator hat das Ändern von Benutzernamen deaktiviert.",
"Username_denied_the_OTR_session": "__username__ hat die OTR-Session abgelehnt.",
"Username_description": "Der Benutzername wird dazu benutzt, Sie in Nachrichten zu erwähnen.",
"Username_description": "So werden Sie in Nachrichten erwähnt und in der Suche gefunden.",
"Username_doesnt_exist": "Der Benutzer \"%s\" existiert nicht.",
"Username_ended_the_OTR_session": "__username__ hat die OTR-Session beendet.",
"Username_invalid": "<strong>%s</strong> ist kein zulässiger Benutzername.<br/> Verwenden Sie nur Buchstaben, Zahlen, Punkte oder Binde- und Unterstriche.",
Expand Down
Loading

0 comments on commit 1b06f24

Please sign in to comment.