import 'package:Envelope/database/models/my_profile.dart';
|
|
|
|
import '/database/models/conversations.dart';
|
|
import '/utils/storage/database.dart';
|
|
|
|
class DeviceTokensRepository {
|
|
static Future<List<String>> getDeviceTokensForConversation(Conversation conversation) async {
|
|
final db = await getDatabaseConnection();
|
|
|
|
MyProfile profile = await MyProfile.getProfile();
|
|
|
|
final List<Map<String, dynamic>> maps = await db.rawQuery(
|
|
'''
|
|
SELECT device_tokens.token from device_tokens
|
|
WHERE user_id IN (
|
|
SELECT user_id FROM conversation_users
|
|
WHERE conversation_id = ?
|
|
)
|
|
''',
|
|
[ conversation.id ],
|
|
);
|
|
|
|
return List.generate(maps.length, (i) {
|
|
return maps[i]['token'];
|
|
});
|
|
}
|
|
}
|