Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions apps/meteor/app/api/server/v1/channels.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Team, Room } from '@rocket.chat/core-services';
import { TEAM_TYPE, type IRoom, type ISubscription, type IUser, type RoomType, type UserStatus } from '@rocket.chat/core-typings';
import { TeamType, type IRoom, type ISubscription, type IUser, type RoomType, type UserStatus } from '@rocket.chat/core-typings';
import { Integrations, Messages, Rooms, Subscriptions, Uploads, Users } from '@rocket.chat/models';
import {
isChannelsAddAllProps,
Expand Down Expand Up @@ -1466,7 +1466,7 @@ API.v1.addRoute(
// Public rooms of private teams should be accessible only by team members
if (findResult.teamId) {
const team = await Team.getOneById(findResult.teamId);
if (team?.type === TEAM_TYPE.PRIVATE) {
if (team?.type === TeamType.PRIVATE) {
if (!this.userId || !(await canAccessRoomAsync(findResult, { _id: this.userId }))) {
return API.v1.notFound('Room not found');
}
Expand Down
4 changes: 2 additions & 2 deletions apps/meteor/app/api/server/v1/teams.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Team } from '@rocket.chat/core-services';
import type { ITeam, UserStatus } from '@rocket.chat/core-typings';
import { TEAM_TYPE } from '@rocket.chat/core-typings';
import { TeamType } from '@rocket.chat/core-typings';
import { Users, Rooms } from '@rocket.chat/models';
import {
isTeamsConvertToChannelProps,
Expand Down Expand Up @@ -73,7 +73,7 @@ API.v1.addRoute(
this.bodyParams,
Match.ObjectIncluding({
name: String,
type: Match.OneOf(TEAM_TYPE.PRIVATE, TEAM_TYPE.PUBLIC),
type: Match.OneOf(TeamType.PRIVATE, TeamType.PUBLIC),
members: Match.Maybe([String]),
room: Match.Maybe(Match.Any),
owner: Match.Maybe(String),
Expand Down
2 changes: 1 addition & 1 deletion apps/meteor/app/api/server/v1/users.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { MeteorError, Team, api, Calendar } from '@rocket.chat/core-services';
import { type IExportOperation, type ILoginToken, type IPersonalAccessToken, type IUser, type UserStatus } from '@rocket.chat/core-typings';
import type { IExportOperation, ILoginToken, IPersonalAccessToken, IUser, UserStatus } from '@rocket.chat/core-typings';
import { Users, Subscriptions, Sessions } from '@rocket.chat/models';
import {
isUserCreateParamsPOST,
Expand Down
5 changes: 3 additions & 2 deletions apps/meteor/app/autotranslate/server/autotranslate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import type {
IMessage,
IRoom,
MessageAttachment,
ISupportedLanguages,
IProviderMetadata,
ISupportedLanguage,
ITranslationResult,
Expand Down Expand Up @@ -134,7 +133,9 @@ export abstract class AutoTranslate {

languages: string[];

supportedLanguages: ISupportedLanguages;
supportedLanguages: {
[language: string]: ISupportedLanguage[];
};

/**
* Encapsulate the api key and provider settings.
Expand Down
14 changes: 6 additions & 8 deletions apps/meteor/app/autotranslate/server/deeplTranslate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,7 @@
* @author Vigneshwaran Odayappan <[email protected]>
*/

import type {
IMessage,
IDeepLTranslation,
MessageAttachment,
IProviderMetadata,
ITranslationResult,
ISupportedLanguage,
} from '@rocket.chat/core-typings';
import type { IMessage, MessageAttachment, IProviderMetadata, ITranslationResult, ISupportedLanguage } from '@rocket.chat/core-typings';
import { serverFetch as fetch } from '@rocket.chat/server-fetch';
import _ from 'underscore';

Expand All @@ -21,6 +14,11 @@ import { settings } from '../../settings/server';
const proApiEndpoint = 'https://api.deepl.com/v2/translate';
const freeApiEndpoint = 'https://api-free.deepl.com/v2/translate';

interface IDeepLTranslation {
detected_source_language: string;
text: string;
}

/**
* DeepL translation service provider class representation.
* Encapsulates the service provider settings and information.
Expand Down
13 changes: 5 additions & 8 deletions apps/meteor/app/autotranslate/server/googleTranslate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,7 @@
* @author Vigneshwaran Odayappan <[email protected]>
*/

import type {
IMessage,
IProviderMetadata,
ISupportedLanguage,
ITranslationResult,
IGoogleTranslation,
MessageAttachment,
} from '@rocket.chat/core-typings';
import type { IMessage, IProviderMetadata, ISupportedLanguage, ITranslationResult, MessageAttachment } from '@rocket.chat/core-typings';
import { serverFetch as fetch } from '@rocket.chat/server-fetch';
import _ from 'underscore';

Expand All @@ -18,6 +11,10 @@ import { i18n } from '../../../server/lib/i18n';
import { SystemLogger } from '../../../server/lib/logger/system';
import { settings } from '../../settings/server';

interface IGoogleTranslation {
translatedText: string;
}

/**
* Represents google translate class
* @class
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Team } from '@rocket.chat/core-services';
import type { IRoom, IRoomWithRetentionPolicy, IUser, MessageTypesValues, ITeam } from '@rocket.chat/core-typings';
import { TEAM_TYPE } from '@rocket.chat/core-typings';
import type { IRoom, IRoomWithRetentionPolicy, IUser, MessageTypesValues, ITeam, RequiredField } from '@rocket.chat/core-typings';
import { TeamType } from '@rocket.chat/core-typings';
import type { ServerMethods } from '@rocket.chat/ddp-client';
import { Rooms, Users } from '@rocket.chat/models';
import { Match } from 'meteor/check';
Expand Down Expand Up @@ -68,7 +68,7 @@ const isAbacManagedRoom = (room: IRoom): boolean => {

const isAbacManagedTeam = (team: Partial<ITeam> | null, teamRoom: IRoom): boolean => {
return (
team?.type === TEAM_TYPE.PRIVATE &&
team?.type === TeamType.PRIVATE &&
settings.get<boolean>('ABAC_Enabled') &&
Array.isArray(teamRoom?.abacAttributes) &&
teamRoom.abacAttributes.length > 0
Expand Down Expand Up @@ -236,7 +236,7 @@ const validators: RoomSettingsValidators = {
type RoomSettingsSavers = {
[TRoomSetting in keyof RoomSettings]?: (params: {
userId: IUser['_id'];
user: IUser & Required<Pick<IUser, 'username' | 'name'>>;
user: RequiredField<IUser, 'username' | 'name'>;
value: RoomSettings[TRoomSetting];
room: IRoom;
rid: IRoom['_id'];
Expand All @@ -251,7 +251,7 @@ const settingSavers: RoomSettingsSavers = {

if (room.teamId && room.teamMain) {
void Team.update(user._id, room.teamId, {
type: room.t === 'c' ? TEAM_TYPE.PUBLIC : TEAM_TYPE.PRIVATE,
type: room.t === 'c' ? TeamType.PUBLIC : TeamType.PRIVATE,
name: value,
updateRoom: false,
});
Expand Down Expand Up @@ -296,7 +296,7 @@ const settingSavers: RoomSettingsSavers = {
}

if (room.teamId && room.teamMain) {
const type = value === 'c' ? TEAM_TYPE.PUBLIC : TEAM_TYPE.PRIVATE;
const type = value === 'c' ? TeamType.PUBLIC : TeamType.PRIVATE;
void Team.update(user._id, room.teamId, { type, updateRoom: false });
}
},
Expand Down Expand Up @@ -406,7 +406,7 @@ async function save<TRoomSetting extends keyof RoomSettings>(
setting: TRoomSetting,
params: {
userId: IUser['_id'];
user: IUser & Required<Pick<IUser, 'username' | 'name'>>;
user: RequiredField<IUser, 'username' | 'name'>;
value: RoomSettings[TRoomSetting];
room: IRoom;
rid: IRoom['_id'];
Expand Down Expand Up @@ -509,7 +509,7 @@ export async function saveRoomSettings(
for await (const setting of Object.keys(settings) as (keyof RoomSettings)[]) {
await save(setting, {
userId,
user: user as IUser & Required<Pick<IUser, 'username' | 'name'>>,
user: user as RequiredField<IUser, 'username' | 'name'>,
value: settings[setting],
room,
rid,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export const handleBannerOnWorkspaceSync = async (banners: Exclude<Serialized<Cl
}
};

const deserializeAnnouncement = (announcement: Serialized<Cloud.Announcement>): Cloud.Announcement => {
const deserializeAnnouncement = (announcement: Serialized<Cloud.IAnnouncement>): Cloud.IAnnouncement => {
const { inactivedAt, _updatedAt, expireAt, startAt, createdAt } = announcement;

return {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import type { ImageAttachmentProps } from '@rocket.chat/core-typings';
import { useMediaUrl } from '@rocket.chat/ui-contexts';

import { useLoadImage } from './hooks/useLoadImage';
import MarkdownText from '../../../../MarkdownText';
import MessageCollapsible from '../../../MessageCollapsible';
import MessageContentBody from '../../../MessageContentBody';
import AttachmentImage from '../structure/AttachmentImage';
import { useLoadImage } from './hooks/useLoadImage';

const ImageAttachment = ({
id,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import type { Dimensions } from '@rocket.chat/core-typings';
import { Box } from '@rocket.chat/fuselage';
import { useAttachmentDimensions } from '@rocket.chat/ui-contexts';
import { memo, useState, useMemo } from 'react';
Expand All @@ -14,12 +13,13 @@ type AttachmentImageProps = {
loadImage?: boolean;
setLoadImage: () => void;
id: string | undefined;
} & Dimensions &
({ loadImage: true } | { loadImage: false; setLoadImage: () => void });
width: number;
height: number;
} & ({ loadImage: true } | { loadImage: false; setLoadImage: () => void });

const getDimensions = (
originalWidth: Dimensions['width'],
originalHeight: Dimensions['height'],
originalWidth: number,
originalHeight: number,
limits: { width: number; height: number },
): { width: number; height: number; ratio: number } => {
const widthRatio = originalWidth / limits.width;
Expand Down
7 changes: 6 additions & 1 deletion apps/meteor/client/lib/chats/ChatAPI.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
import type { IMessage, IRoom, ISubscription, IE2EEMessage, IUpload, Subscribable } from '@rocket.chat/core-typings';
import type { IMessage, IRoom, ISubscription, IE2EEMessage, IUpload } from '@rocket.chat/core-typings';
import type { IActionManager } from '@rocket.chat/ui-contexts';

import type { Upload } from './Upload';
import type { ReadStateManager } from './readStateManager';
import type { FormattingButton } from '../../../app/ui-message/client/messageBox/messageBoxFormatting';

type Subscribable<T> = {
get(): T;
subscribe(callback: () => void): () => void;
};

export type ComposerAPI = {
release(): void;
readonly text: string;
Expand Down
3 changes: 2 additions & 1 deletion apps/meteor/client/meteor/minimongo/Cursor.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import type { Optional } from '@rocket.chat/core-typings';
import { createComparatorFromSort, createPredicateFromFilter } from '@rocket.chat/mongo-adapter';
import { Tracker } from 'meteor/tracker';
import type { Filter, Sort } from 'mongodb';
Expand Down Expand Up @@ -573,7 +574,7 @@ export class Cursor<T extends { _id: string }, TOptions extends Options<T>> {

if (!options._suppress_initial && !this.collection.paused) {
const handler = (doc: T) => {
const fields: Omit<T, '_id'> & Partial<Pick<T, '_id'>> = clone(doc);
const fields: Optional<T, '_id'> = clone(doc);

delete fields._id;

Expand Down
5 changes: 3 additions & 2 deletions apps/meteor/client/meteor/minimongo/LocalCollection.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import type { Optional } from '@rocket.chat/core-typings';
import {
createDocumentMatcherFromFilter,
createPredicateFromFilter,
Expand Down Expand Up @@ -134,7 +135,7 @@ export class LocalCollection<T extends { _id: string }> {
}

private _insertInResults(query: Query<T>, doc: T) {
const fields: Omit<T, '_id'> & Partial<Pick<T, '_id'>> = clone(doc);
const fields: Optional<T, '_id'> = clone(doc);

delete fields._id;

Expand All @@ -158,7 +159,7 @@ export class LocalCollection<T extends { _id: string }> {
}

private async _insertInResultsAsync(query: Query<T>, doc: T) {
const fields: Omit<T, '_id'> & Partial<Pick<T, '_id'>> = clone(doc);
const fields: Optional<T, '_id'> = clone(doc);

delete fields._id;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { ITeam } from '@rocket.chat/core-typings';
import { TEAM_TYPE } from '@rocket.chat/core-typings';
import { TeamType } from '@rocket.chat/core-typings';
import { useUserId } from '@rocket.chat/ui-contexts';

import { useTeamInfoQuery } from '../../../../hooks/useTeamInfoQuery';
Expand Down Expand Up @@ -27,7 +27,7 @@ export const useParentTeamData = (teamId?: ITeam['_id']) => {
const { data: userTeams, isLoading: userTeamsLoading } = useUserTeamsQuery(userId);

const userBelongsToTeam = Boolean(userTeams?.find((team) => team._id === teamId)) || false;
const isTeamPublic = teamInfo?.type === TEAM_TYPE.PUBLIC;
const isTeamPublic = teamInfo?.type === TeamType.PUBLIC;
const shouldDisplayTeam = isTeamPublic || userBelongsToTeam;

return {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { IRoom } from '@rocket.chat/core-typings';
import { TEAM_TYPE } from '@rocket.chat/core-typings';
import { TeamType } from '@rocket.chat/core-typings';
import { useUserId } from '@rocket.chat/ui-contexts';
import { useTranslation } from 'react-i18next';

Expand Down Expand Up @@ -37,7 +37,7 @@ const ParentTeam = ({ room }: ParentTeamProps) => {
const { data: userTeams, isLoading: userTeamsLoading } = useUserTeamsQuery(userId);

const userBelongsToTeam = Boolean(userTeams?.find((team) => team._id === teamId)) || false;
const isPublicTeam = teamInfo?.type === TEAM_TYPE.PUBLIC;
const isPublicTeam = teamInfo?.type === TeamType.PUBLIC;
const shouldDisplayTeam = isPublicTeam || userBelongsToTeam;

const redirectToMainRoom = (): void => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import type { Optional } from '@rocket.chat/core-typings';
import type { ReactElement } from 'react';
import { useContext, createContext } from 'react';

Expand Down Expand Up @@ -29,7 +30,7 @@ export type ComposerPopupContextValue = ComposerPopupOption[];
export const ComposerPopupContext = createContext<ComposerPopupContextValue | undefined>(undefined);

export const createMessageBoxPopupConfig = <T extends { _id: string; sort?: number }>(
partial: Omit<ComposerPopupOption<T>, 'getValue'> & Partial<Pick<ComposerPopupOption<T>, 'getValue'>>,
partial: Optional<ComposerPopupOption<T>, 'getValue'>,
): ComposerPopupOption<T> => {
return {
blurOnSelectItem: true,
Expand Down
4 changes: 2 additions & 2 deletions apps/meteor/client/views/room/hooks/useE2EEResetRoomKey.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import type { RoomID } from '@rocket.chat/core-typings';
import type { IRoom } from '@rocket.chat/core-typings';
import { useEndpoint } from '@rocket.chat/ui-contexts';
import type { UseMutationOptions, UseMutationResult } from '@tanstack/react-query';
import { useMutation } from '@tanstack/react-query';

import { e2e } from '../../../lib/e2ee';

type UseE2EEResetRoomKeyVariables = {
roomId: RoomID;
roomId: IRoom['_id'];
};

export const useE2EEResetRoomKey = (
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { AppRequest, IUser, Pagination } from '@rocket.chat/core-typings';
import type { AppRequest, IUser } from '@rocket.chat/core-typings';
import { serverFetch as fetch } from '@rocket.chat/server-fetch';

import { getWorkspaceAccessToken } from '../../../../app/cloud/server';
Expand Down Expand Up @@ -49,7 +49,7 @@ export const appRequestNotififyForUsers = async (
};

// First request
const pagination: Pagination = { limit: DEFAULT_LIMIT, offset: 0 };
const pagination = { limit: DEFAULT_LIMIT, offset: 0 };

// First request to get the total and the first batch
const response = await fetch(`${marketplaceBaseUrl}/v1/app-request`, {
Expand Down
8 changes: 2 additions & 6 deletions apps/meteor/ee/server/lib/engagementDashboard/users.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,10 @@ export const fillFirstDaysOfUsersIfNeeded = async (date: Date): Promise<void> =>
}).toArray();
if (!usersFromAnalytics.length) {
const startOfPeriod = moment(date).subtract(90, 'days').toDate();
const users = (await Users.getTotalOfRegisteredUsersByDate({
const users = await Users.getTotalOfRegisteredUsersByDate({
start: startOfPeriod,
end: date,
})) as {
date: string;
users: number;
type: 'users';
}[];
});
users.forEach((user) =>
Analytics.insertOne({
...user,
Expand Down
5 changes: 0 additions & 5 deletions apps/meteor/lib/typedJSONParse.ts

This file was deleted.

1 change: 0 additions & 1 deletion apps/meteor/server/configuration/cas.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import type { Awaited } from '@rocket.chat/core-typings';
import debounce from 'lodash.debounce';
import { RoutePolicy } from 'meteor/routepolicy';
import { WebApp } from 'meteor/webapp';
Expand Down
4 changes: 2 additions & 2 deletions apps/meteor/server/lib/cas/middleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import type { IncomingMessage, ServerResponse } from 'http';
import url from 'url';

import { validate } from '@rocket.chat/cas-validate';
import type { ICredentialToken } from '@rocket.chat/core-typings';
import type { ICredentialToken, RequiredField } from '@rocket.chat/core-typings';
import { CredentialTokens } from '@rocket.chat/models';
import _ from 'underscore';

Expand All @@ -15,7 +15,7 @@ const closePopup = function (res: ServerResponse): void {
res.end(content, 'utf-8');
};

type IncomingMessageWithUrl = IncomingMessage & Required<Pick<IncomingMessage, 'url'>>;
type IncomingMessageWithUrl = RequiredField<IncomingMessage, 'url'>;

const casTicket = function (req: IncomingMessageWithUrl, token: string, callback: () => void): void {
// get configuration
Expand Down
Loading
Loading