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

let client = FeedsClient(apiKey: apiKey, user: user, token: token)
let moderation = client.moderation

User Moderation

Ban Users

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

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

let response = try await client.moderation.ban(banRequest: banRequest)
print("User banned for: \(response.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

To reverse a ban, see Unban User in the Moderation docs. The user object returned by queryUsers only exposes the ban state (banned, ban_expires) — it does not include banned_by or the ban reason. To retrieve that metadata, use Query Banned Users.

Mute Users

Mute is not supported in Feeds. Muting a user does not hide their activities from feed reads.

To hide another user's activities in Feeds, use Block Users instead.

Block Users

Block a user. Blocking is bidirectional:

  • Neither user sees the other's activities in feeds
  • Neither can follow the other

This replaces the v2 discard_actors option. Instead of sending blocked user IDs on every feed read, call blockUsers once — Stream filters those activities automatically.

let blockRequest = BlockUsersRequest(blockedUserId: "user-123")
let response = try await client.moderation.blockUsers(blockUsersRequest: blockRequest)

Unblock Users

Unblock a previously blocked user.

let unblockRequest = UnblockUsersRequest(blockedUserId: "user-123")
let response = try await client.moderation.unblockUsers(unblockUsersRequest: unblockRequest)

Get Blocked Users

Retrieve a list of users you have blocked.

let blockedUsers = try await client.moderation.getBlockedUsers()
for block in blockedUsers.blocks {
    print("Blocked user: \(block.blockedUserId)")
}

Content Moderation

Flag Content

Flag inappropriate content for moderation review.

let flagRequest = FlagRequest(
    entityId: "activity-123",
    entityType: "stream:feeds:v3:activity",
    reason: "Inappropriate content",
    entityCreatorId: "user-456"
)

let response = try await client.moderation.flag(flagRequest: flagRequest)

Parameters:

  • entityId: The ID of the content to flag
  • entityType: The type of content (e.g., "stream:feeds:v3:activity", "stream:feeds:v3: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.

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

let response = try await client.moderation.submitAction(submitActionRequest: actionRequest)

Review Queue

Query Review Queue

Retrieve items in the moderation review queue.

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

let reviewQueue = try await client.moderation.queryReviewQueue(queryReviewQueueRequest: queryRequest)

Configuration Management

Upsert Moderation Configuration

Create or update moderation configuration settings.

let configRequest = UpsertConfigRequest(
    // Configuration details
)

let response = try await client.moderation.upsertConfig(upsertConfigRequest: configRequest)

Get Moderation Configuration

Retrieve a specific moderation configuration.

let config = try await 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.

let response = try await client.moderation.deleteConfig(key: "automod_settings", team: "team-123")

Query Moderation Configurations

Search and filter moderation configurations.

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

let configs = try await 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. Error handling documents the exception classes and their fields for each backend SDK, and API error codes explains what the codes mean. Handle them appropriately:

do {
    let response = try await client.moderation.ban(banRequest: banRequest)
    print("User banned successfully")
} catch {
    print("Failed to ban user: \(error)")
}