aboutsummaryrefslogtreecommitdiff
path: root/lib/firebase
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/firebase
parent786267d0ebb337ad5b4f1e528fdd4c23731e0606 (diff)
downloadlinkchat-f0e45a5a510d2b4693580179645bd0bb0b352f86.tar.gz
linkchat-f0e45a5a510d2b4693580179645bd0bb0b352f86.tar.bz2
linkchat-f0e45a5a510d2b4693580179645bd0bb0b352f86.zip
Soporte y restricción para links
Diffstat (limited to 'lib/firebase')
-rw-r--r--lib/firebase/database.dart6
1 files changed, 4 insertions, 2 deletions
diff --git a/lib/firebase/database.dart b/lib/firebase/database.dart
index eb9ef05..46970ce 100644
--- a/lib/firebase/database.dart
+++ b/lib/firebase/database.dart
@@ -3,6 +3,7 @@ import 'dart:async';
import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:linkchat/models/group.dart';
import 'package:linkchat/models/message.dart';
+import 'package:simple_link_preview/simple_link_preview.dart';
import '../models/user.dart';
@@ -58,13 +59,14 @@ class Database {
}
Future<void> saveMessage(Message msg, String groupId) async {
+ LinkPreview? preview = await SimpleLinkPreview.getPreview(msg.messageText);
await _firestore
.collection('messages')
.doc(groupId)
.collection('messages')
- .add(msg.toMap());
+ .add(msg.toMap(preview: preview));
await _firestore.collection('groups').doc(groupId).update({
- "recentMessage": msg.toMap(),
+ "recentMessage": msg.toMap(preview: preview),
});
}