fix(llc): fixed expired cdn attachment links
This commit is contained in:
@@ -3,6 +3,7 @@
|
|||||||
🐞 Fixed
|
🐞 Fixed
|
||||||
|
|
||||||
- [[#710]](https://github.com/GetStream/stream-chat-flutter/issues/710) Fixed JWT requiring using `String` as id.
|
- [[#710]](https://github.com/GetStream/stream-chat-flutter/issues/710) Fixed JWT requiring using `String` as id.
|
||||||
|
- Fixed expired CDN attachment links not updating correctly.
|
||||||
|
|
||||||
## 3.0.0
|
## 3.0.0
|
||||||
|
|
||||||
|
|||||||
@@ -1521,7 +1521,7 @@ class ChannelClientState {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void _checkExpiredAttachmentMessages(ChannelState channelState) {
|
void _checkExpiredAttachmentMessages(ChannelState channelState) async {
|
||||||
final expiredAttachmentMessagesId = channelState.messages
|
final expiredAttachmentMessagesId = channelState.messages
|
||||||
.where((m) =>
|
.where((m) =>
|
||||||
!_updatedMessagesIds.contains(m.id) &&
|
!_updatedMessagesIds.contains(m.id) &&
|
||||||
@@ -1532,20 +1532,24 @@ class ChannelClientState {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
final uri = Uri.parse(url);
|
final uri = Uri.parse(url);
|
||||||
if (uri.host != 'stream-io-cdn.com' ||
|
if (!uri.host.endsWith('stream-io-cdn.com') ||
|
||||||
uri.queryParameters['Expires'] == null) {
|
uri.queryParameters['Expires'] == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
final expiration =
|
final secondsFromEpoch =
|
||||||
DateTime.parse(uri.queryParameters['Expires']!);
|
int.parse(uri.queryParameters['Expires']!);
|
||||||
|
final expiration = DateTime.fromMillisecondsSinceEpoch(
|
||||||
|
secondsFromEpoch * 1000);
|
||||||
return expiration.isBefore(DateTime.now());
|
return expiration.isBefore(DateTime.now());
|
||||||
}) ==
|
}) ==
|
||||||
true)
|
true)
|
||||||
.map((e) => e.id)
|
.map((e) => e.id)
|
||||||
.toList();
|
.toList();
|
||||||
|
|
||||||
if (expiredAttachmentMessagesId.isNotEmpty == true) {
|
if (expiredAttachmentMessagesId.isNotEmpty == true) {
|
||||||
_channel.getMessagesById(expiredAttachmentMessagesId);
|
await _channel._initializedCompleter.future;
|
||||||
_updatedMessagesIds.addAll(expiredAttachmentMessagesId);
|
_updatedMessagesIds.addAll(expiredAttachmentMessagesId);
|
||||||
|
_channel.getMessagesById(expiredAttachmentMessagesId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user