|
|
@@ -1,10 +1,17 @@ |
|
|
|
import 'dart:typed_data';
|
|
|
|
import 'dart:convert';
|
|
|
|
|
|
|
|
import 'package:chat/data/UserData.dart';
|
|
|
|
import 'package:chat/data/constants.dart';
|
|
|
|
import 'package:chat/generated/i18n.dart';
|
|
|
|
import 'package:chat/proto/chat.pb.dart';
|
|
|
|
import 'package:chat/proto/chat.pbenum.dart';
|
|
|
|
import 'package:chat/proto/transhousekeeper.pb.dart';
|
|
|
|
import 'package:chat/utils/date_utils.dart';
|
|
|
|
import 'package:chat/utils/file_cache_mgr.dart';
|
|
|
|
import 'package:chat/utils/sql_util.dart';
|
|
|
|
import 'package:chat/data/group_data_mgr.dart';
|
|
|
|
import 'package:chat/utils/upload_util.dart';
|
|
|
|
|
|
|
|
class MsgState {
|
|
|
|
static const int None = 0; //默认
|
|
|
@@ -196,4 +203,84 @@ class MsgModel { |
|
|
|
|
|
|
|
return textList.length == 0 ? [''] : textList;
|
|
|
|
}
|
|
|
|
|
|
|
|
getFileUrl() {
|
|
|
|
var fullUrl = UploadUtil().getFullUrl(extraFile, sessionId, channelType);
|
|
|
|
if (extraFile.contains('http://')) {
|
|
|
|
fullUrl = extraFile;
|
|
|
|
}
|
|
|
|
|
|
|
|
return fullUrl;
|
|
|
|
}
|
|
|
|
|
|
|
|
//发送给翻译人员的记录
|
|
|
|
shortRecordForTranslator() {
|
|
|
|
String desc = '';
|
|
|
|
switch (ChatType.valueOf(msgType)) {
|
|
|
|
case ChatType.TextChatType:
|
|
|
|
desc = utf8.decode(msgContent);
|
|
|
|
break;
|
|
|
|
case ChatType.EmoticonType:
|
|
|
|
desc = '[${I18n.of(Constants.getCurrentContext()).emoji}]';
|
|
|
|
break;
|
|
|
|
case ChatType.ImageChatType:
|
|
|
|
case ChatType.ShortVideoChatType:
|
|
|
|
case ChatType.ShortVoiceChatType:
|
|
|
|
case ChatType.FileChatType:
|
|
|
|
desc = getFileUrl();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ChatType.PlaceChatType:
|
|
|
|
desc = '[${I18n.of(Constants.getCurrentContext()).locate}]';
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ChatType.GiftChatType:
|
|
|
|
GiftChat giftChat = GiftChat.fromBuffer(msgContent);
|
|
|
|
|
|
|
|
if (giftChat.tuId == UserData().basicInfo.userId) {
|
|
|
|
desc = I18n.of(Constants.getCurrentContext()).you_get;
|
|
|
|
} else {
|
|
|
|
desc = I18n.of(Constants.getCurrentContext()).you_give;
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ChatType.RedWalletChatType:
|
|
|
|
if (from == 0) {
|
|
|
|
//服务器通知消息
|
|
|
|
RedWallet wallet = RedWallet.fromBuffer(msgContent);
|
|
|
|
if (wallet.state == RedWalletState.Received) {
|
|
|
|
var myId = UserData().basicInfo.userId;
|
|
|
|
if (wallet.suId == myId) {
|
|
|
|
desc = I18n.of(Constants.getCurrentContext())
|
|
|
|
.get_money
|
|
|
|
.replaceFirst('/s1', '好友');
|
|
|
|
} else {
|
|
|
|
desc = I18n.of(Constants.getCurrentContext())
|
|
|
|
.you_get_money
|
|
|
|
.replaceFirst('/s1', '好友');
|
|
|
|
}
|
|
|
|
} else if (wallet.state == RedWalletState.Expire) {
|
|
|
|
desc = I18n.of(Constants.getCurrentContext()).money_over;
|
|
|
|
} else {
|
|
|
|
print('WWWWW${wallet.state}');
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
desc = '[${I18n.of(Constants.getCurrentContext()).red_money}]';
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ChatType.GroupChatNoticeType:
|
|
|
|
desc = '群聊通知消息';
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
}
|
|
|
|
|
|
|
|
return {
|
|
|
|
'SendTime' :
|
|
|
|
DateUtils().getFormartData(timeSamp: time, format: 'yyyy:MM:dd hh:mm:ss');
|
|
|
|
'Content' : desc,
|
|
|
|
'UserId':from
|
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|