User object
User represents a single user in a chat.
Properties
User has the following properties:
1public class User : UniqueChatEntity {
2 public string Id { get; protected set; }
3 public string UserName { get; }
4 public string ExternalId { get; }
5 public string ProfileUrl { get; }
6 public string Email { get; }
7 public Dictionary<string, object> CustomData { get; }
8 public string Status { get; }
9 public string DataType { get; }
10 public bool Active { get; }
11 public string LastActiveTimeStamp { get; }
12}
| Parameter | Description |
|---|---|
IdType: string | Unique identifier for the user. |
UserNameType: string | Display name or username of the user. |
ExternalIdType: string | Identifier for the user from an external system, such as a database or CRM. |
ProfileUrlType: string | URL to the user's profile or avatar image. |
EmailType: string | User's email address. |
CustomDataType: Dictionary<string, object> | Any custom data that you want to store for the user. |
StatusType: string | Current status of the user (e.g., online, offline, away). |
DataTypeType: string | Type of user's data. |
ActiveType: bool | Returned info on whether the user is active (true) or not active (false) on the channel. The returned value depends strictly on how you configure your chat app during initialization - if you set the StoreUserActivityInterval parameter to the default 60000 milliseconds (1 minute) and the user has been active in the app within the last 1 minute (based on their LastActiveTimeStamp property), accessing the Active property returns true. |
LastActiveTimeStampType: string | Timestamp for the last time the user was active in a chat app. |
API limits
To learn about the maximum length of parameters used to set user metadata, refer to REST API docs.
Events
The User object has the following events:
1// Event triggered when the user is updated.
2// Call StreamUpdates(true) to enable this callback.
3public event Action<User> OnUpdated;
4// Event triggered when the user is hard-deleted from App Context.
5// Call StreamUpdates(true) to enable this callback.
6public event Action OnDeleted;
7// Event triggered when a user is mentioned in a message.
8// Call StreamMentionEvents(true) to enable this callback.
9public event Action<Mention> OnMentioned;
10// Event triggered when a user is invited to a channel.
11// Call StreamInviteEvents(true) to enable this callback.
12public event Action<Invite> OnInvited;
13// Event triggered when a user's moderation restrictions change.
14// Call StreamModerationEvents(true) to enable this callback.
15public event Action<ChannelRestriction> OnRestrictionChanged;
Example
An event that is triggered when the user is updated by the server.
1
Methods
You can call the following methods on the User object.
Click on each method for more details.
Standard methods
Delete()GetChannelRestrictions()GetChannelsRestrictions()GetMembership()GetMemberships()IsMemberOn()IsPresentOn()SetRestriction()Update()WherePresent()
Streaming methods
These methods register or unregister real-time event subscriptions. Each streaming method activates one or more of the events listed in the Events section above.
StreamInviteEvents()StreamMentionEvents()StreamModerationEvents()StreamUpdates()StreamUpdatesOn()
Use case
User methods enable:
- Creating and managing users
- Configuring channel memberships
- Checking if a user is a member of a channel
- Mentioning others in conversations
- Checking user presence status