Files
outline/server/presenters/user.ts
T
Tom MoorandClaude Opus 5 59ea433420 Add Invited by and Joined columns to the users table (#13325)
* Add Invited by and Joined columns to users table

* Move responsive column hiding into column definitions

Adds a hideOnMobile flag to the table column type, handled in the Table
component, replacing per-column isMobile ternaries in the users table.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-06 22:11:41 -04:00

69 lines
1.6 KiB
TypeScript

import type {
NotificationSettings,
UserPreferences,
UserRole,
} from "@shared/types";
import env from "@server/env";
import type { User } from "@server/models";
type Options = {
includeDetails?: boolean;
includeEmail?: boolean;
};
type UserPresentation = {
id: string;
name: string;
avatarUrl: string | null | undefined;
createdAt: Date;
updatedAt: Date;
deletedAt: Date | null;
lastActiveAt: Date | null;
color: string;
role: UserRole;
isSuspended: boolean;
email?: string | null;
language?: string;
preferences?: UserPreferences | null;
notificationSettings?: NotificationSettings;
timezone?: string | null;
invitedBy?: UserPresentation;
};
export default function presentUser(
user: User,
options: Options = {}
): UserPresentation {
const userData: UserPresentation = {
id: user.id,
name: user.name,
avatarUrl: user.avatarUrl,
color: user.color,
role: user.role,
isSuspended: user.isSuspended,
createdAt: user.createdAt,
updatedAt: user.updatedAt,
deletedAt: user.deletedAt,
lastActiveAt: user.lastActiveAt,
timezone: user.timezone,
};
if (options.includeDetails) {
userData.email = user.email;
userData.language = user.language || env.DEFAULT_LANGUAGE;
userData.preferences = user.preferences;
userData.notificationSettings = user.notificationSettings;
}
if (options.includeEmail) {
userData.email = user.email;
}
// Only included when the association has been eager-loaded by the caller.
if (user.invitedBy) {
userData.invitedBy = presentUser(user.invitedBy);
}
return userData;
}