aboutsummaryrefslogtreecommitdiff
path: root/lib/models/message.dart
diff options
context:
space:
mode:
authorIván Ávalos <avalos@disroot.org>2023-05-22 09:00:45 -0600
committerIván Ávalos <avalos@disroot.org>2023-05-22 09:00:45 -0600
commitf0e45a5a510d2b4693580179645bd0bb0b352f86 (patch)
tree1de8c7235e5dba68898a1ac33f5d420a18ac2fff /lib/models/message.dart
parent786267d0ebb337ad5b4f1e528fdd4c23731e0606 (diff)
downloadlinkchat-f0e45a5a510d2b4693580179645bd0bb0b352f86.tar.gz
linkchat-f0e45a5a510d2b4693580179645bd0bb0b352f86.tar.bz2
linkchat-f0e45a5a510d2b4693580179645bd0bb0b352f86.zip
Soporte y restricción para links
Diffstat (limited to 'lib/models/message.dart')
-rw-r--r--lib/models/message.dart15
1 files changed, 14 insertions, 1 deletions
diff --git a/lib/models/message.dart b/lib/models/message.dart
index ac31c18..4026215 100644
--- a/lib/models/message.dart
+++ b/lib/models/message.dart
@@ -1,19 +1,29 @@
import 'package:cloud_firestore/cloud_firestore.dart';
+import 'package:simple_link_preview/simple_link_preview.dart';
class Message {
final String messageText;
+ final String? linkTitle;
+ final String? linkDescription;
+ final String? linkPhotoURL;
final DateTime sentAt;
final String sentBy;
const Message({
required this.messageText,
+ this.linkTitle,
+ this.linkDescription,
+ this.linkPhotoURL,
required this.sentAt,
required this.sentBy,
});
- Map<String, dynamic> toMap() {
+ Map<String, dynamic> toMap({LinkPreview? preview}) {
return {
"messageText": messageText,
+ "linkTitle": preview?.title,
+ "linkDescription": preview?.description,
+ "linkPhotoURL": preview?.image,
"sentAt": sentAt,
"sentBy": sentBy,
};
@@ -22,6 +32,9 @@ class Message {
factory Message.fromMap(Map<String, dynamic> map) {
return Message(
messageText: map['messageText'],
+ linkTitle: map['linkTitle'],
+ linkDescription: map['linkDescription'],
+ linkPhotoURL: map['linkPhotoURL'],
sentAt: (map['sentAt'] as Timestamp).toDate(),
sentBy: map['sentBy'],
);