From fdde865cfc8064578d76deed1e7333b0d6e1b2c8 Mon Sep 17 00:00:00 2001 From: Tyler Jeong Date: Tue, 12 Mar 2024 15:28:24 +0900 Subject: [PATCH] Add 4.2.5. --- CHANGELOG.md | 5 +++ README.md | 2 +- lib/src/internal/main/chat/chat.dart | 2 +- lib/src/public/core/message/file_message.dart | 34 ++++++++++++++++++- pubspec.yaml | 2 +- 5 files changed, 41 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a382bdc..46b2dd2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,8 @@ +## v4.2.5 (Mar 12, 2024) + +### Improvements +- Added `secureUrl` in `Thumbnail` + ## v4.2.4 (Mar 8, 2024) ### Improvements diff --git a/README.md b/README.md index 0ec1bb8..f1b6c3b 100644 --- a/README.md +++ b/README.md @@ -48,7 +48,7 @@ Before installing Sendbird Chat SDK, you need to create a Sendbird application o ```yaml dependencies: - sendbird_chat_sdk: ^4.2.4 + sendbird_chat_sdk: ^4.2.5 ``` - Run `flutter pub get` command in your project directory. diff --git a/lib/src/internal/main/chat/chat.dart b/lib/src/internal/main/chat/chat.dart index e0085f4..7f0f8b7 100644 --- a/lib/src/internal/main/chat/chat.dart +++ b/lib/src/internal/main/chat/chat.dart @@ -60,7 +60,7 @@ part 'chat_notifications.dart'; part 'chat_push.dart'; part 'chat_user.dart'; -const sdkVersion = '4.2.4'; +const sdkVersion = '4.2.5'; // Internal implementation for main class. Do not directly access this class. class Chat with WidgetsBindingObserver { diff --git a/lib/src/public/core/message/file_message.dart b/lib/src/public/core/message/file_message.dart index 6e6815d..7878c36 100644 --- a/lib/src/public/core/message/file_message.dart +++ b/lib/src/public/core/message/file_message.dart @@ -136,6 +136,15 @@ class FileMessage extends BaseMessage { FileMessage fileMessage = _$FileMessageFromJson(json) ..set(SendbirdChat().chat); // Set the singleton chat + if (fileMessage.thumbnails != null && fileMessage.thumbnails!.isNotEmpty) { + for (final thumbnail in fileMessage.thumbnails!) { + thumbnail.set( + chat: fileMessage.chat, + requireAuth: fileMessage.requireAuth, + ); + } + } + // Scheduled message if (json['scheduled_message_id'] != null) { fileMessage.scheduledInfo = ScheduledInfo.fromJson(json); @@ -212,8 +221,14 @@ class FileMessage extends BaseMessage { /// An object represents thumbnail @JsonSerializable() class Thumbnail { + @JsonKey(includeFromJson: false, includeToJson: false) + Chat? _chat; + + @JsonKey(includeFromJson: false, includeToJson: false) + bool? _requireAuth; + String url; - String? plainUrl; + String? plainUrl; // This property is always null. This will be removed. double? height; double? width; double? realHeight; @@ -228,6 +243,23 @@ class Thumbnail { this.realWidth, ); + void set({required Chat chat, required bool requireAuth}) { + _chat = chat; + _requireAuth = requireAuth; + } + + /// The secure thumbnail URL. + /// @since 4.2.5 + String? get secureUrl { + if (_chat != null && _requireAuth != null) { + final eKey = _chat!.chatContext.eKey; + if (_requireAuth! && eKey != null) { + return '$url?auth=$eKey'; + } + } + return url; + } + factory Thumbnail.fromJson(Map json) => _$ThumbnailFromJson(json); diff --git a/pubspec.yaml b/pubspec.yaml index 8f7d523..c1a33a3 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: sendbird_chat_sdk description: With Sendbird Chat for Flutter, you can easily build an in-app chat with all the essential messaging features. -version: 4.2.4 +version: 4.2.5 homepage: https://sendbird.com repository: https://github.com/sendbird/sendbird-chat-sdk-flutter documentation: https://sendbird.com/docs/chat/sdk/v4/flutter/getting-started/send-first-message