Skip to content

Commit

Permalink
Merge branch 'develop' into fix/thread_preview
Browse files Browse the repository at this point in the history
  • Loading branch information
kodiakhq[bot] authored Mar 22, 2023
2 parents a355c64 + 2d4c2ef commit 2a0f1f1
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 22 deletions.
16 changes: 8 additions & 8 deletions apps/meteor/app/importer/server/classes/ImportDataConverter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ export class ImportDataConverter {
return ImportData.getAllUsers().toArray();
}

findExistingUser(data: IImportUser): IUser | undefined {
async findExistingUser(data: IImportUser): Promise<IUser | undefined> {
if (data.emails.length) {
const emailUser = Users.findOneByEmailAddress(data.emails[0], {});

Expand All @@ -321,7 +321,7 @@ export class ImportDataConverter {
const users = (await this.getUsersToImport()) as IImportUserRecord[];
for await (const { data, _id } of users) {
try {
if (beforeImportFn && !beforeImportFn(data, 'user')) {
if (beforeImportFn && !(await beforeImportFn(data, 'user'))) {
await this.skipRecord(_id);
continue;
}
Expand All @@ -333,7 +333,7 @@ export class ImportDataConverter {
throw new Error('importer-user-missing-email-and-username');
}

let existingUser = this.findExistingUser(data);
let existingUser = await this.findExistingUser(data);
if (existingUser && this._options.skipExistingUsers) {
await this.skipRecord(_id);
continue;
Expand Down Expand Up @@ -367,7 +367,7 @@ export class ImportDataConverter {
}

if (afterImportFn) {
afterImportFn(data, 'user', isNewUser);
await afterImportFn(data, 'user', isNewUser);
}
} catch (e) {
this._logger.error(e);
Expand Down Expand Up @@ -555,7 +555,7 @@ export class ImportDataConverter {

for await (const { data, _id } of messages) {
try {
if (beforeImportFn && !beforeImportFn(data, 'message')) {
if (beforeImportFn && !(await beforeImportFn(data, 'message'))) {
await this.skipRecord(_id);
continue;
}
Expand Down Expand Up @@ -624,7 +624,7 @@ export class ImportDataConverter {
}

if (afterImportFn) {
afterImportFn(data, 'message', true);
await afterImportFn(data, 'message', true);
}
} catch (e) {
await this.saveError(_id, e instanceof Error ? e : new Error(String(e)));
Expand Down Expand Up @@ -905,7 +905,7 @@ export class ImportDataConverter {
const channels = await this.getChannelsToImport();
for await (const { data, _id } of channels) {
try {
if (beforeImportFn && !beforeImportFn(data, 'channel')) {
if (beforeImportFn && !(await beforeImportFn(data, 'channel'))) {
await this.skipRecord(_id);
continue;
}
Expand Down Expand Up @@ -934,7 +934,7 @@ export class ImportDataConverter {
}

if (afterImportFn) {
afterImportFn(data, 'channel', !existingRoom);
await afterImportFn(data, 'channel', !existingRoom);
}
} catch (e) {
await this.saveError(_id, e instanceof Error ? e : new Error(String(e)));
Expand Down
6 changes: 3 additions & 3 deletions apps/meteor/app/importer/server/classes/ImporterBase.js
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ export class Base {
const started = Date.now();
const startedByUserId = Meteor.userId();

const beforeImportFn = (data, type) => {
const beforeImportFn = async (data, type) => {
switch (type) {
case 'channel': {
const id = data.t === 'd' ? '__directMessages__' : data.importIds[0];
Expand All @@ -195,8 +195,8 @@ export class Base {
return true;
};

const afterImportFn = () => {
Promise.await(this.addCountCompleted(1));
const afterImportFn = async () => {
return this.addCountCompleted(1);
};

process.nextTick(async () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import type { IImportUser, IImportMessage, IImportChannel } from '@rocket.chat/core-typings';

type ImporterBeforeImportCallback = {
(data: IImportUser | IImportChannel | IImportMessage, type: string): boolean;
(data: IImportUser | IImportChannel | IImportMessage, type: string): Promise<boolean>;
};

export type ImporterAfterImportCallback = {
(data: IImportUser | IImportChannel | IImportMessage, type: string, isNewRecord: boolean): void;
(data: IImportUser | IImportChannel | IImportMessage, type: string, isNewRecord: boolean): Promise<void>;
};

export interface IConversionCallbacks {
Expand Down
4 changes: 2 additions & 2 deletions apps/meteor/ee/server/configuration/ldap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,12 +88,12 @@ Meteor.startup(() =>

callbacks.add(
'onLDAPLogin',
({ user, ldapUser, isNewUser }: { user: IUser; ldapUser: ILDAPEntry; isNewUser: boolean }, ldap?: LDAPConnection) => {
async ({ user, ldapUser, isNewUser }: { user: IUser; ldapUser: ILDAPEntry; isNewUser: boolean }, ldap?: LDAPConnection) => {
if (!ldap) {
return;
}

Promise.await(LDAPEEManager.advancedSyncForUser(ldap, user, isNewUser, ldapUser.dn));
await LDAPEEManager.advancedSyncForUser(ldap, user, isNewUser, ldapUser.dn);
},
callbacks.priority.MEDIUM,
'advancedLDAPSync',
Expand Down
6 changes: 3 additions & 3 deletions apps/meteor/ee/server/lib/ldap/Manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ export class LDAPEEManager extends LDAPManager {
}

await converter.convertUsers({
afterImportFn: ((data: IImportUser, _type: string, isNewRecord: boolean): void =>
Promise.await(this.advancedSync(ldap, data, converter, isNewRecord))) as ImporterAfterImportCallback,
afterImportFn: (async (data: IImportUser, _type: string, isNewRecord: boolean): Promise<void> =>
this.advancedSync(ldap, data, converter, isNewRecord)) as ImporterAfterImportCallback,
});
} catch (error) {
logger.error(error);
Expand Down Expand Up @@ -126,7 +126,7 @@ export class LDAPEEManager extends LDAPManager {
converter: LDAPDataConverter,
isNewRecord: boolean,
): Promise<void> {
const user = converter.findExistingUser(importUser);
const user = await converter.findExistingUser(importUser);
if (!user?.username) {
return;
}
Expand Down
4 changes: 2 additions & 2 deletions apps/meteor/server/configuration/ldap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ import { callbacks } from '../../lib/callbacks';
import { settings } from '../../app/settings/server';

// Register ldap login handler
Accounts.registerLoginHandler('ldap', function (loginRequest: Record<string, any>) {
Accounts.registerLoginHandler('ldap', async function (loginRequest: Record<string, any>) {
if (!loginRequest.ldap || !loginRequest.ldapOptions) {
return undefined;
}

return Promise.await(LDAP.loginRequest(loginRequest.username, loginRequest.ldapPass));
return LDAP.loginRequest(loginRequest.username, loginRequest.ldapPass);
});

// Prevent password logins by LDAP users when LDAP is enabled
Expand Down
4 changes: 2 additions & 2 deletions apps/meteor/server/lib/ldap/DataConverter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ export class LDAPDataConverter extends VirtualDataConverter {
this.mergeExistingUsers = settings.get<boolean>('LDAP_Merge_Existing_Users') ?? true;
}

findExistingUser(data: IImportUser): IUser | undefined {
async findExistingUser(data: IImportUser): Promise<IUser | undefined> {
if (data.services?.ldap?.id) {
const importedUser = Promise.await(Users.findOneByLDAPId(data.services.ldap.id, data.services.ldap.idAttribute));
const importedUser = await Users.findOneByLDAPId(data.services.ldap.id, data.services.ldap.idAttribute);
if (importedUser) {
return importedUser;
}
Expand Down

0 comments on commit 2a0f1f1

Please sign in to comment.