Skip to content

Commit

Permalink
Merge branch 'develop' into break/remove-endpoints
Browse files Browse the repository at this point in the history
  • Loading branch information
KevLehman committed Jun 27, 2022
2 parents a996183 + ace6f5b commit 7208523
Show file tree
Hide file tree
Showing 963 changed files with 8,526 additions and 4,605 deletions.
10 changes: 9 additions & 1 deletion .github/no-js-action-config.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
{
"added": {
"ignore": ["packages/accounts-linkedin/**/*", "packages/linkedin-oauth/**/*", "tests/cypress/integration/08-resolutions.spec.js", "**/.eslintrc.js", "packages/eslint-config/**", "**/babel.config.js"]
"ignore": [
"packages/node-poplib/**/*",
"packages/accounts-linkedin/**/*",
"packages/linkedin-oauth/**/*",
"tests/cypress/integration/08-resolutions.spec.js",
"**/.eslintrc.js",
"packages/eslint-config/**",
"**/babel.config.js"
]
}
}
2 changes: 1 addition & 1 deletion .github/workflows/build_and_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -681,7 +681,7 @@ jobs:
docker logs presence --tail=50
cd ./apps/meteor
npm run test:playwright
IS_EE=true npm run test:playwright
- name: Store playwright test trace
uses: actions/upload-artifact@v2
Expand Down
8 changes: 8 additions & 0 deletions _templates/package/new/package.json.ejs.t
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,13 @@ to: packages/<%= name %>/package.json
"/dist"
],
"dependencies": {
},
"eslintConfig": {
"extends": [
"@rocket.chat/eslint-config"
],
"ignorePatterns": [
"**/dist"
]
}
}
2 changes: 1 addition & 1 deletion apps/meteor/app/2fa/server/functions/resetTOTP.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { Meteor } from 'meteor/meteor';
import { TAPi18n } from 'meteor/rocketchat:tap-i18n';
import type { IUser } from '@rocket.chat/core-typings';
import { Users } from '@rocket.chat/models';

import { settings } from '../../../settings/server';
import * as Mailer from '../../../mailer';
import { Users } from '../../../models/server/raw/index';

const sendResetNotification = async function (uid: string): Promise<void> {
const user = await Users.findOneById<Pick<IUser, 'language' | 'emails'>>(uid, {
Expand Down
3 changes: 1 addition & 2 deletions apps/meteor/app/2fa/server/lib/totp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ import { SHA256 } from 'meteor/sha';
import { Random } from 'meteor/random';
import speakeasy from 'speakeasy';

// @ts-expect-error
import { Users } from '../../../models';
import { Users } from '../../../models/server';
import { settings } from '../../../settings/server';

export const TOTP = {
Expand Down
2 changes: 1 addition & 1 deletion apps/meteor/app/analytics/client/trackEvents.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { Tracker } from 'meteor/tracker';

import { settings } from '../../settings';
import { callbacks } from '../../../lib/callbacks';
import { ChatRoom } from '../../models';
import { ChatRoom } from '../../models/client';

function trackEvent(category, action, label) {
if (window._paq) {
Expand Down
2 changes: 1 addition & 1 deletion apps/meteor/app/api/server/lib/emailInbox.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { IEmailInbox } from '@rocket.chat/core-typings';
import { InsertOneWriteOpResult, UpdateWriteOpResult, WithId } from 'mongodb';
import { EmailInbox } from '@rocket.chat/models';

import { EmailInbox } from '../../../models/server/raw';
import { hasPermissionAsync } from '../../../authorization/server/functions/hasPermission';
import { Users } from '../../../models/server';

Expand Down
3 changes: 1 addition & 2 deletions apps/meteor/app/api/server/lib/emoji-custom.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { IEmojiCustom, ILivechatDepartmentRecord } from '@rocket.chat/core-typings';
import { FilterQuery, SortOptionObject } from 'mongodb';

import { EmojiCustom } from '../../../models/server/raw';
import { EmojiCustom } from '@rocket.chat/models';

export async function findEmojisCustom({
query = {},
Expand Down
2 changes: 1 addition & 1 deletion apps/meteor/app/api/server/lib/integrations.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { IIntegration, IUser } from '@rocket.chat/core-typings';
import { Integrations } from '@rocket.chat/models';

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

const hasIntegrationsPermission = async (userId: string, integration: IIntegration): Promise<boolean> => {
Expand Down
10 changes: 5 additions & 5 deletions apps/meteor/app/api/server/lib/messages.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { IMessage, IUser } from '@rocket.chat/core-typings';
import { Rooms, Messages, Users } from '@rocket.chat/models';

import { canAccessRoomAsync } from '../../../authorization/server/functions/canAccessRoom';
import { Rooms, Messages, Users } from '../../../models/server/raw';
import { getValue } from '../../../settings/server/raw';

export async function findMentionedMessages({
Expand All @@ -19,7 +19,7 @@ export async function findMentionedMessages({
total: number;
}> {
const room = await Rooms.findOneById(roomId);
if (!(await canAccessRoomAsync(room, { _id: uid }))) {
if (!room || !(await canAccessRoomAsync(room, { _id: uid }))) {
throw new Error('error-not-allowed');
}
const user: IUser | null = await Users.findOneById(uid, { fields: { username: 1 } });
Expand Down Expand Up @@ -60,7 +60,7 @@ export async function findStarredMessages({
total: number;
}> {
const room = await Rooms.findOneById(roomId);
if (!(await canAccessRoomAsync(room, { _id: uid }))) {
if (!room || !(await canAccessRoomAsync(room, { _id: uid }))) {
throw new Error('error-not-allowed');
}
const user = await Users.findOneById(uid, { fields: { username: 1 } });
Expand Down Expand Up @@ -133,7 +133,7 @@ export async function findSnippetedMessages({
}
const room = await Rooms.findOneById(roomId);

if (!(await canAccessRoomAsync(room, { _id: uid }))) {
if (!room || !(await canAccessRoomAsync(room, { _id: uid }))) {
throw new Error('error-not-allowed');
}

Expand Down Expand Up @@ -173,7 +173,7 @@ export async function findDiscussionsFromRoom({
}> {
const room = await Rooms.findOneById(roomId);

if (!(await canAccessRoomAsync(room, { _id: uid }))) {
if (!room || !(await canAccessRoomAsync(room, { _id: uid }))) {
throw new Error('error-not-allowed');
}

Expand Down
2 changes: 1 addition & 1 deletion apps/meteor/app/api/server/lib/rooms.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { IRoom, ISubscription } from '@rocket.chat/core-typings';
import { Rooms } from '@rocket.chat/models';

import { hasPermissionAsync, hasAtLeastOnePermissionAsync } from '../../../authorization/server/functions/hasPermission';
import { Rooms } from '../../../models/server/raw';
import { Subscriptions } from '../../../models/server';
import { adminFields } from '../../../../lib/rooms/adminFields';

Expand Down
2 changes: 1 addition & 1 deletion apps/meteor/app/api/server/lib/users.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { escapeRegExp } from '@rocket.chat/string-helpers';
import { ILivechatDepartmentRecord, IUser } from '@rocket.chat/core-typings';
import { FilterQuery } from 'mongodb';
import { Users } from '@rocket.chat/models';

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

export async function findUsersToAutocomplete({
Expand Down
3 changes: 1 addition & 2 deletions apps/meteor/app/api/server/lib/webdav.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import type { IWebdavAccount } from '@rocket.chat/core-typings';

import { WebdavAccounts } from '../../../models/server/raw';
import { WebdavAccounts } from '@rocket.chat/models';

export async function findWebdavAccountsByUserId({ uid }: { uid: string }): Promise<IWebdavAccount[]> {
return WebdavAccounts.findWithUserId(uid, {
Expand Down
2 changes: 1 addition & 1 deletion apps/meteor/app/api/server/v1/channels.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { Meteor } from 'meteor/meteor';
import { Match, check } from 'meteor/check';
import _ from 'underscore';
import { Integrations, Uploads } from '@rocket.chat/models';

import { Rooms, Subscriptions, Messages, Users } from '../../../models/server';
import { Integrations, Uploads } from '../../../models/server/raw';
import { canAccessRoom, hasPermission, hasAtLeastOnePermission } from '../../../authorization/server';
import { mountIntegrationQueryBasedOnPermissions } from '../../../integrations/server/lib/mountQueriesBasedOnPermission';
import { normalizeMessagesForUser } from '../../../utils/server/lib/normalizeMessagesForUser';
Expand Down
8 changes: 6 additions & 2 deletions apps/meteor/app/api/server/v1/channels.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import {
} from '@rocket.chat/rest-typings';

import { Rooms, Subscriptions, Messages } from '../../../models/server';
import { hasPermission, hasAllPermission } from '../../../authorization/server';
import { hasPermission } from '../../../authorization/server';
import { normalizeMessagesForUser } from '../../../utils/server/lib/normalizeMessagesForUser';
import { API } from '../api';
import { Team } from '../../../../server/sdk';
Expand Down Expand Up @@ -454,7 +454,7 @@ API.v1.addRoute(
},
{
async post() {
if (!hasAllPermission(this.userId, ['create-team', 'edit-room'])) {
if (!hasPermission(this.userId, 'create-team')) {
return API.v1.unauthorized();
}

Expand All @@ -464,6 +464,10 @@ API.v1.addRoute(
return API.v1.failure('The parameter "channelId" or "channelName" is required');
}

if (!hasPermission(this.userId, 'edit-room', channelId)) {
return API.v1.unauthorized();
}

const room = findChannelByIdOrName({
params: {
roomId: channelId,
Expand Down
2 changes: 1 addition & 1 deletion apps/meteor/app/api/server/v1/chat.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { escapeRegExp } from '@rocket.chat/string-helpers';
import { Meteor } from 'meteor/meteor';
import { Match, check } from 'meteor/check';

import { Messages } from '../../../models';
import { Messages } from '../../../models/server';
import { canAccessRoom, canAccessRoomId, roomAccessAttributes, hasPermission } from '../../../authorization/server';
import { normalizeMessagesForUser } from '../../../utils/server/lib/normalizeMessagesForUser';
import { processWebhookMessage } from '../../../lib/server';
Expand Down
3 changes: 2 additions & 1 deletion apps/meteor/app/api/server/v1/custom-sounds.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { CustomSounds } from '../../../models/server/raw';
import { CustomSounds } from '@rocket.chat/models';

import { API } from '../api';

API.v1.addRoute(
Expand Down
2 changes: 1 addition & 1 deletion apps/meteor/app/api/server/v1/custom-user-status.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Meteor } from 'meteor/meteor';
import { Match, check } from 'meteor/check';
import { CustomUserStatus } from '@rocket.chat/models';

import { CustomUserStatus } from '../../../models/server/raw';
import { API } from '../api';

API.v1.addRoute(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,26 @@
/* eslint-disable @typescript-eslint/camelcase */
import { Meteor } from 'meteor/meteor';
import {
ise2eGetUsersOfRoomWithoutKeyParamsGET,
ise2eSetRoomKeyIDParamsPOST,
ise2eSetUserPublicAndPrivateKeysParamsPOST,
ise2eUpdateGroupKeyParamsPOST,
} from '@rocket.chat/rest-typings';
import { IUser } from '@rocket.chat/core-typings';

import { API } from '../api';

API.v1.addRoute(
'e2e.fetchMyKeys',
{ authRequired: true },
{
authRequired: true,
},
{
get() {
let result;
Meteor.runAsUser(this.userId, () => {
result = Meteor.call('e2e.fetchMyKeys');
});
const result: {
public_key: string;
private_key: string;
} = Meteor.call('e2e.fetchMyKeys');

return API.v1.success(result);
},
Expand All @@ -19,15 +29,17 @@ API.v1.addRoute(

API.v1.addRoute(
'e2e.getUsersOfRoomWithoutKey',
{ authRequired: true },
{
authRequired: true,
validateParams: ise2eGetUsersOfRoomWithoutKeyParamsGET,
},
{
get() {
const { rid } = this.queryParams;

let result;
Meteor.runAsUser(this.userId, () => {
result = Meteor.call('e2e.getUsersOfRoomWithoutKey', rid);
});
const result: {
users: IUser[];
} = Meteor.call('e2e.getUsersOfRoomWithoutKey', rid);

return API.v1.success(result);
},
Expand Down Expand Up @@ -65,16 +77,18 @@ API.v1.addRoute(
* schema:
* $ref: '#/components/schemas/ApiFailureV1'
*/

API.v1.addRoute(
'e2e.setRoomKeyID',
{ authRequired: true },
{
authRequired: true,
validateParams: ise2eSetRoomKeyIDParamsPOST,
},
{
post() {
const { rid, keyID } = this.bodyParams;

Meteor.runAsUser(this.userId, () => {
API.v1.success(Meteor.call('e2e.setRoomKeyID', rid, keyID));
});
Meteor.call('e2e.setRoomKeyID', rid, keyID);

return API.v1.success();
},
Expand Down Expand Up @@ -114,18 +128,17 @@ API.v1.addRoute(
*/
API.v1.addRoute(
'e2e.setUserPublicAndPrivateKeys',
{ authRequired: true },
{
authRequired: true,
validateParams: ise2eSetUserPublicAndPrivateKeysParamsPOST,
},
{
post() {
const { public_key, private_key } = this.bodyParams;

Meteor.runAsUser(this.userId, () => {
API.v1.success(
Meteor.call('e2e.setUserPublicAndPrivateKeys', {
public_key,
private_key,
}),
);
const { public_key, private_key } = Meteor.call('e2e.fetchMyKeys');

Meteor.call('e2e.setUserPublicAndPrivateKeys', {
public_key,
private_key,
});

return API.v1.success();
Expand Down Expand Up @@ -168,14 +181,15 @@ API.v1.addRoute(
*/
API.v1.addRoute(
'e2e.updateGroupKey',
{ authRequired: true },
{
authRequired: true,
validateParams: ise2eUpdateGroupKeyParamsPOST,
},
{
post() {
const { uid, rid, key } = this.bodyParams;

Meteor.runAsUser(this.userId, () => {
API.v1.success(Meteor.call('e2e.updateGroupKey', rid, uid, key));
});
Meteor.call('e2e.updateGroupKey', rid, uid, key);

return API.v1.success();
},
Expand Down
2 changes: 1 addition & 1 deletion apps/meteor/app/api/server/v1/email-inbox.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { check, Match } from 'meteor/check';
import { EmailInbox } from '@rocket.chat/models';

import { API } from '../api';
import { insertOneEmailInbox, findEmailInboxes, findOneEmailInbox, updateEmailInbox } from '../lib/emailInbox';
import { hasPermission } from '../../../authorization/server/functions/hasPermission';
import { EmailInbox } from '../../../models/server/raw';
import Users from '../../../models/server/models/Users';
import { sendTestEmailToInbox } from '../../../../server/features/EmailInbox/EmailInbox_Outgoing';

Expand Down
2 changes: 1 addition & 1 deletion apps/meteor/app/api/server/v1/emoji-custom.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Meteor } from 'meteor/meteor';
import { EmojiCustom } from '@rocket.chat/models';

import { EmojiCustom } from '../../../models/server/raw';
import { API } from '../api';
import { getUploadFormData } from '../lib/getUploadFormData';
import { findEmojisCustom } from '../lib/emoji-custom';
Expand Down
2 changes: 1 addition & 1 deletion apps/meteor/app/api/server/v1/groups.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import _ from 'underscore';
import { Meteor } from 'meteor/meteor';
import { Match, check } from 'meteor/check';
import { Integrations, Uploads } from '@rocket.chat/models';

import { mountIntegrationQueryBasedOnPermissions } from '../../../integrations/server/lib/mountQueriesBasedOnPermission';
import { Subscriptions, Rooms, Messages, Users } from '../../../models/server';
import { Integrations, Uploads } from '../../../models/server/raw';
import {
hasPermission,
hasAtLeastOnePermission,
Expand Down
Loading

0 comments on commit 7208523

Please sign in to comment.