Mask Sensitive Content

When content gets flagged, there’s a window of time before it’s reviewed—during which any sensitive content is still visible to an end user. This might not be ideal, especially for things like phone numbers or other private information.

Mask and Flag is a two-part moderation action that:

  1. Masks blocklisted words in the content by replacing them with asterisks
  2. Flags the content for moderator review

When this action is triggered, users see the censored version of the content while moderators can review the original content.

If you only want to censor the words without sending the content to the review queue, use the mask action instead of mask_flag.

Mask and Flag is supported for:

  • Chat messages
  • Activity Feeds v3 activities and comments
Warning:

Mask and Flag is not supported for Activity Feeds v2.

Setup Mask and Flag Action for Chat Moderation

Mask and Flag is available as an action for blocklist. You can use mask_flag action in your block_list_config's rule.

client.moderation().upsertConfig(UpsertConfigRequest.builder()
    .key("chat")
    .blockListConfig(BlockListConfig.builder()
        .enabled(true)
        .rules(List.of(BlockListRule.builder()
            .name(blocklistName)
            .action("mask_flag")
            .team("")
            .build()))
        .build())
    .build())
    .execute();

Setup Mask and Flag Action for Activity Feeds v3

Mask and Flag works the same way for Activity Feeds v3. Add a mask_flag rule to the block_list_config of your feeds policy, using the feeds config key (or a more specific feeds:{group_id} / feeds:{group_id}:{feed_id} key). Activities and comments are both covered by the same policy.

client.moderation().upsertConfig(UpsertConfigRequest.builder()
    .key("feeds")
    .blockListConfig(BlockListConfig.builder()
        .enabled(true)
        .rules(List.of(BlockListRule.builder()
            .name(blocklistName)
            .action("mask_flag")
            .team("")
            .build()))
        .build())
    .build())
    .execute();

When an activity or comment matches the blocklist:

  • The stored text is replaced with the masked version, so every reader, including the author, sees the censored text.
  • The original text is returned in moderation.original_text in the response of the add or update call. Moderators can always see the original text in the review queue.
  • With mask_flag, the item is flagged (moderation_action: "flag" on the activity, moderation.action: "flag" on the comment) and shows up in the review queue.

Moderators can use the Unmask action in the review queue to restore the original text.

Usecases

Mask phone numbers

We can use "Mask and Flag" feature so that phone numbers will not be shown to a user in Chat messages or in Activity Feeds v3 activities and comments.

Create a Policy and add a regex filter blocklist for the phone number(Example phone number regex: (?m)(\+?\d{1,2}\s?)?(\(?\d{3}\)?[\s.-]?)?\d{3}[\s.-]?\d{4}). Set the action of that policy to Mask and Flag

That's it! Phone number sent by users will be masked and won't be exposed to an end user. Moderator can still see the original content and will be able to take an informed decision.

Add Chat to my app: getstream.io/SKILL.md

The fastest way to build with Stream. Start a new project or improve an existing one. Full CLI and documentation integration out of the box.


Ask your agent:

/stream Build me a Social App with Feeds and Moderation.
/stream Any livestream calls running?
/stream Moderation Java: <Your Question>