From 95252be186b383b0cbfad8c059e6dd3bf57793e9 Mon Sep 17 00:00:00 2001 From: Aguilaair Date: Sun, 17 Oct 2021 16:53:01 +0200 Subject: [PATCH] Support attachments on recieved messages --- lib/utils/socket/joinConversation.dart | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/lib/utils/socket/joinConversation.dart b/lib/utils/socket/joinConversation.dart index c404599..6cac98a 100644 --- a/lib/utils/socket/joinConversation.dart +++ b/lib/utils/socket/joinConversation.dart @@ -42,6 +42,23 @@ PhoenixChannel? joinConversationAndListen({ conversationId: event.payload!["conversation_id"], customerId: event.payload!["customer_id"], id: event.payload!["id"], + attachments: (event.payload!["attachments"] != null) + ? (event.payload!["attachments"] as List) + .map((attachment) { + return PapercupsAttachment( + contentType: attachment["content_type"], + fileName: attachment["filename"], + fileUrl: attachment["file_url"], + id: attachment["id"], + ); + }).toList() + : null, + fileIds: (event.payload!["attachments"] != null) + ? (event.payload!["attachments"] as List) + .map((attachment) { + return attachment["id"] as String; + }).toList() + : null, user: (event.payload!["user"] != null) ? User( email: event.payload!["user"]["email"],