Encrypted messaging app
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

27 lines
749 B

  1. import 'package:Envelope/database/models/my_profile.dart';
  2. import '/database/models/conversations.dart';
  3. import '/utils/storage/database.dart';
  4. class DeviceTokensRepository {
  5. static Future<List<String>> getDeviceTokensForConversation(Conversation conversation) async {
  6. final db = await getDatabaseConnection();
  7. MyProfile profile = await MyProfile.getProfile();
  8. final List<Map<String, dynamic>> maps = await db.rawQuery(
  9. '''
  10. SELECT device_tokens.token from device_tokens
  11. WHERE user_id IN (
  12. SELECT user_id FROM conversation_users
  13. WHERE conversation_id = ?
  14. )
  15. ''',
  16. [ conversation.id ],
  17. );
  18. return List.generate(maps.length, (i) {
  19. return maps[i]['token'];
  20. });
  21. }
  22. }