fix: Compatibility message extension editing content is empty, parsing error issue

This commit is contained in:
SL 2024-09-13 14:51:57 +08:00
parent b5d6723950
commit 5a61be1b94
6 changed files with 77 additions and 11 deletions

View File

@ -104,3 +104,5 @@
* fix: Add connection ack and return nodeId * fix: Add connection ack and return nodeId
### 1.5.2 ### 1.5.2
* fix: Add search channel and message method * fix: Add search channel and message method
### 1.5.3
* fix: Compatibility message extension editing content is empty, parsing error issue

View File

@ -319,9 +319,12 @@ class ChatListDataState extends State<ChatList> {
'清空记录', '清空记录',
style: TextStyle(color: Color.fromARGB(255, 4, 80, 194)), style: TextStyle(color: Color.fromARGB(255, 4, 80, 194)),
), ),
onPressed: () { onPressed: () async {
WKIM.shared.messageManager var v = await WKIM.shared.messageManager
.clearWithChannel(channelID, channelType); .getMaxExtraVersionWithChannel(channelID, channelType);
print(v);
// WKIM.shared.messageManager
// .clearWithChannel(channelID, channelType);
}), }),
], ],
), ),
@ -360,7 +363,23 @@ class ChatListDataState extends State<ChatList> {
), ),
MaterialButton( MaterialButton(
onPressed: () { onPressed: () {
getLast(); WKMsgExtra extra = WKMsgExtra();
extra.messageID = "112";
extra.channelID = channelID;
extra.channelType = channelType;
extra.readed = 1;
extra.extraVersion = 100871;
List<WKMsgExtra> list = [];
list.add(extra);
WKMsgExtra extra1 = WKMsgExtra();
extra1.messageID = "1122";
extra1.channelID = channelID;
extra1.channelType = channelType;
extra1.readed = 1;
extra1.extraVersion = 100872;
list.add(extra1);
WKIM.shared.messageManager.saveRemoteExtraMsg(list);
// getLast();
}, },
color: Colors.brown, color: Colors.brown,
child: child:

View File

@ -2,6 +2,7 @@ import 'dart:convert';
import 'dart:io'; import 'dart:io';
import 'package:dio/dio.dart'; import 'package:dio/dio.dart';
import 'package:dio/io.dart';
import 'package:example/const.dart'; import 'package:example/const.dart';
import 'package:wukongimfluttersdk/entity/conversation.dart'; import 'package:wukongimfluttersdk/entity/conversation.dart';
import 'package:wukongimfluttersdk/entity/msg.dart'; import 'package:wukongimfluttersdk/entity/msg.dart';
@ -10,7 +11,17 @@ class HttpUtils {
static String apiURL = "https://api.githubim.com"; static String apiURL = "https://api.githubim.com";
static Future<int> login(String uid, String token) async { static Future<int> login(String uid, String token) async {
final httpClient = HttpClient();
httpClient.badCertificateCallback =
(X509Certificate cert, String host, int port) {
//
return true;
};
final dio = Dio(); final dio = Dio();
dio.httpClientAdapter = DefaultHttpClientAdapter()
..onHttpClientCreate = (client) {
return httpClient;
};
final response = await dio.post("$apiURL/user/token", data: { final response = await dio.post("$apiURL/user/token", data: {
'uid': uid, 'uid': uid,
'token': token, 'token': token,
@ -21,7 +32,17 @@ class HttpUtils {
} }
static Future<String> getIP() async { static Future<String> getIP() async {
final httpClient = HttpClient();
httpClient.badCertificateCallback =
(X509Certificate cert, String host, int port) {
//
return true;
};
final dio = Dio(); final dio = Dio();
dio.httpClientAdapter = DefaultHttpClientAdapter()
..onHttpClientCreate = (client) {
return httpClient;
};
String ip = ''; String ip = '';
final response = await dio.get('$apiURL/route'); final response = await dio.get('$apiURL/route');
if (response.statusCode == HttpStatus.ok) { if (response.statusCode == HttpStatus.ok) {
@ -32,7 +53,17 @@ class HttpUtils {
static syncConversation(String lastSsgSeqs, int msgCount, int version, static syncConversation(String lastSsgSeqs, int msgCount, int version,
Function(WKSyncConversation) back) async { Function(WKSyncConversation) back) async {
final httpClient = HttpClient();
httpClient.badCertificateCallback =
(X509Certificate cert, String host, int port) {
//
return true;
};
final dio = Dio(); final dio = Dio();
dio.httpClientAdapter = DefaultHttpClientAdapter()
..onHttpClientCreate = (client) {
return httpClient;
};
final response = await dio.post('$apiURL/conversation/sync', data: { final response = await dio.post('$apiURL/conversation/sync', data: {
"uid": UserInfo.uid, // uid "uid": UserInfo.uid, // uid
"version": version, // (version0) "version": version, // (version0)
@ -84,7 +115,17 @@ class HttpUtils {
int limit, int limit,
int pullMode, int pullMode,
Function(WKSyncChannelMsg) back) async { Function(WKSyncChannelMsg) back) async {
final httpClient = HttpClient();
httpClient.badCertificateCallback =
(X509Certificate cert, String host, int port) {
//
return true;
};
final dio = Dio(); final dio = Dio();
dio.httpClientAdapter = DefaultHttpClientAdapter()
..onHttpClientCreate = (client) {
return httpClient;
};
final response = await dio.post('$apiURL/channel/messagesync', data: { final response = await dio.post('$apiURL/channel/messagesync', data: {
"login_uid": UserInfo.uid, // uid "login_uid": UserInfo.uid, // uid
"channel_id": channelID, // ID "channel_id": channelID, // ID

View File

@ -114,7 +114,7 @@ class ChannelDB {
Future<List<WKChannelSearchResult>> search(String keyword) async { Future<List<WKChannelSearchResult>> search(String keyword) async {
List<WKChannelSearchResult> list = []; List<WKChannelSearchResult> list = [];
var sql = var sql =
"select t.*,cm.member_name,cm.member_remark from (select ${WKDBConst.tableChannel}.*,max( ${WKDBConst.tableChannelMember}.id) mid from ${WKDBConst.tableChannel}, ${WKDBConst.tableChannelMember} where ${WKDBConst.tableChannel}.channel_id=${WKDBConst.tableChannelMember}.channel_id and ${WKDBConst.tableChannel}.channel_type=${WKDBConst.tableChannelMember}.channel_type and (${WKDBConst.tableChannel}.channel_name like ? or ${WKDBConst.tableChannel}.channel_remark like ? or ${WKDBConst.tableChannelMember}.member_name like ? or ${WKDBConst.tableChannelMember}.member_remark like ?) group by ${WKDBConst.tableChannel}.channel_id,${WKDBConst.tableChannel}.channel_type) t,${WKDBConst.tableChannelMember} cm where t.channel_id=cm.channel_id and t.channel_type=cm.channel_type and t.mid=cm.id"; "select t.*,cm.member_name,cm.member_remark from (select ${WKDBConst.tableChannel}.*,max(${WKDBConst.tableChannelMember}.id) mid from ${WKDBConst.tableChannel}, ${WKDBConst.tableChannelMember} where ${WKDBConst.tableChannel}.channel_id=${WKDBConst.tableChannelMember}.channel_id and ${WKDBConst.tableChannel}.channel_type=${WKDBConst.tableChannelMember}.channel_type and (${WKDBConst.tableChannel}.channel_name like ? or ${WKDBConst.tableChannel}.channel_remark like ? or ${WKDBConst.tableChannelMember}.member_name like ? or ${WKDBConst.tableChannelMember}.member_remark like ?) group by ${WKDBConst.tableChannel}.channel_id,${WKDBConst.tableChannel}.channel_type) t,${WKDBConst.tableChannelMember} cm where t.channel_id=cm.channel_id and t.channel_type=cm.channel_type and t.mid=cm.id";
List<Map<String, Object?>> results = await WKDBHelper.shared List<Map<String, Object?>> results = await WKDBHelper.shared
.getDB()! .getDB()!
.rawQuery( .rawQuery(

View File

@ -51,13 +51,17 @@ class WKDBConst {
msg.localExtraMap = readDynamic(data, 'extra'); msg.localExtraMap = readDynamic(data, 'extra');
if (msg.content != '') { if (msg.content != '') {
dynamic contentJson = jsonDecode(msg.content); dynamic contentJson = jsonDecode(msg.content);
msg.messageContent = WKIM.shared.messageManager if (contentJson != null && contentJson != '') {
.getMessageModel(msg.contentType, contentJson); msg.messageContent = WKIM.shared.messageManager
.getMessageModel(msg.contentType, contentJson);
}
} }
if (msg.wkMsgExtra!.contentEdit != '') { if (msg.wkMsgExtra!.contentEdit != '') {
dynamic json = jsonDecode(msg.wkMsgExtra!.contentEdit); dynamic json = jsonDecode(msg.wkMsgExtra!.contentEdit);
msg.wkMsgExtra!.messageContent = WKIM.shared.messageManager if (json != null && json != '') {
.getMessageModel(WkMessageContentType.text, json); msg.wkMsgExtra!.messageContent = WKIM.shared.messageManager
.getMessageModel(WkMessageContentType.text, json);
}
} }
return msg; return msg;

View File

@ -15,7 +15,7 @@ description: wukong IM flutter sdk
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html # 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 # 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. # of the product and file versions while build-number is used as the build suffix.
version: 1.5.2 version: 1.5.3
homepage: https://github.com/WuKongIM/WuKongIMFlutterSDK homepage: https://github.com/WuKongIM/WuKongIMFlutterSDK
environment: environment: