Block User

LAST EDIT Oct 14 2024

Overview

Copied!

The user block feature allows users to control their 1-on-1 interactions within the chat application by blocking other users. When a user is blocked, several changes occur to the blocked user's experience and the blocker’s interactions within the application.

  • Direct Communication Termination

    • When a user blocks another user, all direct 1-on-1 communication channels are hidden for the blocking user.

  • Adding to Channels

    • If a blocked user tries to add the blocking user to a channel as a member, the action is ignored. The channel will not include the blocking user but will have the remaining members.

  • Push Notifications

    • The blocking user will not receive push notifications from blocked users for 1-on-1 channels.

  • Channel Events

    • The blocking user will not receive any events from blocked users in 1-on-1 channels (e.g., message.new).

  • Group Channels

    • Group channels are unaffected by the block. Both the blocking and blocked users can participate, receive push notifications, and events in group channels.

  • Query Channels

    • When hidden channels are requested, 1-on-1 channels with blocked users will be returned with a blocked:true flag and all the messages.

  • Active Chats and Unread Counts

    • Blocked users will not appear in the blocking user's list of active chats. Messages from blocked users will not contribute to unread counts.

  • Unblocking Users

    • After unblocking, all previous messages in 1-on-1 channels become visible again, including those sent during the block period.

  • Hidden Channels

    • Channels with only the blocked and blocking users are marked as hidden for the blocking user by default.

    • If a blocked user sends a message in a hidden channel, the channel remains hidden for the blocking user.

  • Group Channel Messages

    • Messages from blocked users will still appear when retrieving messages from a group channel.

  • WebSocket Connection

    • When connecting to the WebSocket, the blocking user receives a list of users they have blocked (user.blocked_users). This is only available for the blocking user's own account.

  • Message Actions

    • Actions such as sending, updating, reacting to, and deleting messages will still work in blocked channels. However, since the channels are hidden, these actions will not be visible to the blocking user.

Features

Copied!
  1. Block User: Users can block others in 1-on-1 chats, preventing further direct communication.

  2. Get Blocked Users: Users can view a list of individuals they have blocked.

  3. Unblock User: Users can unblock previously blocked users, allowing direct communication to resume.

Setup example

Copied!

Any user is allowed to block another user. BlockedUsers are stored at the user level and returned with the rest of the user information when connectUser is called. A user will be blocked until the user is unblocked.

Block User

Copied!

Unblock user

Copied!

List of Blocked Users

Copied!

Server Side

Copied!

Block User

Copied!

Unblock user

Copied!

Get List of Blocked Users

Copied!