mnemo_cards/mnemo_cards_backend/lib/api/ads/ads_manager.dart
Dmitry 0f49280805
Some checks are pending
Backend CI / test (push) Waiting to run
Backend CI / build (push) Blocked by required conditions
Mobile App CI / test (push) Waiting to run
Mobile App CI / build-android (push) Blocked by required conditions
Mobile App CI / build-ios (push) Blocked by required conditions
Web App CI / test (push) Waiting to run
Web App CI / build (push) Blocked by required conditions
Deploy Mnemo Cards / Deploy Backend (push) Waiting to run
Deploy Mnemo Cards / Deploy Web App (push) Blocked by required conditions
Deploy Mnemo Cards / Final Verification (push) Blocked by required conditions
Deploy Telegram Bot / Deploy Telegram Bot (push) Waiting to run
fixes and format
2025-12-20 21:26:15 +03:00

22 lines
726 B
Dart

import 'package:injectable/injectable.dart';
import 'package:mnemo_cards_common_backend/mnemo_cards_common_backend.dart';
import 'package:crypto/crypto.dart' as crypto;
@lazySingleton
class AdsManager {
final _salt = 'elmhqun0d58iqm265bmqlg4oymqujrub';
AdsManager();
String getAdsKey(List<MnemoCardsProductModel> products, UserModel user) {
final productString =
(products.toList()..sort((p, n) => (p.id ?? '').compareTo(n.id ?? '')))
.map((product) => '${product.type.name}_${product.id}')
.join(',');
final userId = user.id.toString();
final hash = crypto.sha256
.convert('${productString}_${userId}_$_salt'.codeUnits)
.toString();
return hash;
}
}