update sync msg name

This commit is contained in:
SL 2023-08-19 16:14:10 +08:00
parent ce91626554
commit 28c84355dd
15 changed files with 110 additions and 97 deletions

2
CHANGELOG.md Normal file
View File

@ -0,0 +1,2 @@
### 1.0.0
* first commint

14
LICENSE Normal file
View File

@ -0,0 +1,14 @@
wukongimfluttersdk
Copyright <2023> <WuKongIM>
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
THS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.I

View File

@ -47,12 +47,12 @@ class HttpUtils {
for (int i = 0; i < list.length; i++) {
var json = list[i];
WKSyncConvMsg convMsg = WKSyncConvMsg();
convMsg.channel_id = json['channel_id'];
convMsg.channel_type = json['channel_type'];
convMsg.channelID = json['channel_id'];
convMsg.channelType = json['channel_type'];
convMsg.unread = json['unread'];
convMsg.timestamp = json['timestamp'];
convMsg.last_msg_seq = json['last_msg_seq'];
convMsg.last_client_msg_no = json['last_client_msg_no'];
convMsg.lastMsgSeq = json['last_msg_seq'];
convMsg.lastClientMsgNO = json['last_client_msg_no'];
convMsg.version = json['version'];
var msgListJson = json['recents'] as List<dynamic>;
List<WKSyncMsg> msgList = [];
@ -92,8 +92,8 @@ class HttpUtils {
if (response.statusCode == HttpStatus.ok) {
var data = response.data;
WKSyncChannelMsg msg = WKSyncChannelMsg();
msg.start_message_seq = data['start_message_seq'];
msg.end_message_seq = data['end_message_seq'];
msg.startMessageSeq = data['start_message_seq'];
msg.endMessageSeq = data['end_message_seq'];
msg.more = data['more'];
var messages = data['messages'] as List<dynamic>;
List<WKSyncMsg> msgList = [];
@ -108,20 +108,18 @@ class HttpUtils {
static WKSyncMsg getWKSyncMsg(dynamic json) {
WKSyncMsg msg = WKSyncMsg();
msg.channel_id = json['channel_id'];
msg.message_id = json['message_id'].toString();
msg.channel_type = json['channel_type'];
msg.client_msg_no = json['client_msg_no'];
msg.message_seq = json['message_seq'];
msg.from_uid = json['from_uid'];
msg.channelID = json['channel_id'];
msg.messageID = json['message_id'].toString();
msg.channelType = json['channel_type'];
msg.clientMsgNO = json['client_msg_no'];
msg.messageSeq = json['message_seq'];
msg.fromUID = json['from_uid'];
msg.timestamp = json['timestamp'];
msg.channel_id = json['channel_id'];
msg.channelID = json['channel_id'];
// msg.payload = json['payload'];
String payload = json['payload'];
// print('消息发送着:${msg.from_uid},${msg.channel_id}');
try {
print(
'消息内容:${msg.from_uid},${msg.channel_id}${utf8.decode(base64Decode(payload))}');
msg.payload = jsonDecode(utf8.decode(base64Decode(payload)));
// print('查询的消息${msg.payload}');
} catch (e) {

View File

@ -499,7 +499,7 @@ packages:
path: ".."
relative: true
source: path
version: "1.0.0+1"
version: "1.0.0"
x25519:
dependency: transitive
description:

View File

@ -59,8 +59,6 @@ class ConversationDB {
}
if (row > 0) {
return getUIMsg(conversationMsg);
} else {
print('新消息的修改失败');
}
return null;
}

View File

@ -1,7 +1,7 @@
import 'package:shared_preferences/shared_preferences.dart';
import 'package:sqflite/sqflite.dart';
import 'package:flutter/services.dart';
import 'package:path/path.dart';
import 'package:path/path.dart' as p;
import '../wkim.dart';
@ -13,7 +13,7 @@ class WKDBHelper {
Database? _database;
Future<bool> init() async {
var databasesPath = await getDatabasesPath();
String path = join(databasesPath, 'wk_${WKIM.shared.options.uid}.db');
String path = p.join(databasesPath, 'wk_${WKIM.shared.options.uid}.db');
_database = await openDatabase(
path,
version: dbVersion,

View File

@ -104,18 +104,18 @@ class WKUIConversationMsg {
}
class WKSyncConversation {
int cmd_version = 0;
int cmdVersion = 0;
List<WkSyncCMD>? cmds;
String uid = '';
List<WKSyncConvMsg>? conversations;
}
class WKSyncConvMsg {
String channel_id = '';
int channel_type = 0;
String last_client_msg_no = '';
int last_msg_seq = 0;
int offset_msg_seq = 0;
String channelID = '';
int channelType = 0;
String lastClientMsgNO = '';
int lastMsgSeq = 0;
int offsetMsgSeq = 0;
int timestamp = 0;
int unread = 0;
int version = 0;

View File

@ -104,49 +104,49 @@ class WKMsgReaction {
}
class WKSyncMsg {
String message_id = '';
int message_seq = 0;
String client_msg_no = '';
String from_uid = '';
String channel_id = '';
int channel_type = 0;
String messageID = '';
int messageSeq = 0;
String clientMsgNO = '';
String fromUID = '';
String channelID = '';
int channelType = 0;
int timestamp = 0;
int voice_status = 0;
int is_deleted = 0;
int voiceStatus = 0;
int isDeleted = 0;
int revoke = 0;
String revoker = '';
int extra_version = 0;
int unread_count = 0;
int readed_count = 0;
int extraVersion = 0;
int unreadCount = 0;
int readedCount = 0;
int readed = 0;
int receipt = 0;
int setting = 0;
dynamic payload;
List<WKSyncMsgReaction>? reactions;
WKSyncExtraMsg? message_extra;
WKSyncExtraMsg? messageExtra;
WKMsg getWKMsg() {
WKMsg msg = WKMsg();
msg.channelID = channel_id;
msg.channelType = channel_type;
msg.messageID = message_id;
msg.messageSeq = message_seq;
msg.clientMsgNO = client_msg_no;
msg.fromUID = from_uid;
msg.channelID = channelID;
msg.channelType = channelType;
msg.messageID = messageID;
msg.messageSeq = messageSeq;
msg.clientMsgNO = clientMsgNO;
msg.fromUID = fromUID;
msg.timestamp = timestamp;
msg.orderSeq = msg.messageSeq * WKIM.shared.messageManager.wkOrderSeqFactor;
msg.voiceStatus = voice_status;
msg.isDeleted = is_deleted;
msg.voiceStatus = voiceStatus;
msg.isDeleted = isDeleted;
msg.status = WKSendMsgResult.sendSuccess;
msg.wkMsgExtra = WKMsgExtra();
msg.wkMsgExtra!.revoke = revoke;
msg.wkMsgExtra!.revoker = revoker;
msg.wkMsgExtra!.unreadCount = unread_count;
msg.wkMsgExtra!.readedCount = readed_count;
msg.wkMsgExtra!.unreadCount = unreadCount;
msg.wkMsgExtra!.readedCount = readedCount;
msg.wkMsgExtra!.readed = readed;
// msg.reactionList = reactions;
// msg.receipt = receipt;
msg.wkMsgExtra!.extraVersion = extra_version;
msg.wkMsgExtra!.extraVersion = extraVersion;
//
msg.setting = msg.setting.decode(setting);
//channelId改成发送者ID
@ -177,15 +177,15 @@ class WKSyncMsg {
List<WKMsgReaction> list = [];
for (int i = 0, size = msgReaction.length; i < size; i++) {
WKMsgReaction reaction = WKMsgReaction();
reaction.channelID = msgReaction[i].channel_id;
reaction.channelType = msgReaction[i].channel_type;
reaction.channelID = msgReaction[i].channelID;
reaction.channelType = msgReaction[i].channelType;
reaction.uid = msgReaction[i].uid;
reaction.name = msgReaction[i].name;
reaction.emoji = msgReaction[i].emoji;
reaction.seq = msgReaction[i].seq;
reaction.isDeleted = msgReaction[i].is_deleted;
reaction.messageID = msgReaction[i].message_id;
reaction.createdAt = msgReaction[i].created_at;
reaction.isDeleted = msgReaction[i].isDeleted;
reaction.messageID = msgReaction[i].messageID;
reaction.createdAt = msgReaction[i].createdAt;
list.add(reaction);
}
return list;
@ -193,35 +193,35 @@ class WKSyncMsg {
}
class WKSyncMsgReaction {
String message_id = '';
String messageID = '';
String uid = '';
String name = '';
String channel_id = '';
int channel_type = 0;
String channelID = '';
int channelType = 0;
int seq = 0;
String emoji = '';
int is_deleted = 0;
String created_at = '';
int isDeleted = 0;
String createdAt = '';
}
class WKSyncExtraMsg {
int message_id = 0;
String message_id_str = '';
int messageID = 0;
String messageIdStr = '';
int revoke = 0;
String revoker = '';
int voice_status = 0;
int is_mutual_deleted = 0;
int extra_version = 0;
int unread_count = 0;
int readed_count = 0;
int voiceStatus = 0;
int isMutualDeleted = 0;
int extraVersion = 0;
int unreadCount = 0;
int readedCount = 0;
int readed = 0;
dynamic content_edit;
int edited_at = 0;
dynamic contentEdit;
int editedAt = 0;
}
class WKSyncChannelMsg {
int start_message_seq = 0;
int end_message_seq = 0;
int startMessageSeq = 0;
int endMessageSeq = 0;
int more = 0;
List<WKSyncMsg>? messages = [];
}

View File

@ -28,7 +28,7 @@ class _WKSocket {
_socket.add(data);
_socket.flush();
} catch (e) {
Logs.error('发送消息错误${e}');
Logs.debug('发送消息错误');
}
}
@ -383,10 +383,10 @@ class WKConnectionManager {
msg.orderSeq = await WKIM.shared.messageManager
.getMessageOrderSeq(msg.messageSeq, msg.channelID, msg.channelType);
dynamic contentJson = jsonDecode(msg.content);
msg.contentType = contentJson['type'];
msg.isDeleted = _isDeletedMsg(contentJson);
msg.messageContent = WKIM.shared.messageManager
.getMessageModel(msg.contentType, contentJson);
msg.contentType = msg.messageContent!.contentType;
WKIM.shared.messageManager.parsingMsg(msg);
WKIM.shared.messageManager.saveMsg(msg);
if (msg.isDeleted == 0 &&

View File

@ -122,18 +122,18 @@ class WKConversationManager {
if (syncChat.conversations != null && syncChat.conversations!.isNotEmpty) {
for (int i = 0, size = syncChat.conversations!.length; i < size; i++) {
WKConversationMsg conversationMsg = WKConversationMsg();
int channelType = syncChat.conversations![i].channel_type;
String channelID = syncChat.conversations![i].channel_id;
int channelType = syncChat.conversations![i].channelType;
String channelID = syncChat.conversations![i].channelID;
if (channelType == WKChannelType.communityTopic) {
var str = channelID.split("@");
conversationMsg.parentChannelID = str[0];
conversationMsg.parentChannelType = WKChannelType.community;
}
conversationMsg.channelID = syncChat.conversations![i].channel_id;
conversationMsg.channelType = syncChat.conversations![i].channel_type;
conversationMsg.lastMsgSeq = syncChat.conversations![i].last_msg_seq;
conversationMsg.channelID = syncChat.conversations![i].channelID;
conversationMsg.channelType = syncChat.conversations![i].channelType;
conversationMsg.lastMsgSeq = syncChat.conversations![i].lastMsgSeq;
conversationMsg.lastClientMsgNO =
syncChat.conversations![i].last_client_msg_no;
syncChat.conversations![i].lastClientMsgNO;
conversationMsg.lastMsgTimestamp = syncChat.conversations![i].timestamp;
conversationMsg.unreadCount = syncChat.conversations![i].unread;
conversationMsg.version = syncChat.conversations![i].version;
@ -149,10 +149,10 @@ class WKConversationManager {
if (conversationMsg.lastClientMsgNO == msg.clientMsgNO) {
conversationMsg.isDeleted = msg.isDeleted;
}
if (wkSyncRecent.message_extra != null) {
if (wkSyncRecent.messageExtra != null) {
WKMsgExtra extra = WKIM.shared.messageManager
.wkSyncExtraMsg2WKMsgExtra(msg.channelID, msg.channelType,
wkSyncRecent.message_extra!);
wkSyncRecent.messageExtra!);
msgExtraList.add(extra);
}
msgList.add(msg);

View File

@ -123,10 +123,10 @@ class WKMessageManager {
for (int j = 0, len = list.length; j < len; j++) {
WKMsg wkMsg = list[j].getWKMsg();
msgList.add(wkMsg);
if (list[j].message_extra != null) {
if (list[j].message_extra != null) {
if (list[j].messageExtra != null) {
if (list[j].messageExtra != null) {
WKMsgExtra extra = wkSyncExtraMsg2WKMsgExtra(
wkMsg.channelID, wkMsg.channelType, list[j].message_extra!);
wkMsg.channelID, wkMsg.channelType, list[j].messageExtra!);
msgExtraList.add(extra);
}
}
@ -144,20 +144,20 @@ class WKMessageManager {
WKMsgExtra extra = WKMsgExtra();
extra.channelID = channelID;
extra.channelType = channelType;
extra.unreadCount = extraMsg.unread_count;
extra.readedCount = extraMsg.readed_count;
extra.unreadCount = extraMsg.unreadCount;
extra.readedCount = extraMsg.readedCount;
extra.readed = extraMsg.readed;
extra.messageID = extraMsg.message_id_str;
extra.isMutualDeleted = extraMsg.is_mutual_deleted;
extra.extraVersion = extraMsg.extra_version;
extra.messageID = extraMsg.messageIdStr;
extra.isMutualDeleted = extraMsg.isMutualDeleted;
extra.extraVersion = extraMsg.extraVersion;
extra.revoke = extraMsg.revoke;
extra.revoker = extraMsg.revoker;
extra.needUpload = 0;
if (extraMsg.content_edit != null) {
extra.contentEdit = jsonEncode(extraMsg.content_edit);
if (extraMsg.contentEdit != null) {
extra.contentEdit = jsonEncode(extraMsg.contentEdit);
}
extra.editedAt = extraMsg.edited_at;
extra.editedAt = extraMsg.editedAt;
return extra;
}

View File

@ -112,7 +112,6 @@ PacketHeader decodeHeader(ReadData reader) {
if (header.packetType != PacketType.ping &&
header.packetType != PacketType.pong) {
header.remainingLength = reader.readVariableLength();
print('科技长度${header.remainingLength}');
}
return header;
}

View File

@ -130,7 +130,7 @@ packages:
source: hosted
version: "5.3.2"
encrypt:
dependency: transitive
dependency: "direct main"
description:
name: encrypt
sha256: "4fd4e4fdc21b9d7d4141823e1e6515cd94e7b8d84749504c232999fba25d9bbb"
@ -265,7 +265,7 @@ packages:
source: hosted
version: "1.9.1"
path:
dependency: transitive
dependency: "direct main"
description:
name: path
sha256: "8829d8a55c13fc0e37127c29fedf290c102f4e40ae94ada574091fe0ff96c917"

View File

@ -1,8 +1,7 @@
name: wukongimfluttersdk
description: A new Flutter project.
description: wukong IM flutter sdk
# The following line prevents the package from being accidentally published to
# pub.dev using `flutter pub publish`. This is preferred for private packages.
publish_to: 'none' # Remove this line if you wish to publish to pub.dev
# The following defines the version and build number for your application.
# A version number is three numbers separated by dots, like 1.2.43
@ -16,7 +15,8 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
# In Windows, build-name is used as the major, minor, and patch parts
# of the product and file versions while build-number is used as the build suffix.
version: 1.0.0+1
version: 1.0.0
homepage: https://github.com/WuKongIM/WuKongIMFlutterSDK
environment:
sdk: '>=3.0.6 <4.0.0'
@ -34,6 +34,8 @@ dependencies:
# The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons.
path: ^1.8.3
encrypt: ^5.0.1
cupertino_icons: ^1.0.2
x25519: ^0.1.1
encryptions: ^1.1.0+1