/** * @module User */ import { Service } from "../../services"; import { ConnectedUser, RBEvent, User } from "../../models"; import { Subscription } from "rxjs"; import { UsersByEmailsResult } from "../../models/user.model"; /** @internal */ export declare const USER_SVC = "UserService"; /** * Users service events * Can listen to it via `UserService.subscribe()` API. * @eventProperty */ export declare enum UserServiceEvents { /** * @eventProperty */ ON_USER_CHANGED = "ON_USER_CHANGED" } /** * User Service interface */ export interface UserService { /** * The current connectedUser */ connectedUser?: ConnectedUser; /** * Subscribe to updates from the user service, all events are of RBEvent * @param callback - The callback function that will be called when events are received * @param eventNames - Array of event to listen * @returns Returns RxJS Subscription */ subscribe(callback: (event: RBEvent) => any, eventNames?: UserServiceEvents | UserServiceEvents[]): Subscription; /** * Get a user by one of its identifier * The user is first search in service cache then server side. * @param userRef - a user jid or user dbId or user jid tel */ getUserById(userRef: string): Promise; /** * Retrieves users matching the given e-mail addresses. * * Each e-mail is looked up against the Rainbow directory. Found users are * returned both as an indexed map (keyed by login e-mail) and as a flat * array. E-mail addresses that did not match any Rainbow user are returned * in the `emails` array so the caller can handle them as guest invitations. * * @param emails - List of e-mail addresses to resolve. * @returns An object containing: * - `contacts` — a map of `loginEmail → User` for matched users, * - `contactsArray` — the same matched users as a flat array, * - `emails` — e-mail addresses that could not be resolved to a user. */ getUsersByEmails(emails: string[]): Promise; /** * Computes a deterministic color string associated with a user's display name. * The same display name will always produce the same color, making it suitable * for use as a user avatar background color. * @param displayName - The display name of the user * @returns A color string (e.g. a hex or CSS color value) */ computeUserColor(displayName: string): { colorIndex: number; color: string; colorName: string; }; /** * Computes the avatar representation for a user. * If no avatar update timestamp is provided, generates a default avatar image from the user's initials and color. * Otherwise, returns a URL pointing to the server-side avatar image. * @param objId - The unique identifier of the user * @param initials - The user's initials, used to generate a default avatar * @param color - The background color used when generating the default avatar * @param size - The desired avatar size in pixels * @param lastAvatarUpdate - Timestamp of the last avatar update; falsy if no custom avatar exists * @returns An `HTMLImageElement` for a generated default avatar, an object with a `src` URL for a server avatar, or `null` if no initials are available */ computeUserAvatar(objId: string, initials: string, color: string, size: number, lastAvatarUpdate: any): HTMLImageElement | { src: string; } | null; /** * Computes the display name and initials for a user from their first and last name. * The display order (first-last or last-first) is determined by the application settings. * @param firstName - The user's first name * @param lastName - The user's last name * @returns An object containing the formatted `displayName` and the two-letter `initials` */ computeUserName(firstName: string, lastName: string): { displayName: string; initials: string; }; } /** * User Service implementation * @internal */ export declare class UserServiceRB extends Service implements UserService { private rxSubject; private readonly logger; private readonly userInfoService; private contactService?; /** * Returns the Favorite service singleton */ static getInstance(): UserServiceRB; static build(): UserServiceRB; private constructor(); get connectedUser(): ConnectedUser; subscribe(handler: (event: RBEvent) => any, eventNames?: UserServiceEvents | UserServiceEvents[]): Subscription; configure(contactService: any): void; /** * User service events send method * Can listen to it via UserService.subscribe() API * @param name - the name of the event * @param data - the data to be send (an object) */ sendEvent(name: UserServiceEvents, data?: any): void; /** * Get a user by one of its identifier * The user is first search in service cache then server side. * @param userRef - a user jid or user dbId or user jid tel */ getUserById(userRef: string): Promise; getUsersByEmails(emails: string[]): Promise; /** * Check if the jid/dbId belongs to the connected user * @param userRef - a user jid or user dbId or user jid tel */ isConnectedUser(userRef: string): boolean; computeUserColor(displayName: string): { colorIndex: number; color: string; colorName: string; }; computeUserAvatar(objId: string, initials: string, color: string, size: number, lastAvatarUpdate: any): HTMLImageElement | { src: string; } | null; computeUserName(firstName: string, lastName: string): { displayName: string; initials: string; }; } //# sourceMappingURL=user.service.d.ts.map