Skip to content

Commit

Permalink
Merge branch 'develop' into improve/videoconf-first-phase
Browse files Browse the repository at this point in the history
  • Loading branch information
ggazzo committed Jul 19, 2022
2 parents 05121c1 + 55b2617 commit 22ed6e9
Show file tree
Hide file tree
Showing 17 changed files with 239 additions and 521 deletions.
26 changes: 9 additions & 17 deletions apps/meteor/app/api/server/lib/users.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { escapeRegExp } from '@rocket.chat/string-helpers';
import { IUser } from '@rocket.chat/core-typings';
import { Filter } from 'mongodb';
import { Users } from '@rocket.chat/models';
import type { Mongo } from 'meteor/mongo';

import { hasPermissionAsync } from '../../../authorization/server/functions/hasPermission';

Expand Down Expand Up @@ -80,6 +81,7 @@ export function getNonEmptyFields(fields: { [k: string]: 1 | 0 }): { [k: string]
active: 1,
avatarETag: 1,
lastLogin: 1,
type: 1,
} as const;

if (!fields || Object.keys(fields).length === 0) {
Expand All @@ -89,29 +91,19 @@ export function getNonEmptyFields(fields: { [k: string]: 1 | 0 }): { [k: string]
return { ...defaultFields, ...fields };
}

const _defaultQuery = {
$or: [
{ 'emails.address': { $regex: '', $options: 'i' } },
{ username: { $regex: '', $options: 'i' } },
{ name: { $regex: '', $options: 'i' } },
],
};

/**
* get the default query if **query** is empty (`{}`) or `undefined`/`null`
* @param {Object|null|undefined} query the query from parsed jsonQuery
*/

type Query = { [k: string]: unknown };
export function getNonEmptyQuery(query: Query): typeof _defaultQuery | (typeof _defaultQuery & Query) {
const defaultQuery = {
$or: [
{ 'emails.address': { $regex: '', $options: 'i' } },
{ username: { $regex: '', $options: 'i' } },
{ name: { $regex: '', $options: 'i' } },
],
export function getNonEmptyQuery<T extends IUser>(query: Mongo.Query<T> | undefined | null, canSeeAllUserInfo?: boolean): Mongo.Query<T> {
const defaultQuery: Mongo.Query<IUser> = {
$or: [{ username: { $regex: '', $options: 'i' } }, { name: { $regex: '', $options: 'i' } }],
};

if (canSeeAllUserInfo) {
defaultQuery.$or?.push({ 'emails.address': { $regex: '', $options: 'i' } });
}

if (!query || Object.keys(query).length === 0) {
return defaultQuery;
}
Expand Down
3 changes: 2 additions & 1 deletion apps/meteor/app/api/server/v1/users.ts
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,7 @@ API.v1.addRoute(
const { offset, count } = this.getPaginationItems();
const { sort, fields, query } = this.parseJsonQuery();

const nonEmptyQuery = getNonEmptyQuery(query);
const nonEmptyQuery = getNonEmptyQuery(query, hasPermission(this.userId, 'view-full-other-user-info'));
const nonEmptyFields = getNonEmptyFields(fields);

const inclusiveFields = getInclusiveFields(nonEmptyFields);
Expand All @@ -414,6 +414,7 @@ API.v1.addRoute(
inclusiveFieldsKeys.includes('emails') && 'emails.address.*',
inclusiveFieldsKeys.includes('username') && 'username.*',
inclusiveFieldsKeys.includes('name') && 'name.*',
inclusiveFieldsKeys.includes('type') && 'type.*',
].filter(Boolean) as string[],
this.queryOperations,
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,27 @@ const OmnichannelRoomIcon = new (class extends Emitter {
if (this.icons.has(`${appId}-${icon}`)) {
return `${appId}-${icon}`;
}
APIClient.get(`/apps/public/${appId}/get-sidebar-icon`, { icon }).then((response: any) => {
this.icons.set(
`${appId}-${icon}`,
DOMPurify.sanitize(response, {
FORBID_ATTR: ['id'],
NAMESPACE: 'http://www.w3.org/2000/svg',
USE_PROFILES: { svg: true, svgFilters: true },
})
.replace(`<svg`, `<symbol id="${appId}-${icon}"`)
.replace(`</svg>`, '</symbol>'),
);
this.emit('change');
this.emit(`${appId}-${icon}`);
});
// TODO: update the apps icons to send JSON instead of a string. This will allow us to use APIClient.get()
APIClient.send(`/apps/public/${appId}/get-sidebar-icon?icon=${icon}`, 'GET')
.then((response: any) => {
response.text().then((text: any) => {
this.icons.set(
`${appId}-${icon}`,
DOMPurify.sanitize(text, {
FORBID_ATTR: ['id'],
NAMESPACE: 'http://www.w3.org/2000/svg',
USE_PROFILES: { svg: true, svgFilters: true },
})
.replace(`<svg`, `<symbol id="${appId}-${icon}"`)
.replace(`</svg>`, '</symbol>'),
);
this.emit('change');
this.emit(`${appId}-${icon}`);
});
})
.catch((error: any) => {
console.error('error from get-sidebar-icon', error);
});
}
})();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,34 +24,55 @@ export const OmnichannelRoomIconProvider: FC = ({ children }) => {

return (
<OmnichannelRoomIconContext.Provider
value={useMemo(
() => ({
value={useMemo(() => {
const extractSnapshot = (app: string, iconName: string): AsyncState<string> => {
const icon = OmnichannelRoomIcon.get(app, iconName);

if (icon) {
return {
phase: AsyncStatePhase.RESOLVED,
value: icon,
error: undefined,
};
}

return {
phase: AsyncStatePhase.LOADING,
value: undefined,
error: undefined,
};
};

// We cache all the icons here, so that we can use them in the OmnichannelRoomIcon component
const snapshots = new Map<string, AsyncState<string>>();

return {
queryIcon: (
app: string,
iconName: string,
): [subscribe: (onStoreChange: () => void) => () => void, getSnapshot: () => AsyncState<string>] => [
(callback): (() => void) => OmnichannelRoomIcon.on(`${app}-${iconName}`, callback),
(callback): (() => void) =>
OmnichannelRoomIcon.on(`${app}-${iconName}`, () => {
snapshots.set(`${app}-${iconName}`, extractSnapshot(app, iconName));

// Then we call the callback (onStoreChange), signaling React to re-render
callback();
}),

// No problem here, because it's return value is a cached in the snapshots map on subsequent calls
(): AsyncState<string> => {
const icon = OmnichannelRoomIcon.get(app, iconName);
let snapshot = snapshots.get(`${app}-${iconName}`);

if (!icon) {
return {
phase: AsyncStatePhase.LOADING,
value: undefined,
error: undefined,
};
if (!snapshot) {
snapshot = extractSnapshot(app, iconName);
snapshots.set(`${app}-${iconName}`, snapshot);
}

return {
phase: AsyncStatePhase.RESOLVED,
value: icon,
error: undefined,
};
return snapshot;
},
],
}),
[],
)}
};
}, [])}
>
{createPortal(
<svg
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,5 +68,5 @@ settings.watch('Canned_Responses_Enable', function (value) {
return;
}

callbacks.add('beforeSaveMessage', handleBeforeSaveMessage, callbacks.priority.MEDIUM, 'canned-responses-replace-placeholders');
callbacks.add('beforeSaveMessage', handleBeforeSaveMessage, callbacks.priority.HIGH * 2, 'canned-responses-replace-placeholders');
});
10 changes: 5 additions & 5 deletions apps/meteor/ee/server/services/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@
"dependencies": {
"@rocket.chat/apps-engine": "^1.32.0",
"@rocket.chat/core-typings": "workspace:^",
"@rocket.chat/emitter": "~0.31.13",
"@rocket.chat/message-parser": "~0.32.0-dev.5",
"@rocket.chat/emitter": "next",
"@rocket.chat/message-parser": "next",
"@rocket.chat/model-typings": "workspace:^",
"@rocket.chat/models": "workspace:^",
"@rocket.chat/rest-typings": "workspace:^",
"@rocket.chat/string-helpers": "~0.31.13",
"@rocket.chat/ui-kit": "~0.31.13",
"@rocket.chat/string-helpers": "next",
"@rocket.chat/ui-kit": "next",
"ajv": "^8.11.0",
"bcrypt": "^5.0.1",
"body-parser": "^1.20.0",
Expand All @@ -54,7 +54,7 @@
"ws": "^8.8.0"
},
"devDependencies": {
"@rocket.chat/icons": "^0.31.13",
"@rocket.chat/icons": "next",
"@types/cookie": "^0.5.1",
"@types/cookie-parser": "^1.4.3",
"@types/ejson": "^2.2.0",
Expand Down
30 changes: 15 additions & 15 deletions apps/meteor/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -195,32 +195,32 @@
"@rocket.chat/apps-engine": "1.33.0",
"@rocket.chat/cas-validate": "workspace:^",
"@rocket.chat/core-typings": "workspace:^",
"@rocket.chat/css-in-js": "~0.31.15-dev.6",
"@rocket.chat/emitter": "~0.31.15-dev.6",
"@rocket.chat/css-in-js": "next",
"@rocket.chat/emitter": "next",
"@rocket.chat/favicon": "workspace:^",
"@rocket.chat/forked-matrix-appservice-bridge": "^4.0.1",
"@rocket.chat/forked-matrix-bot-sdk": "^0.6.0-beta.2",
"@rocket.chat/fuselage": "^0.32.0-dev.83",
"@rocket.chat/fuselage-hooks": "~0.31.15-dev.6",
"@rocket.chat/fuselage-polyfills": "~0.31.15-dev.6",
"@rocket.chat/fuselage-toastbar": "^0.32.0-dev.47",
"@rocket.chat/fuselage-tokens": "^0.32.0-dev.23",
"@rocket.chat/fuselage-ui-kit": "~0.32.0-dev.23",
"@rocket.chat/fuselage": "next",
"@rocket.chat/fuselage-hooks": "next",
"@rocket.chat/fuselage-polyfills": "next",
"@rocket.chat/fuselage-toastbar": "next",
"@rocket.chat/fuselage-tokens": "next",
"@rocket.chat/fuselage-ui-kit": "next",
"@rocket.chat/gazzodown": "workspace:^",
"@rocket.chat/icons": "~0.32.0-dev.60",
"@rocket.chat/logo": "~0.32.0-dev.23",
"@rocket.chat/memo": "~0.31.15-dev.6",
"@rocket.chat/message-parser": "~0.32.0-dev.21",
"@rocket.chat/icons": "next",
"@rocket.chat/logo": "next",
"@rocket.chat/memo": "next",
"@rocket.chat/message-parser": "next",
"@rocket.chat/model-typings": "workspace:^",
"@rocket.chat/models": "workspace:^",
"@rocket.chat/mp3-encoder": "0.24.0",
"@rocket.chat/onboarding-ui": "~0.32.0-dev.73",
"@rocket.chat/onboarding-ui": "next",
"@rocket.chat/poplib": "workspace:^",
"@rocket.chat/rest-typings": "workspace:^",
"@rocket.chat/string-helpers": "~0.31.15-dev.6",
"@rocket.chat/string-helpers": "next",
"@rocket.chat/ui-client": "workspace:^",
"@rocket.chat/ui-contexts": "workspace:^",
"@rocket.chat/ui-kit": "~0.32.0-dev.8",
"@rocket.chat/ui-kit": "next",
"@rocket.chat/ui-video-conf": "workspace:^",
"@slack/rtm-api": "^6.0.0",
"@types/cookie": "^0.5.1",
Expand Down
4 changes: 2 additions & 2 deletions ee/apps/ddp-streamer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@
"dependencies": {
"@rocket.chat/apps-engine": "^1.32.0",
"@rocket.chat/core-typings": "workspace:^",
"@rocket.chat/emitter": "~0.31.13",
"@rocket.chat/emitter": "next",
"@rocket.chat/model-typings": "workspace:^",
"@rocket.chat/models": "workspace:^",
"@rocket.chat/rest-typings": "workspace:^",
"@rocket.chat/string-helpers": "~0.31.13",
"@rocket.chat/string-helpers": "next",
"@rocket.chat/ui-contexts": "workspace:^",
"colorette": "^1.4.0",
"ejson": "^2.2.2",
Expand Down
6 changes: 3 additions & 3 deletions packages/core-typings/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
],
"dependencies": {
"@rocket.chat/apps-engine": "^1.32.0",
"@rocket.chat/icons": "^0.31.13",
"@rocket.chat/message-parser": "^0.32.0-dev.5",
"@rocket.chat/ui-kit": "^0.31.13"
"@rocket.chat/icons": "next",
"@rocket.chat/message-parser": "next",
"@rocket.chat/ui-kit": "next"
}
}
6 changes: 3 additions & 3 deletions packages/gazzodown/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
"@babel/core": "^7.18.5",
"@mdx-js/react": "^1.6.22",
"@rocket.chat/core-typings": "workspace:^",
"@rocket.chat/css-in-js": "^0.31.14",
"@rocket.chat/css-in-js": "next",
"@rocket.chat/fuselage": "next",
"@rocket.chat/fuselage-tokens": "^0.31.14",
"@rocket.chat/fuselage-tokens": "next",
"@rocket.chat/message-parser": "next",
"@rocket.chat/styled": "^0.31.14",
"@rocket.chat/styled": "next",
"@rocket.chat/ui-client": "workspace:^",
"@rocket.chat/ui-contexts": "workspace:^",
"@storybook/addon-actions": "^6.5.9",
Expand Down
6 changes: 3 additions & 3 deletions packages/livechat/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
"devDependencies": {
"@babel/preset-env": "^7.18.2",
"@rocket.chat/eslint-config": "^0.4.0",
"@rocket.chat/fuselage-tokens": "~0.31.14",
"@rocket.chat/logo": "~0.31.14",
"@rocket.chat/fuselage-tokens": "next",
"@rocket.chat/logo": "next",
"@storybook/addon-actions": "^6.5.9",
"@storybook/addon-backgrounds": "^6.5.9",
"@storybook/addon-essentials": "^6.5.9",
Expand Down Expand Up @@ -86,7 +86,7 @@
},
"dependencies": {
"@rocket.chat/sdk": "^1.0.0-alpha.42",
"@rocket.chat/ui-kit": "^0.14.1",
"@rocket.chat/ui-kit": "next",
"crypto-js": "^4.1.1",
"css-vars-ponyfill": "^2.4.7",
"date-fns": "^2.15.0",
Expand Down
4 changes: 2 additions & 2 deletions packages/rest-typings/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
"dependencies": {
"@rocket.chat/apps-engine": "^1.32.0",
"@rocket.chat/core-typings": "workspace:^",
"@rocket.chat/message-parser": "^0.32.0-dev.5",
"@rocket.chat/ui-kit": "^0.31.13",
"@rocket.chat/message-parser": "next",
"@rocket.chat/ui-kit": "next",
"ajv": "^8.11.0"
}
}
2 changes: 1 addition & 1 deletion packages/ui-client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"version": "0.0.1",
"private": true,
"devDependencies": {
"@rocket.chat/fuselage": "^0.31.13",
"@rocket.chat/fuselage": "next",
"@storybook/addon-actions": "^6.5.9",
"@storybook/addon-docs": "^6.5.9",
"@storybook/addon-essentials": "^6.5.9",
Expand Down
4 changes: 2 additions & 2 deletions packages/ui-contexts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
"private": true,
"devDependencies": {
"@rocket.chat/core-typings": "workspace:^",
"@rocket.chat/emitter": "^0.31.13",
"@rocket.chat/fuselage-hooks": "~0.31.13",
"@rocket.chat/emitter": "next",
"@rocket.chat/fuselage-hooks": "next",
"@rocket.chat/rest-typings": "workspace:^",
"@types/jest": "^27.4.1",
"@types/react": "^17.0.47",
Expand Down
8 changes: 4 additions & 4 deletions packages/ui-video-conf/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
"version": "0.0.1",
"private": true,
"devDependencies": {
"@rocket.chat/css-in-js": "~0.31.14",
"@rocket.chat/css-in-js": "next",
"@rocket.chat/eslint-config": "workspace:^",
"@rocket.chat/fuselage": "~0.31.14",
"@rocket.chat/fuselage-hooks": "~0.31.14",
"@rocket.chat/styled": "~0.31.14",
"@rocket.chat/fuselage": "next",
"@rocket.chat/fuselage-hooks": "next",
"@rocket.chat/styled": "next",
"@types/jest": "^27.4.1",
"eslint": "^8.12.0",
"eslint-plugin-react": "^7.30.1",
Expand Down
1 change: 0 additions & 1 deletion packages/ui-video-conf/src/VideoConfController.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ const VideoConfController = ({ icon, active, secondary, disabled, small = true,
info={active}
disabled={disabled}
secondary={secondary || active || disabled}
square
{...props}
/>
);
Expand Down
Loading

0 comments on commit 22ed6e9

Please sign in to comment.