redesign app phase 2
This commit is contained in:
@@ -57,7 +57,7 @@ class ChopperAggregateLogger implements Logger {
|
||||
}
|
||||
|
||||
void onEndRequest(chopper.Request request) {
|
||||
info(_requests.remove(request)?.toString().trim());
|
||||
info(_censorSensitiveLog(_requests.remove(request)?.toString().trim()));
|
||||
}
|
||||
|
||||
void onStartResponse(chopper.Response response) {
|
||||
@@ -65,7 +65,18 @@ class ChopperAggregateLogger implements Logger {
|
||||
}
|
||||
|
||||
void onEndResponse(chopper.Response response) {
|
||||
info(_responses.remove(response)?.toString().trim());
|
||||
info(_censorSensitiveLog(_responses.remove(response)?.toString().trim()));
|
||||
}
|
||||
|
||||
String? _censorSensitiveLog(String? message) {
|
||||
if (message == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return message
|
||||
.replaceAll(RegExp(r'Token="[^"]*"'), 'Token="TOKEN"')
|
||||
.replaceAll(RegExp(r'"Username":"[^"]*"'), '"Username":"USER"')
|
||||
.replaceAll(RegExp(r'"Pw":"[^"]*"'), '"Pw":"PASSWORD"');
|
||||
}
|
||||
|
||||
@override
|
||||
|
||||
@@ -4,6 +4,7 @@ import 'package:android_id/android_id.dart';
|
||||
import 'package:chopper/chopper.dart';
|
||||
import 'package:device_info_plus/device_info_plus.dart';
|
||||
import 'package:finamp/services/http_aggregate_logging_interceptor.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:get_it/get_it.dart';
|
||||
import 'package:package_info_plus/package_info_plus.dart';
|
||||
|
||||
@@ -422,19 +423,28 @@ Future<String> getAuthHeader() async {
|
||||
}
|
||||
|
||||
authHeader = '${authHeader}Client="Finamp", ';
|
||||
DeviceInfoPlugin deviceInfo = DeviceInfoPlugin();
|
||||
if (Platform.isAndroid) {
|
||||
if (kIsWeb) {
|
||||
authHeader = '${authHeader}Device="Web Browser", ';
|
||||
authHeader = '${authHeader}DeviceId="finamp-web", ';
|
||||
} else if (Platform.isAndroid) {
|
||||
DeviceInfoPlugin deviceInfo = DeviceInfoPlugin();
|
||||
AndroidDeviceInfo androidDeviceInfo = await deviceInfo.androidInfo;
|
||||
authHeader = '${authHeader}Device="${androidDeviceInfo.model}", ';
|
||||
final androidId = await const AndroidId().getId();
|
||||
authHeader = '${authHeader}DeviceId="$androidId", ';
|
||||
} else if (Platform.isIOS) {
|
||||
DeviceInfoPlugin deviceInfo = DeviceInfoPlugin();
|
||||
IosDeviceInfo iosDeviceInfo = await deviceInfo.iosInfo;
|
||||
authHeader = '${authHeader}Device="${iosDeviceInfo.name}", ';
|
||||
authHeader =
|
||||
'${authHeader}DeviceId="${iosDeviceInfo.identifierForVendor}", ';
|
||||
} else {
|
||||
throw "getAuthHeader() only supports Android and iOS";
|
||||
final deviceName = "Finamp ${Platform.operatingSystem}";
|
||||
final deviceId =
|
||||
"finamp-${Platform.operatingSystem}-${Platform.localHostname}";
|
||||
|
||||
authHeader = '${authHeader}Device="$deviceName", ';
|
||||
authHeader = '${authHeader}DeviceId="$deviceId", ';
|
||||
}
|
||||
|
||||
PackageInfo packageInfo = await PackageInfo.fromPlatform();
|
||||
|
||||
@@ -702,21 +702,12 @@ class MusicPlayerBackgroundTask extends BaseAudioHandler {
|
||||
}
|
||||
|
||||
Future<Uri> _songUri(MediaItem mediaItem) async {
|
||||
// We need the platform to be Android or iOS to get device info
|
||||
assert(Platform.isAndroid || Platform.isIOS,
|
||||
"_songUri() only supports Android and iOS");
|
||||
|
||||
// When creating the MediaItem (usually in AudioServiceHelper), we specify
|
||||
// whether or not to transcode. We used to pull from FinampSettings here,
|
||||
// but since audio_service runs in an isolate (or at least, it does until
|
||||
// 0.18), the value would be wrong if changed while a song was playing since
|
||||
// Hive is bad at multi-isolate stuff.
|
||||
|
||||
final androidId =
|
||||
Platform.isAndroid ? await const AndroidId().getId() : null;
|
||||
final iosDeviceInfo =
|
||||
Platform.isIOS ? await DeviceInfoPlugin().iosInfo : null;
|
||||
|
||||
final parsedBaseUrl = Uri.parse(_finampUserHelper.currentUser!.baseUrl);
|
||||
|
||||
List<String> builtPath = List.from(parsedBaseUrl.pathSegments);
|
||||
@@ -795,4 +786,4 @@ String _jellyfinRepeatModeFromRepeatMode(AudioServiceRepeatMode repeatMode) {
|
||||
case AudioServiceRepeatMode.group:
|
||||
return "RepeatAll";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user