Skip to content

Commit

Permalink
feat: add option to force unauthenticated media endpoints
Browse files Browse the repository at this point in the history
  • Loading branch information
td-famedly committed Sep 4, 2024
1 parent 804832e commit f27eef3
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions lib/src/client.dart
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,8 @@ class Client extends MatrixApi {
Future<MatrixImageFileResizedResponse?> Function(
MatrixImageFileResizeArguments)? customImageResizer;

final bool forceUnAuthMedia;

/// Create a client
/// [clientName] = unique identifier of this client
/// [databaseBuilder]: A function that creates the database instance, that will be used.
Expand Down Expand Up @@ -184,6 +186,7 @@ class Client extends MatrixApi {
/// Set [customImageResizer] to your own implementation for a more advanced
/// and faster image resizing experience.
/// Set [enableDehydratedDevices] to enable experimental support for enabling MSC3814 dehydrated devices.
/// Set [forceUnAuthMedia] to force unauthenticated media endpoints even if support is detected.
Client(
this.clientName, {
this.databaseBuilder,
Expand Down Expand Up @@ -229,6 +232,7 @@ class Client extends MatrixApi {
/// support.
this.customRefreshTokenLifetime,
this.typingIndicatorTimeout = const Duration(seconds: 30),
this.forceUnAuthMedia = false,
}) : syncFilter = syncFilter ??
Filter(
room: RoomFilter(
Expand Down Expand Up @@ -1203,6 +1207,7 @@ class Client extends MatrixApi {
AsyncCache<GetVersionsResponse>(const Duration(hours: 1));

Future<bool> authenticatedMediaSupported() async {
if (forceUnAuthMedia) return false;
final versionsResponse = await _versionsCache.fetch(() => getVersions());
return versionsResponse.versions.any(
(v) => isVersionGreaterThanOrEqualTo(v, 'v1.11'),
Expand Down

0 comments on commit f27eef3

Please sign in to comment.