tencent cloud

Chat

製品の説明
製品の概要
Basic Concepts
ユースケース
機能概要
アカウントシステム
ユーザープロフィールとリレーションシップチェーン
メッセージ管理
グループシステム
Official Account
Audio/Video Call
使用制限
購入ガイド
課金概要
価格説明
Purchase Instructions
Renewal Guide
支払い延滞説明
Refund Policy
ダウンロードセンター
SDK & Demo ソースコード
更新ログ
シナリオプラン
Live Streaming Setup Guide
AI Chatbot
極めて大規模なエンターテインメントコラボレーションコミュニティ
Discord実装ガイド
ゲーム内IM統合ガイド
WhatsApp Channel-style Official Account Integration Solution
Send Red Packet
Firewall Restrictions
クライアントAPIs
SDK API(Web)
Android
iOS & macOS
Swift
Flutter
SDK API(Electron)
SDK APIs (Unity)
SDK API(React Native)
C APIs
C++
サービス側 APIs
UserSigの生成
RESTful APIs
Webhooks
コンソールガイド
New Console Introduction
アプリケーションの作成とアップグレード
基本設定
機能設定
アカウント管理
グループ管理
Official Channel Management
コールバック設定
監視ダッシュボード
Viewing Guide for Resource Packages
Real-Time Monitor
補助ツールの開発
アクセス管理
Advanced Features
よくあるご質問
uni-app FAQs
 購入に関する質問
SDKに関する質問
アカウント認証に関する質問
ユーザープロファイルとリレーションシップチェーンに関する質問
メッセージに関する質問
グループに関する質問
ライブ配信グループに関する質問
ニックネームプロフィール画像に関連した問題
一般的なリファレンス
Service Level Agreement
セキュリティコンプライアンス認証
IM ポリシー
プライバシーポリシー
データプライバシーとセキュリティ契約
エラーコード
お問い合わせ

JavaScript

フォーカスモード
フォントサイズ
最終更新日: 2025-01-07 16:18:24

Feature Overview

To block a user's messages, add the user to the blocklist.
Note:
1. The maximum limit for the blocklist is 1000, and it cannot be adjusted.
2. If you need to add a friend to the blocklist while still maintaining the friendship, go to the Chat console, find the corresponding SDKAppID, navigate to Chat > Configuration > Friends and Relationship > Block configuration, and select Remain Friends.

Blocking a user

By adding a user to the blocklist, you can block all the messages sent by the user. Therefore, this API can be used to block the messages of a specified user.
If user A and user B are friends, the two-way friend relationship is terminated when either A or B is blocked by the other user.
If either user A or user B is blocked by the other user, neither user A nor user B can start a conversation with the other user.
If either user A or user B is blocked by the other user, neither user A nor user B can send a friend request to the other user.
API
chat.addToBlacklist(options);
Parameters
The options parameter is of the Object type. It contains the following attribute values:
Name
Type
Description
userIDList
Array
List of userID values of the users to be added to the blocklist. The number of userID values cannot exceed 1,000 per request.
Return value
Promise
Examples
let promise = chat.addToBlacklist({userIDList: ['user1', 'user2']});
promise.then(function(imResponse) {
console.log(imResponse.data);
console.warn('addToBlacklist error:', imError); // Failed to add the user to the blocklist
});

Unblocking a user

After a user is removed from the blocklist, messages from the user can be received.
API
chat.removeFromBlacklist(options);
Parameters
The options parameter is of the Object type. It contains the following attribute values:
Name
Type
Description
userIDList
Array
List of userID values of the users to be removed from the blocklist. The number of userID values cannot exceed 1,000 per request.
Return value
Promise
Examples
let promise = chat.removeFromBlacklist({userIDList: ['user1', 'user2']});
console.log(imResponse.data);
console.warn('removeFromBlacklist error:', imError); // Failed to remove the user from the blocklist
});

Getting the blocklist

The blocklist cached in the SDK can be obtained.
API
chat.getBlacklist();
Return value
Promise
Examples
let promise = chat.getBlacklist();
promise.then(function(imResponse) {
console.log(imResponse.data);
}).catch(function(imError) {
console.warn('getBlacklist error:', imError); // Failed to obtain the blocklist
});

Notification of a change in the blocklist

When a blocklist is updated, the SDK will deliver the TencentCloudChat.EVENT.BLACKLIST_UPDATED event.
Examples
let onBlacklistUpdated = function(event) {
console.log(event.data);
};
chat.on(TencentCloudChat.EVENT.BLACKLIST_UPDATED, onBlacklistUpdated);


ヘルプとサポート

この記事はお役に立ちましたか?

フィードバック