diff --git a/lib/model/social.dart b/lib/model/social.dart index 578072d5..19687fc2 100644 --- a/lib/model/social.dart +++ b/lib/model/social.dart @@ -892,16 +892,17 @@ class Message { final String? message; final bool? read; + final bool? draft; final DateTime? dateSentUtc; final DateTime? dateUpdatedUtc; - Message({this.id, this.globalId, this.conversationId, this.sender, this.recipient, this.message, this.read, this.dateSentUtc, this.dateUpdatedUtc}); + Message({this.id, this.globalId, this.conversationId, this.sender, this.recipient, this.message, this.read, this.draft, this.dateSentUtc, this.dateUpdatedUtc}); factory Message.fromOther(Message? other, { String? id, String? globalId, String? conversationId, ConversationMember? sender, ConversationMember? recipient, - String? message, bool? read, + String? message, bool? read, bool? draft, DateTime? dateSentUtc, DateTime? dateUpdatedUtc }) => Message( @@ -912,6 +913,7 @@ class Message { recipient: recipient ?? other?.recipient, message: message ?? other?.message, read: read ?? other?.read, + draft: draft ?? other?.draft, dateSentUtc: dateSentUtc ?? other?.dateSentUtc, dateUpdatedUtc: dateUpdatedUtc ?? other?.dateUpdatedUtc, ); @@ -924,6 +926,7 @@ class Message { recipient: ConversationMember.fromJson(json['recipient']), message: JsonUtils.stringValue(json['message']), read: JsonUtils.boolValue(json['read']), + draft: JsonUtils.boolValue(json['draft']), dateSentUtc: DateTimeUtils.dateTimeFromString(JsonUtils.stringValue(json['date_sent']), isUtc: true), dateUpdatedUtc: DateTimeUtils.dateTimeFromString(JsonUtils.stringValue(json['date_updated']), isUtc: true), ) : null; @@ -937,6 +940,7 @@ class Message { 'recipient': recipient?.toJson(), 'message': message, 'read': read, + 'draft': draft, 'date_sent': DateTimeUtils.utcDateTimeToString(dateSentUtc), 'date_updated': DateTimeUtils.utcDateTimeToString(dateUpdatedUtc), }; diff --git a/lib/service/social.dart b/lib/service/social.dart index 762a7812..c77b34b7 100644 --- a/lib/service/social.dart +++ b/lib/service/social.dart @@ -678,7 +678,7 @@ class Social extends Service implements NotificationsListener { } } - Future updateConversationMessage({required String conversationId, required String globalMessageId, required String newText,}) async { + Future updateConversationMessage({required String conversationId, required String globalMessageId, required String newText, bool draft = false}) async { String? socialUrl = Config().socialUrl; if (StringUtils.isEmpty(socialUrl)) { Log.e('Failed to update conversation message. Reason: missing social url.'); @@ -693,7 +693,7 @@ class Social extends Service implements NotificationsListener { return false; } - String? requestBody = JsonUtils.encode({'message': newText}); + String? requestBody = JsonUtils.encode({'message': newText, 'draft': draft}); String url = '$socialUrl/conversations/$conversationId/messages/$globalMessageId/update'; @@ -748,7 +748,7 @@ class Social extends Service implements NotificationsListener { - Future?> createConversationMessage({required String conversationId, required String message}) async { + Future?> createConversationMessage({required String conversationId, required String message, bool draft = false}) async { String? socialUrl = Config().socialUrl; if (StringUtils.isEmpty(socialUrl)) { Log.e('Failed to create message for conversation $conversationId. Reason: missing social url.'); @@ -759,7 +759,8 @@ class Social extends Service implements NotificationsListener { return null; } String? requestBody = JsonUtils.encode({ - 'message': message + 'message': message, + 'draft': draft }); Response? response = await Network().post('$socialUrl/conversations/$conversationId/messages/send', auth: Auth2(), body: requestBody); int? responseCode = response?.statusCode;