Skip to content

Commit

Permalink
Merge pull request #655 from lamarios/feature/set-app-user-agent
Browse files Browse the repository at this point in the history
change user agent to be Clipious/version
  • Loading branch information
lamarios authored Dec 23, 2024
2 parents 842452f + f64b4c0 commit 2dab36c
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 3 deletions.
3 changes: 3 additions & 0 deletions lib/globals.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import 'package:flutter/animation.dart';
import 'package:clipious/service.dart';
import 'package:clipious/utils/file_db.dart';
import 'package:clipious/utils/interfaces/db.dart';
import 'package:package_info_plus/package_info_plus.dart';

import 'utils/models/country.dart';

Expand All @@ -30,6 +31,8 @@ late IDbClient db;

final FileDB fileDb = FileDB();

PackageInfo? packageInfo;

List<Country> countryCodes = [
Country('AD', 'Andorra'),
Country('AE', 'United Arab Emirates'),
Expand Down
2 changes: 2 additions & 0 deletions lib/http_overrides.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ class MyHttpOverrides extends HttpOverrides {
@override
HttpClient createHttpClient(SecurityContext? context) {
return super.createHttpClient(context)
..userAgent =
'Clipious/${packageInfo?.version ?? '0.0.0'} (${packageInfo?.packageName ?? ''})'
..badCertificateCallback = (X509Certificate cert, String host, int port) {
// if true, it will allow all certs, if false it will throw error on a bad cert
return db.getSettings(skipSslVerificationSettingName)?.value == 'true';
Expand Down
4 changes: 4 additions & 0 deletions lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import 'package:clipious/utils.dart';
import 'package:clipious/utils/sembast_sqflite_database.dart';
import 'package:clipious/workmanager.dart';
import 'package:logging/logging.dart';
import 'package:package_info_plus/package_info_plus.dart';

import 'settings/models/db/app_logs.dart';

Expand Down Expand Up @@ -55,6 +56,9 @@ Future<void> main() async {
HttpOverrides.global = MyHttpOverrides();

WidgetsFlutterBinding.ensureInitialized();

packageInfo = await PackageInfo.fromPlatform();

// FlutterNativeSplash.preserve(widgetsBinding: widgetsBinding);
db = await SembastSqfDb.create();
await fileDb.syncWithDb();
Expand Down
3 changes: 1 addition & 2 deletions lib/settings/states/settings.dart
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,7 @@ class SettingsCubit extends Cubit<SettingsState> {
}

getPackageInfo() async {
PackageInfo packageInfo = await PackageInfo.fromPlatform();
emit(state.copyWith(packageInfo: packageInfo));
emit(state.copyWith(packageInfo: packageInfo!));
}

toggleBlackBackground(bool value) async {
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: clipious
version: 1.22.5+4068
version: 1.22.6+4069
publish_to: none
description: Client for invidious.
environment:
Expand Down

0 comments on commit 2dab36c

Please sign in to comment.