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;
status?: | {
activeUntil?: string | null;
effects?: {
pauseActivity?: {
scope?: {
mode?: ... | ...;
};
};
pauseNotifications?: {
scope?: {
mode?: ... | ...;
};
};
};
emoji?: string | null;
message: string;
}
| null;
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;
status?: | {
activeUntil?: string | null;
effects?: {
pauseActivity?: {
scope?: {
mode?: ... | ...;
};
};
pauseNotifications?: {
scope?: {
mode?: ... | ...;
};
};
};
emoji?: string | null;
message: string;
}
| null;
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; status?: { activeUntil?: string | null; effects?: { pauseActivity?: { scope?: { mode?: string } }; pauseNotifications?: { scope?: { mode?: string } } }; emoji?: string | null; message: string } | null; version: number };
Narrows a VisibleWorkspaceUser to the reduced shape, which has no
timezone and no userType.
Parameters
| Parameter | Type | Description |
|---|---|---|
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; status?: | { activeUntil?: string | null; effects?: { pauseActivity?: { scope?: { mode?: ... | ...; }; }; pauseNotifications?: { scope?: { mode?: ... | ...; }; }; }; emoji?: string | null; message: string; } | null; 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; status?: | { activeUntil?: string | null; effects?: { pauseActivity?: { scope?: { mode?: ... | ...; }; }; pauseNotifications?: { scope?: { mode?: ... | ...; }; }; }; emoji?: string | null; message: string; } | null; 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; status?: { activeUntil?: string | null; effects?: { pauseActivity?: { scope?: { mode?: string } }; pauseNotifications?: { scope?: { mode?: string } } }; emoji?: string | null; message: string } | null; 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