diff --git a/apps/meteor/app/lib/server/functions/addUserToDefaultChannels.ts b/apps/meteor/app/lib/server/functions/addUserToDefaultChannels.ts index c7a47067ce62..62906fa893c1 100644 --- a/apps/meteor/app/lib/server/functions/addUserToDefaultChannels.ts +++ b/apps/meteor/app/lib/server/functions/addUserToDefaultChannels.ts @@ -3,7 +3,7 @@ import type { IRoom, IUser } from '@rocket.chat/core-typings'; import { Rooms, Subscriptions, Messages } from '../../../models/server'; import { callbacks } from '../../../../lib/callbacks'; -export const addUserToDefaultChannels = function (user: IUser, silenced: boolean): void { +export const addUserToDefaultChannels = function (user: IUser, silenced?: boolean): void { callbacks.run('beforeJoinDefaultChannels', user); const defaultRooms = Rooms.findByDefaultAndTypes(true, ['c', 'p'], { fields: { usernames: 0 }, diff --git a/apps/meteor/app/lib/server/functions/getStatusText.ts b/apps/meteor/app/lib/server/functions/getStatusText.ts index af154b24d3fe..ad5ffcd84b4f 100644 --- a/apps/meteor/app/lib/server/functions/getStatusText.ts +++ b/apps/meteor/app/lib/server/functions/getStatusText.ts @@ -1,8 +1,8 @@ import { Users } from '../../../models/server'; -export const getStatusText = function (userId: string): unknown { +export const getStatusText = function (userId: string): string | undefined { if (!userId) { - return undefined; + return; } const fields = { diff --git a/apps/meteor/app/lib/server/functions/setRealName.ts b/apps/meteor/app/lib/server/functions/setRealName.ts index 21c1c9b7362e..493b211aab02 100644 --- a/apps/meteor/app/lib/server/functions/setRealName.ts +++ b/apps/meteor/app/lib/server/functions/setRealName.ts @@ -8,15 +8,19 @@ import { hasPermission } from '../../../authorization/server'; import { RateLimiter } from '../lib'; import { api } from '../../../../server/sdk/api'; -export const _setRealName = function (userId: string, name: string, fullUser: IUser): unknown { +export const _setRealName = function (userId: string, name: string, fullUser: IUser): IUser | undefined { name = s.trim(name); if (!userId || (settings.get('Accounts_RequireNameForSignUp') && !name)) { - return false; + return; } const user = fullUser || Users.findOneById(userId); + if (!user) { + return; + } + // User already has desired name, return if (user.name && s.trim(user.name) === name) { return user; diff --git a/apps/meteor/app/lib/server/functions/setRoomAvatar.ts b/apps/meteor/app/lib/server/functions/setRoomAvatar.ts index 2873443e1fd3..1cd2a2442b75 100644 --- a/apps/meteor/app/lib/server/functions/setRoomAvatar.ts +++ b/apps/meteor/app/lib/server/functions/setRoomAvatar.ts @@ -7,7 +7,7 @@ import { Rooms, Messages } from '../../../models/server'; import { Avatars } from '../../../models/server/raw'; import { api } from '../../../../server/sdk/api'; -export const setRoomAvatar = async function (rid: string, dataURI: string, user: IUser): Promise { +export const setRoomAvatar = async function (rid: string, dataURI: string, user: IUser): Promise { const fileStore = FileUpload.getStore('Avatars'); const current = await Avatars.findOneByRoomId(rid); diff --git a/apps/meteor/app/lib/server/functions/setStatusText.ts b/apps/meteor/app/lib/server/functions/setStatusText.ts index ee8e533a81a4..23bda1463602 100644 --- a/apps/meteor/app/lib/server/functions/setStatusText.ts +++ b/apps/meteor/app/lib/server/functions/setStatusText.ts @@ -1,5 +1,6 @@ import { Meteor } from 'meteor/meteor'; import s from 'underscore.string'; +import type { IUser } from '@rocket.chat/core-typings'; import { Users } from '../../../models/server'; import { Users as UsersRaw } from '../../../models/server/raw'; @@ -34,7 +35,7 @@ export const _setStatusTextPromise = async function (userId: string, statusText: return true; }; -export const _setStatusText = function (userId: any, statusText: string): unknown { +export const _setStatusText = function (userId: any, statusText: string): IUser | boolean { statusText = s.trim(statusText); if (statusText.length > 120) { statusText = statusText.substr(0, 120);