Activity Feeds V3 is in closed alpha — do not use it in production (just yet).

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

const client = new FeedsClient("<API key>");

client.moderation;

User Moderation

Ban Users

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

await client.moderation.ban({
  target_user_id: "user-123",
  reason: "Violation of community guidelines",
  timeout: 3600, // 1 hour in seconds
  shadow: false,
  ip_ban: false,
});

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.

client.moderation.mute({
  target_ids: ["user-123", "user-456"],
  timeout: 86400, // 24 hours in seconds
});

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.

await client.blockUsers({
  blocked_user_id: "user-123",
});

Unblock Users

Unblock a previously blocked user.

client.unblockUsers({
  blocked_user_id: "user-123",
});

Get Blocked Users

Retrieve a list of users you have blocked.

client.getBlockedUsers();

Content Moderation

Flag Content

Flag inappropriate content for moderation review.

await client.moderation.flag({
  entity_type: "activity",
  entity_id: "activity_123",
  reason: "Inappropriate content",
});

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.

client.moderation.submitAction({
  // Action details for moderation
});

Review Queue

Query Review Queue

Retrieve items in the moderation review queue.

client.moderation.queryReviewQueue({
  // Query parameters for filtering and pagination
});

Configuration Management

Upsert Moderation Configuration

Create or update moderation configuration settings.

client.moderation.upsertConfig({
    key: 'feeds',
    block_list_config: {
        enabled: true,
        rules: [
        // Names of existing block lists
        { name: blocklistName, action: 'remove', team: '' },
        { name: flagBlocklistName, action: 'flag', team: '' },
        { name: shadowBlocklistName, action: 'shadow', team: '' },
        { name: bounceBlocklistName, action: 'bounce', team: '' },
        ],
    },
    ai_image_config: {
        enabled: true,
        rules: [{ label: 'Non-Explicit Nudity', action: 'remove', min_confidence: 0 }],
        ocr_rules: [{ label: 'Non-Explicit Nudity', action: 'remove' }],
    },
}),

Get Moderation Configuration

Retrieve a specific moderation configuration.

client.moderation.getConfig({
  key: "feeds",
});

Parameters:

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

Delete Moderation Configuration

Remove a moderation configuration.

client.moderation.deleteConfig({
  key: "feeds",
});

Query Moderation Configurations

Search and filter moderation configurations.

client.moderation.queryModerationConfigs({
  filter: {
    // Filter params
  },
});

Error Handling

All moderation methods can throw errors. Handle them appropriately:

try {
  const response = await client.moderation.ban({
    target_user_id: "user-123",
    reason: "Violation of community guidelines",
    timeout: 3600, // 1 hour in seconds
    shadow: false,
    ip_ban: false,
  });

  console.log(`${response.user.id} banned successfully`);
} catch (e) {
  console.error(`Failed to ban user, error: ${e}`);
}
© Getstream.io, Inc. All Rights Reserved.