Skip to main content

isRestrictedWorkspaceUser()

function isRestrictedWorkspaceUser(user:
| {
avatarUrls?: | {
s195: string;
s35: string;
s60: string;
s640: string;
}
| null;
dateFormat?: string | null;
email?: string | null;
firstName?: string | null;
fullName: string;
id: number;
imageId?: string | null;
removed: boolean;
restricted?: boolean | null;
setupPending?: boolean | null;
shortName: string;
theme?: number | null;
timeFormat?: string | null;
timezone: string;
userType: "USER" | "GUEST" | "ADMIN";
version: number;
}
| {
avatarUrls?: | {
s195: string;
s35: string;
s60: string;
s640: string;
}
| null;
firstName?: string | null;
fullName: string;
id: number;
imageId?: string | null;
removed: boolean;
restricted: true;
setupPending?: boolean | null;
shortName: string;
version: number;
}): user is { avatarUrls?: { s195: string; s35: string; s60: string; s640: string } | null; firstName?: string | null; fullName: string; id: number; imageId?: string | null; removed: boolean; restricted: true; setupPending?: boolean | null; shortName: string; version: number };

Narrows a VisibleWorkspaceUser to the reduced shape, which has no timezone and no userType.

Parameters

ParameterTypeDescription
user| { avatarUrls?: | { s195: string; s35: string; s60: string; s640: string; } | null; dateFormat?: string | null; email?: string | null; firstName?: string | null; fullName: string; id: number; imageId?: string | null; removed: boolean; restricted?: boolean | null; setupPending?: boolean | null; shortName: string; theme?: number | null; timeFormat?: string | null; timezone: string; userType: "USER" | "GUEST" | "ADMIN"; version: number; } | { avatarUrls?: | { s195: string; s35: string; s60: string; s640: string; } | null; firstName?: string | null; fullName: string; id: number; imageId?: string | null; removed: boolean; restricted: true; setupPending?: boolean | null; shortName: string; version: number; }The user to check.

Returns

user is { avatarUrls?: { s195: string; s35: string; s60: string; s640: string } | null; firstName?: string | null; fullName: string; id: number; imageId?: string | null; removed: boolean; restricted: true; setupPending?: boolean | null; shortName: string; version: number }

true when the viewer only gets the restricted profile.

Example

const user = await api.workspaceUsers.getUserById({ workspaceId: 123, userId: 456 })
const zone = isRestrictedWorkspaceUser(user) ? 'UTC' : user.timezone