Moderation Tools

Last Edit: Nov 27 2020

Flag

Any user is allowed to flag a message or a user.


const flag = await client.flagMessage(messageResponse.message.id);
                    

$flag = $client->flagMessage('message-id', ['user_id' => 'user-id']);
                    

await client.flagMessage("messageID");
                    

let message = Message(text: "bad bad sentence")
message.flag { (result) in
    // handle result
}

// and unflag
message.unflag { (result) in /**/ }

let john = User(id: "john")
User.current.flag(user: john) { (result) in /**/ }

User.current.unflag(user: john) { (result) in /**/ }
                    

Mutes

Any user is allowed to mute another user. Mutes are stored at user level and returned with the rest of the user information when setUser is called. A user will be be muted until the user is unmuted or the mute is expired.

Name Type Description Default Optional
timeout number The timeout in minutes until the mute is expired. no limit

// client-side mute
const mute = await client.muteUser('eviluser');

// client-side mute for 60 minutes
const mute = await client.muteUser('eviluser', null, {
    timeout: 60
});

// server-side mute requires the id of the user creating the mute as well
const mute = await client.muteUser('eviluser', 'user_id');
                    

// server-side mute requires the id of the user creating the mute as well
$mute = $client->muteUser('evil-user', 'user-id');
                    

await client.muteUser("eviluser");

await client.unmuteUser("eviluser");
                    

let john = User(id: "john")
john.mute { (result) in /**/ }
john.unmute { (result) in /**/ }
                    

After muting a user messages will still be delivered via web-socket. Implementing business logic such as hiding messages from muted users or display them differently is left to the developer to implement.

Messages from muted users are not delivered via push (APN/Firebase)

Ban

Users can be banned from an app entirely or from a channel. When a user is banned, it will not be allowed to post messages until the ban is removed or expired but it will be able to connect to Chat and to channels as before.

It is also possible to ban the user's last known IP address to prevent creation of new "throw-away" accounts. This type of ban is only applicable on the app level. We do not recommend applying IP ban without reasonable timeout, however this is not restricted. The IP address will be unbanned either after reaching a timeout or with explicit user unban.

In most cases only admins or moderators are allowed to ban other users from a channel.

Name Type Description Default Optional
timeout number The timeout in minutes until the ban is automatically expired. no limit
reason string The reason that the ban was created.
ip_ban boolean Whether or not to apply IP address ban false
banned_by_id string The ID of the user who is performing the ban. This is required only when using API from the server-side
Banning a user from all channels can only be done using server-side auth.

// ban a user for 60 minutes from all channel
let data = await client.banUser('eviluser', {
    banned_by_id: userID, // ID of the user who is performing the ban (Server-side auth)
    timeout: 60,
    reason: 'Banned for one hour',
});

// ban a user and their IP address for 24 hours
let data = await client.banUser('eviluser', {
   banned_by_id: userID,
   timeout: 24*60,
   ip_ban:  true,
   reason: 'Please come back tomorrow',
});

// ban a user from the livestream:fortnite channel
data = await channel.banUser('eviluser', {
    banned_by_id: userID,
    reason: 'Profanity is not allowed here',
});

// remove ban from channel
data = await channel.unbanUser('eviluser');

// remove global ban
data = await authClient.unbanUser('eviluser');
                    

# ban a user for 60 minutes from all channel
client.ban_user("eviluser", banned_by_id=admin_id, timeout=60, reason="Banned for one hour")

# ban a user and their IP address for 24 hours
client.ban_user("eviluser", banned_by_id=admin_id, timeout=24*60, ip_ban=true, reason="Please come back tomorrow")

# ban a user from the livestream:fortnite channel
channel.ban_user("eviluser", banned_by_id=admin_id, reason="Profanity is not allowed here")

# remove ban from channel
channel.unban_user("eviluser")

# remove global ban
client.unban_user("eviluser")
                    

client.banUser(userId, channel, reason, timeout, new CompletableCallback() {
    @Override
    public void onSuccess(CompletableResponse response) {
        
    }

    @Override
    public void onError(String errMsg, int errCode) {

    }
});
                    

let channel = Client.shared.channel(type: .messaging, id: "general")
let john = User(id: "john")

channel.ban(user: john)
// or
channel.ban(user: user, timeoutInMinutes: 10, reason: "Bad words!") { result in /* Handle Result */ }
                    

client.banUser(userId, channel, reason, timeout, object : CompletableCallback {
    override fun onSuccess(response: CompletableResponse) {

    }

    override fun onError(errMsg: String, errCode: Int) {

    }
})
                    

// ban a user for 60 minutes from all channel
$ban = $client->banUser('evil-user', [
    'timeout' => 60,
    'reason' => 'Banned for one hour',
    'banned_by_id' => 'user-id'
]);

// ban a user and their IP address for 24 hours
$ban = $channel->banUser('evil-user', [
    'banned_by_id' => 'user-id'
    'timeout' => 24*60,
    'ip_ban' => true,
    'reason' => 'Please come back tomorrow',
]);

// ban a user from the livestream:fortnite channel
$ban = $channel->banUser('evil-user', [
    'reason' => 'Banned for one hour',
    'banned_by_id' => 'user-id'
]);

// remove ban from channel
$unban = $channel->unbanUser('evil-user');

// remove global ban
$unban = $client->unbanUser('evil-user');
                    

List banned users

You can list banned users from the API directly using the user search endpoint or the member search endpoint. You use the first to get the list of users banned from all channels and the second to list users that are banned from a specific channel. Both endpoints support additional query parameters as well as pagination, you can find the full information on the specific doc sections.


// retrieve the list of banned users
const response = await client.queryUsers({banned:true}, {}, {limit:10, offset:0});

// query for banned members in channel
channel.queryMembers({banned:true}, {}, {limit:10, offset:0})
                    

// retrieve the list of banned users
client.queryUsers(QueryUsersRequest(filter, offset, limit)).enqueue { result ->
    println(result.data())
}

// query for banned members in channel
client.queryMembers(channelType, channelId, offset, limit, filter).enqueue { result ->
    println(result.data())
}
                    

Shadow Ban

Users can be shadow banned from an app entirely or from a channel. When a user is shadow banned, it will still be allowed to post messages, but any message sent during, will have shadowed: true field. However, this will be invisible from the author of the message.

It's up to the client-side implementation to hide or otherwise handle these messages appropriately.


// shadow ban a user from all channels
let data = await client.shadowBan('eviluser');

// shadow ban a user from a channel
data = await channel.shadowBan('eviluser');

// remove shadow ban from channel
data = await channel.removeShadowBan('eviluser');

// remove global shadow ban
data = await client.removeShadowBan('eviluser');
                    

Administrators can view shadow banned user status in queryChannels(), queryMembers() and queryUsers().

Automod

For livestream and gaming channel types Automod is enabled by default. There are three options for moderation:

  • disabled
  • simple (blocks messages that contain a list of profane words)
  • ai (uses an AI-based classification system to detect various types of bad content)
AI-based moderation is a premium feature. Please contact sales to discuss your options.