Files
tatuchat/lib/utils/file_description.dart
Welton Moura 0037b0b9cf
Some checks failed
Main Deploy Workflow / deploy_web (push) Has been cancelled
Main Deploy Workflow / deploy_playstore_internal (push) Has been cancelled
Close stale issues and PRs / stale (push) Has been cancelled
Initial commit
2026-09-11 15:59:56 -03:00

30 lines
791 B
Dart

// SPDX-FileCopyrightText: 2019-Present Christian Kußowski
// SPDX-FileCopyrightText: 2019-Present Contributors to FluffyChat
//
// SPDX-License-Identifier: AGPL-3.0-or-later
import 'package:matrix/matrix.dart';
extension FileDescriptionExtension on Event {
String? get fileDescription {
if (!{
MessageTypes.File,
MessageTypes.Image,
MessageTypes.Sticker,
MessageTypes.Video,
MessageTypes.Audio,
}.contains(messageType)) {
return null;
}
final filename = content.tryGet<String>('filename');
final body = calcUnlocalizedBody(hideReply: true, plaintextBody: true);
if (filename != body &&
filename != null &&
content.tryGet<String>('body')?.isNotEmpty == true) {
return body;
}
return null;
}
}