Activity Feeds v3 is in beta — try it out!

Moderation

Stream Feeds has support for moderation, allowing you to manage user interactions, content moderation, and platform safety. It’s accessible through the client.moderation property.

Overview

val client = FeedsClient(context = context, apiKey = apiKey, user = user, tokenProvider = tokenProvider)
val moderation = client.moderation

User Moderation

Ban Users

Ban a user from the platform with various options including timeout, shadow bans, and IP bans.

val banRequest = BanRequest(
    targetUserId = "user-123",
    reason = "Violation of community guidelines",
    timeout = 3600, // 1 hour in seconds
    shadow = false,
    ipBan = false
)

val response: Result<BanResponse> = client.moderation.ban(banRequest = banRequest)
println("User banned for: ${response.getOrNull()?.duration}")

Parameters:

  • targetUserId: The ID of the user to ban
  • reason: Optional reason for the ban
  • timeout: Optional timeout in seconds (null for permanent ban)
  • shadow: Whether to perform a shadow ban (user doesn’t know they’re banned)
  • ipBan: Whether to ban the user’s IP address
  • bannedBy: Optional user who performed the ban
  • deleteMessages: Whether to delete user’s messages

Mute Users

Mute one or more users to prevent them from interacting with your content.

val muteRequest = MuteRequest(
    targetIds = listOf("user-123", "user-456"),
    timeout = 86400 // 24 hours in seconds
)

val response: Result<MuteResponse> = client.moderation.mute(muteRequest = muteRequest)

Parameters:

  • targetIds: Array of user IDs to mute
  • timeout: Optional timeout in seconds (null for permanent mute)

Block Users

Block a user to prevent them from following you or seeing your content.

val blockRequest = BlockUsersRequest(blockedUserId = "user-123")
val response: Result<BlockUsersResponse> = client.moderation.blockUser(blockRequest)

Unblock Users

Unblock a previously blocked user.

val unblockRequest = UnblockUsersRequest(blockedUserId = "user-123")
val response: Result<UnblockUsersResponse> = client.moderation.unblockUser(unblockRequest)

Get Blocked Users

Retrieve a list of users you have blocked.

val blockedUsers: Result<GetBlockedUsersResponse> = client.moderation.getBlockedUsers()
blockedUsers.getOrNull()?.blocks?.forEach { block ->
    println("Blocked user: ${block.user.id}")
}

Content Moderation

Flag Content

Flag inappropriate content for moderation review.

val flagRequest = FlagRequest(
    entityId = "activity-123",
    entityType = "activity",
    reason = "Inappropriate content",
    entityCreatorId = "user-456"
)

val response: Result<FlagResponse> = client.moderation.flag(flagRequest = flagRequest)

Parameters:

  • entityId: The ID of the content to flag
  • entityType: The type of content (e.g., “activity”, “comment”)
  • reason: Optional reason for flagging
  • entityCreatorId: Optional ID of the content creator
  • custom: Optional custom data for the flag

Submit Moderation Actions

Submit moderation actions for flagged content.

val actionRequest = SubmitActionRequest(
    // Action details for moderation
)

val response: Result<SubmitActionResponse> = client.moderation.submitAction(submitActionRequest = actionRequest)

Review Queue

Query Review Queue

Retrieve items in the moderation review queue.

val queryRequest = QueryReviewQueueRequest(
    // Query parameters for filtering and pagination
)

val reviewQueue: Result<QueryReviewQueueResponse> = client.moderation.queryReviewQueue(queryRequest)

Configuration Management

Upsert Moderation Configuration

Create or update moderation configuration settings.

val configRequest = UpsertConfigRequest(
    // Configuration details
)

val response: Result<UpsertConfigResponse> = client.moderation.upsertConfig(configRequest)

Get Moderation Configuration

Retrieve a specific moderation configuration.

val config: Result<GetConfigResponse> = client.moderation.getConfig(key = "automod_settings", team = "team-123")

Parameters:

  • key: The configuration key to retrieve
  • team: Optional team identifier

Delete Moderation Configuration

Remove a moderation configuration.

val response: Result<DeleteModerationConfigResponse> = client.moderation.deleteConfig(key = "automod_settings", team = "team-123")

Query Moderation Configurations

Search and filter moderation configurations.

val queryRequest = QueryModerationConfigsRequest(
    // Query parameters for filtering and pagination
)

val configs: Result<QueryModerationConfigsResponse> = client.moderation.queryModerationConfigs(queryModerationConfigsRequest = queryRequest)

Moderation Config Queryable Built-In Fields

nametypedescriptionsupported operationsexample
keystring or list of stringsThe configuration key identifier$eq, $ne, $gt, $gte, $lt, $lte, $in, $nin, $exists, $autocomplete{ key: { $autocomplete: 'spam' } }
teamstring or list of stringsThe team identifier for multi-tenant applications$eq, $ne, $gt, $gte, $lt, $lte, $in, $nin, $exists{ team: { $eq: 'team_123' } }
created_atstring, must be formatted as an RFC3339 timestampThe time the configuration was created$eq, $gt, $gte, $lt, $lte{ created_at: { $gte: '2023-12-04T09:30:20.45Z' } }
updated_atstring, must be formatted as an RFC3339 timestampThe time the configuration was last updated$eq, $gt, $gte, $lt, $lte{ updated_at: { $gte: '2023-12-04T09:30:20.45Z' } }

Error Handling

All moderation methods can throw errors. Handle them appropriately:

// Functions that can result in errors, return Kotlin `Result` objects
val result: Result<BanResponse> = client.moderation.ban(banRequest)
© Getstream.io, Inc. All Rights Reserved.