Added user index for statistics
This commit is contained in:
parent
0b48c2e7ab
commit
ef349685ef
@ -0,0 +1,24 @@
|
||||
import 'package:json_annotation/json_annotation.dart';
|
||||
|
||||
part 'updateUserIndexParams.g.dart';
|
||||
|
||||
@JsonSerializable()
|
||||
class UpdateUserIndexParams {
|
||||
String user;
|
||||
String username;
|
||||
String device;
|
||||
int appVersion;
|
||||
String deviceInfo;
|
||||
|
||||
|
||||
UpdateUserIndexParams({
|
||||
required this.user,
|
||||
required this.username,
|
||||
required this.device,
|
||||
required this.appVersion,
|
||||
required this.deviceInfo
|
||||
});
|
||||
|
||||
factory UpdateUserIndexParams.fromJson(Map<String, dynamic> json) => _$UpdateUserIndexParamsFromJson(json);
|
||||
Map<String, dynamic> toJson() => _$UpdateUserIndexParamsToJson(this);
|
||||
}
|
@ -0,0 +1,27 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'updateUserIndexParams.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// JsonSerializableGenerator
|
||||
// **************************************************************************
|
||||
|
||||
UpdateUserIndexParams _$UpdateUserIndexParamsFromJson(
|
||||
Map<String, dynamic> json) =>
|
||||
UpdateUserIndexParams(
|
||||
user: json['user'] as String,
|
||||
username: json['username'] as String,
|
||||
device: json['device'] as String,
|
||||
appVersion: json['appVersion'] as int,
|
||||
deviceInfo: json['deviceInfo'] as String,
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$UpdateUserIndexParamsToJson(
|
||||
UpdateUserIndexParams instance) =>
|
||||
<String, dynamic>{
|
||||
'user': instance.user,
|
||||
'username': instance.username,
|
||||
'device': instance.device,
|
||||
'appVersion': instance.appVersion,
|
||||
'deviceInfo': instance.deviceInfo,
|
||||
};
|
39
lib/api/mhsl/server/userIndex/update/updateUserindex.dart
Normal file
39
lib/api/mhsl/server/userIndex/update/updateUserindex.dart
Normal file
@ -0,0 +1,39 @@
|
||||
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:crypto/crypto.dart';
|
||||
import 'package:device_info_plus/device_info_plus.dart';
|
||||
import 'package:firebase_messaging/firebase_messaging.dart';
|
||||
import 'package:http/http.dart' as http;
|
||||
import 'package:marianum_mobile/api/mhsl/server/userIndex/update/updateUserIndexParams.dart';
|
||||
import 'package:package_info/package_info.dart';
|
||||
|
||||
import '../../../../../model/accountData.dart';
|
||||
import '../../../mhslApi.dart';
|
||||
|
||||
class UpdateUserIndex extends MhslApi<void> {
|
||||
UpdateUserIndexParams params;
|
||||
UpdateUserIndex(this.params) : super("server/userIndex/update");
|
||||
|
||||
@override
|
||||
void assemble(String raw) {}
|
||||
|
||||
@override
|
||||
Future<http.Response> request(Uri uri) {
|
||||
return http.post(uri, body: jsonEncode(params.toJson()));
|
||||
}
|
||||
|
||||
static void index() async {
|
||||
String userId = sha512.convert(utf8.encode("${AccountData().getUsername()}:${AccountData().getPassword()}")).toString();
|
||||
String deviceId = sha512.convert(utf8.encode("$userId@${FirebaseMessaging.instance.getToken()}")).toString();
|
||||
UpdateUserIndex(
|
||||
UpdateUserIndexParams(
|
||||
username: AccountData().getUsername(),
|
||||
user: userId,
|
||||
device: deviceId,
|
||||
appVersion: int.parse((await PackageInfo.fromPlatform()).buildNumber),
|
||||
deviceInfo: jsonEncode((await DeviceInfoPlugin().deviceInfo).data).toString(),
|
||||
),
|
||||
).run();
|
||||
}
|
||||
}
|
@ -8,6 +8,7 @@ import 'package:provider/provider.dart';
|
||||
import 'package:badges/badges.dart' as badges;
|
||||
|
||||
import 'api/mhsl/breaker/getBreakers/getBreakersResponse.dart';
|
||||
import 'api/mhsl/server/userIndex/update/updateUserindex.dart';
|
||||
import 'model/breakers/Breaker.dart';
|
||||
import 'model/breakers/BreakerProps.dart';
|
||||
import 'model/chatList/chatListProps.dart';
|
||||
@ -46,6 +47,10 @@ class _AppState extends State<App> {
|
||||
});
|
||||
});
|
||||
|
||||
// User index
|
||||
UpdateUserIndex.index();
|
||||
|
||||
// User Notifications
|
||||
if(Provider.of<SettingsProvider>(context, listen: false).val().notificationSettings.enabled) {
|
||||
FirebaseMessaging.instance.onTokenRefresh.listen((event) {
|
||||
NotifyUpdater.registerToServer();
|
||||
|
@ -90,6 +90,7 @@ dependencies:
|
||||
share_plus: ^7.1.0
|
||||
flutter_split_view: ^0.1.2
|
||||
bottom_sheet: ^4.0.0
|
||||
device_info_plus: ^9.0.3
|
||||
|
||||
dev_dependencies:
|
||||
flutter_test:
|
||||
|
Loading…
x
Reference in New Issue
Block a user