Privacy SettingsUSER-ONLY
User Walkthrough 20 of 50
Users can control who can see account information and use features such as calls and group invitations.
Getting Privacy Rules
getPrivacySetting with a PrivacySettingKey lets you get PrivacyRule objects.
const rules = await client.getPrivacySetting("phoneNumber");
for (const rule of rules) {
console.log(rule);
}
Setting Privacy Rules
setPrivacySetting accepts InputPrivacyRule objects. This example makes the profile photo visible to contacts only.
await client.setPrivacySetting("profilePhoto", [
{ type: "contacts", isAllowed: true },
{ type: "everybody", isAllowed: false },
]);
Adding User Exceptions
With a users rule, you can add exceptions. This example hides the last seen time from everybody except one user.
await client.setPrivacySetting("lastSeen", [
{ type: "users", usersId: [userId], isAllowed: true },
{ type: "everybody", isAllowed: false },
]);