From 2597dd7a1eba0512624522523de82494e2b995e3 Mon Sep 17 00:00:00 2001 From: manavmodi Date: Mon, 3 Feb 2025 18:03:19 -0500 Subject: [PATCH 1/2] Support has been added --- CHANGELOG.md | 1 + lib/model/social.dart | 8 ++++++-- lib/service/social.dart | 5 +++-- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 67ca23d0c..b61195a1e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Cleaned up social message deep link support [#4572](https://github.com/rokwire/illinois-app/issues/4572). - Use the new groupings for events filtering [#543](https://github.com/rokwire/app-flutter-plugin/issues/543) ### Added +- Add support for draft messages [#547](https://github.com/rokwire/app-flutter-plugin/issues/547) - Add notifications for editing/deleting conversation [#541](https://github.com/rokwire/app-flutter-plugin/issues/541) - Add delete message support to Social BB [#534](https://github.com/rokwire/app-flutter-plugin/issues/534) - Add support for editing messages on the social block [#529](https://github.com/rokwire/app-flutter-plugin/issues/529) diff --git a/lib/model/social.dart b/lib/model/social.dart index 611ec6cb2..3d845554a 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 34b6399be..16fddfeb3 100644 --- a/lib/service/social.dart +++ b/lib/service/social.dart @@ -747,7 +747,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.'); @@ -758,7 +758,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; From 59d11ffd1c899d936e4c8ae4780924b3d5ad17d0 Mon Sep 17 00:00:00 2001 From: manavmodi Date: Thu, 13 Feb 2025 15:33:42 -0500 Subject: [PATCH 2/2] Add draft support --- lib/service/social.dart | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/service/social.dart b/lib/service/social.dart index 19f173241..c77b34b7f 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';