createForwardMessageListFileDetail static method
Future<NIMResult<String>>
createForwardMessageListFileDetail(
- List<NIMMessage> messages
)
Implementation
static Future<NIMResult<String>> createForwardMessageListFileDetail(
List<NIMMessage> messages) async {
if (messages.isEmpty) {
return NIMResult.failure(message: 'message is empty');
}
var sessionId = messages.first.sessionId;
if (sessionId == null) {
return NIMResult.failure(message: 'sessionId is null');
}
var forwardMsgList = messages.where((msg) {
//不是来自同一会话,不添加
//不是可以转发的类型,不添加,通知,语音,话单,机器人等不可转发
return msg.sessionId == sessionId &&
(msg.messageType != NIMMessageType.notification &&
msg.messageType != NIMMessageType.avchat &&
msg.messageType != NIMMessageType.robot);
}).toList();
String header = _buildHeader(0, forwardMsgList.length);
var bodyResult = await _buildBody(forwardMsgList);
if (bodyResult.isSuccess) {
return NIMResult.success(data: '$header\n${bodyResult.data}');
} else {
return NIMResult.failure(message: bodyResult.errorDetails);
}
}