Add custom emoji message

This commit is contained in:
hrxiang
2022-03-10 17:53:01 +08:00
parent 80152e2314
commit 6c0676fbe5
9 changed files with 104 additions and 29 deletions

View File

@@ -7,6 +7,7 @@ class MessageType {
static const file = 105;
static const at_text = 106;
static const merger = 107;
// static const forward = 108;
static const card = 108;
static const location = 109;
@@ -15,6 +16,7 @@ class MessageType {
static const has_read_receipt = 112;
static const typing = 113;
static const quote = 114;
static const custom_face = 115;
///
static const accept_friend = 201;

View File

@@ -444,6 +444,25 @@ class MessageManager {
}))
.then((value) => Utils.toObj(value, (map) => Message.fromJson(map)));
/// Create custom emoji message
/// 创建自定义表情消息
/// [index] The position of the emoji, such as the position emoji表情的位置如位置表情
/// [data] Other data, such as url expressions其他数据如url表情
Future<Message> createFaceMessage({
int index = -1,
String? data,
String? operationID,
}) =>
_channel
.invokeMethod(
'createFaceMessage',
_buildParam({
'index': index,
'data': data,
"operationID": Utils.checkOperationID(operationID),
}))
.then((value) => Utils.toObj(value, (map) => Message.fromJson(map)));
/// Clear all c2c history message
/// 清空单聊消息记录
Future<dynamic> clearC2CHistoryMessage({

View File

@@ -36,6 +36,7 @@ class Message {
QuoteElem? quoteElem;
MergeElem? mergeElem;
NotificationElem? notificationElem;
FaceElem? faceElem;
Message({
this.clientMsgID,
@@ -69,6 +70,7 @@ class Message {
this.quoteElem,
this.mergeElem,
this.notificationElem,
this.faceElem,
});
Message.fromJson(Map<String, dynamic> json) {
@@ -123,6 +125,8 @@ class Message {
notificationElem = json['notificationElem'] != null
? NotificationElem.fromJson(json['notificationElem'])
: null;
faceElem =
json['faceElem'] != null ? FaceElem.fromJson(json['faceElem']) : null;
}
Map<String, dynamic> toJson() {
@@ -158,6 +162,7 @@ class Message {
data['quoteElem'] = this.quoteElem?.toJson();
data['mergeElem'] = this.mergeElem?.toJson();
data['notificationElem'] = this.notificationElem?.toJson();
data['faceElem'] = this.faceElem?.toJson();
return data;
}
@@ -172,8 +177,7 @@ class Message {
int get hashCode => clientMsgID.hashCode;
void update(Message message) {
if (clientMsgID != message.clientMsgID) return;
// clientMsgID = message.clientMsgID;
if (this != message) return;
serverMsgID = message.serverMsgID;
createTime = message.createTime;
sendTime = message.sendTime;
@@ -204,6 +208,7 @@ class Message {
quoteElem = message.quoteElem;
mergeElem = message.mergeElem;
notificationElem = message.notificationElem;
faceElem = message.faceElem;
}
}
@@ -548,6 +553,25 @@ class NotificationElem {
}
}
class FaceElem {
int? index;
String? data;
FaceElem({this.index, this.data});
FaceElem.fromJson(Map<String, dynamic> json) {
index = json['index'];
data = json['data'];
}
Map<String, dynamic> toJson() {
final data = Map<String, dynamic>();
data['index'] = this.index;
data['data'] = this.data;
return data;
}
}
class ReadReceiptInfo {
String? uid;
List<String>? msgIDList;

View File

@@ -16,11 +16,17 @@ class UserInfo {
int? createTime;
String? remark;
/// User's public profile用户公开的资料
PublicUserInfo? publicInfo;
/// Only friends can view information好友才能查看的资料
FriendInfo? friendInfo;
/// blacklist information黑名单资料
BlacklistInfo? blackInfo;
bool? isFriendship;
bool? isBlacklist;
UserInfo({
@@ -76,7 +82,7 @@ class UserInfo {
birth = json['birth'] ?? _birth;
email = json['email'] ?? _email;
remark = json['remark'] ?? _remark;
ex = json['ex'];
ex = json['ex'] ?? _ex;
createTime = json['createTime'];
}
@@ -123,6 +129,10 @@ class UserInfo {
? friendInfo?.gender
: (isBlacklist! ? blackInfo?.gender : publicInfo?.gender);
String? get _ex => isFriendship!
? friendInfo?.ex
: (isBlacklist! ? blackInfo?.ex : publicInfo?.ex);
String? get _phoneNumber => friendInfo?.phoneNumber;
int? get _birth => friendInfo?.birth;
@@ -131,9 +141,9 @@ class UserInfo {
String? get _remark => friendInfo?.remark;
String getShowName() => _trimBlank(remark) ?? _trimBlank(nickname) ?? userID!;
String getShowName() => _isNull(remark) ?? _isNull(nickname) ?? userID!;
static String? _trimBlank(String? value) {
static String? _isNull(String? value) {
if (value == null || value.trim().isEmpty) return null;
return value;
}
@@ -145,6 +155,7 @@ class PublicUserInfo {
String? faceURL;
int? gender;
int? appMangerLevel;
String? ex;
PublicUserInfo({
this.userID,
@@ -152,6 +163,7 @@ class PublicUserInfo {
this.faceURL,
this.gender,
this.appMangerLevel,
this.ex,
});
PublicUserInfo.fromJson(Map<String, dynamic> json) {
@@ -160,6 +172,7 @@ class PublicUserInfo {
faceURL = json['faceURL'];
gender = json['gender'];
appMangerLevel = json['appMangerLevel'];
ex = json['ex'];
}
Map<String, dynamic> toJson() {
@@ -169,6 +182,7 @@ class PublicUserInfo {
data['faceURL'] = this.faceURL;
data['gender'] = this.gender;
data['appMangerLevel'] = this.appMangerLevel;
data['ex'] = this.ex;
return data;
}
}