Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

change user agent to be Clipious/version #655

Merged
merged 3 commits into from
Dec 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading