Skip to content
Snippets Groups Projects
Unverified Commit 75a49237 authored by eduardofcabrera's avatar eduardofcabrera Committed by GitHub
Browse files

Chore: Convert to typescript some functions from app/lib/server/functions (#24519)

parent e0eb54fe
No related branches found
No related tags found
No related merge requests found
......@@ -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 },
......
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 = {
......
......@@ -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;
......
......@@ -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<unknown> {
export const setRoomAvatar = async function (rid: string, dataURI: string, user: IUser): Promise<void> {
const fileStore = FileUpload.getStore('Avatars');
const current = await Avatars.findOneByRoomId(rid);
......
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);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment