CometChat Pro Documentation

You'll find comprehensive guides and documentation to help you start working with CometChat as quickly as possible. Let's jump right in!

Image Moderation

Learn how to filter unsafe images.

It's difficult to control the types of images being shared on your platform. So the Image Moderation extension analyzes every image to check if it's unsafe. After analyzing, it classifies the image into four categories- Explicit Nudity, Suggestive Nudity, Violence or Visually Disturbing. Along with that, you will receive the confidence, on a scale of 0 to 100.

"@injected": {
  "extensions": {
    "image-moderation": {
      'unsafe' => 'yes/no',
      'confidence' => '99',
      'category' => 'explicit_nudity/suggestive/violence/visually_disturbing'

A value for confidence that is less than 50 is likely to be a false-positive. So we recommend moderating only if confidence is higher than 50.

You can then either show a warning or drop the image message. This is how Instagram shows a warning for sensitive content:

At the recipients' end, from the message object, you can fetch the metadata by calling the getMetadata() method. Using this metadata, you can fetch information whether the image is safe or unsafe.

JSONObject metadata = message.getMetadata();
if (metadata != null) {
  JSONObject injectedObject = metadata.getJSONObject("@injected");
  if (injectedObject != null && injectedObject.has("extensions")) {
    JSONObject extensionsObject = injectedObject.getJSONObject("extensions");
    if (extensionsObject != null && extensionsObject.has("image-moderation"))
          JSONObject imageModerationObject = extensionsObject.getJSONObject("image-moderation");
          String unsafe = imageModerationObject.getString("unsafe");
          String confidence = imageModerationObject.getString("confidence");
					String category = imageModerationObject.getString("category");

Image Moderation

Learn how to filter unsafe images.

Suggested Edits are limited on API Reference Pages

You can only suggest edits to Markdown body content, but not to the API spec.