chore: Make push gateway configurable
Signed-off-by: Krille <c.kussowski@famedly.com>
This commit is contained in:
parent
03ea244e64
commit
92db578365
3 changed files with 30 additions and 11 deletions
|
|
@ -4,10 +4,13 @@ import 'package:matrix/matrix.dart';
|
||||||
|
|
||||||
abstract class AppConfig {
|
abstract class AppConfig {
|
||||||
static String _applicationName = 'FluffyChat';
|
static String _applicationName = 'FluffyChat';
|
||||||
|
|
||||||
static String get applicationName => _applicationName;
|
static String get applicationName => _applicationName;
|
||||||
static String? _applicationWelcomeMessage;
|
static String? _applicationWelcomeMessage;
|
||||||
|
|
||||||
static String? get applicationWelcomeMessage => _applicationWelcomeMessage;
|
static String? get applicationWelcomeMessage => _applicationWelcomeMessage;
|
||||||
static String _defaultHomeserver = 'matrix.org';
|
static String _defaultHomeserver = 'matrix.org';
|
||||||
|
|
||||||
static String get defaultHomeserver => _defaultHomeserver;
|
static String get defaultHomeserver => _defaultHomeserver;
|
||||||
static double fontSizeFactor = 1;
|
static double fontSizeFactor = 1;
|
||||||
static const Color chatColor = primaryColor;
|
static const Color chatColor = primaryColor;
|
||||||
|
|
@ -20,6 +23,7 @@ abstract class AppConfig {
|
||||||
static const Color secondaryColor = Color(0xFF41a2bc);
|
static const Color secondaryColor = Color(0xFF41a2bc);
|
||||||
static String _privacyUrl =
|
static String _privacyUrl =
|
||||||
'https://github.com/krille-chan/fluffychat/blob/main/PRIVACY.md';
|
'https://github.com/krille-chan/fluffychat/blob/main/PRIVACY.md';
|
||||||
|
|
||||||
static String get privacyUrl => _privacyUrl;
|
static String get privacyUrl => _privacyUrl;
|
||||||
static const String website = 'https://fluffychat.im';
|
static const String website = 'https://fluffychat.im';
|
||||||
static const String enablePushTutorial =
|
static const String enablePushTutorial =
|
||||||
|
|
@ -31,6 +35,7 @@ abstract class AppConfig {
|
||||||
static const String appId = 'im.fluffychat.FluffyChat';
|
static const String appId = 'im.fluffychat.FluffyChat';
|
||||||
static const String appOpenUrlScheme = 'im.fluffychat';
|
static const String appOpenUrlScheme = 'im.fluffychat';
|
||||||
static String _webBaseUrl = 'https://fluffychat.im/web';
|
static String _webBaseUrl = 'https://fluffychat.im/web';
|
||||||
|
|
||||||
static String get webBaseUrl => _webBaseUrl;
|
static String get webBaseUrl => _webBaseUrl;
|
||||||
static const String sourceCodeUrl =
|
static const String sourceCodeUrl =
|
||||||
'https://github.com/krille-chan/fluffychat';
|
'https://github.com/krille-chan/fluffychat';
|
||||||
|
|
@ -62,9 +67,6 @@ abstract class AppConfig {
|
||||||
static const String schemePrefix = 'matrix:';
|
static const String schemePrefix = 'matrix:';
|
||||||
static const String pushNotificationsChannelId = 'fluffychat_push';
|
static const String pushNotificationsChannelId = 'fluffychat_push';
|
||||||
static const String pushNotificationsAppId = 'chat.fluffy.fluffychat';
|
static const String pushNotificationsAppId = 'chat.fluffy.fluffychat';
|
||||||
static const String pushNotificationsGatewayUrl =
|
|
||||||
'https://push.fluffychat.im/_matrix/push/v1/notify';
|
|
||||||
static const String pushNotificationsPusherFormat = 'event_id_only';
|
|
||||||
static const double borderRadius = 18.0;
|
static const double borderRadius = 18.0;
|
||||||
static const double columnWidth = 360.0;
|
static const double columnWidth = 360.0;
|
||||||
static final Uri homeserverList = Uri(
|
static final Uri homeserverList = Uri(
|
||||||
|
|
|
||||||
|
|
@ -45,7 +45,15 @@ enum AppSettings<T> {
|
||||||
audioRecordingEchoCancel<bool>('audioRecordingEchoCancel', false),
|
audioRecordingEchoCancel<bool>('audioRecordingEchoCancel', false),
|
||||||
audioRecordingNoiseSuppress<bool>('audioRecordingNoiseSuppress', true),
|
audioRecordingNoiseSuppress<bool>('audioRecordingNoiseSuppress', true),
|
||||||
audioRecordingBitRate<int>('audioRecordingBitRate', 64000),
|
audioRecordingBitRate<int>('audioRecordingBitRate', 64000),
|
||||||
audioRecordingSamplingRate<int>('audioRecordingSamplingRate', 44100);
|
audioRecordingSamplingRate<int>('audioRecordingSamplingRate', 44100),
|
||||||
|
pushNotificationsGatewayUrl<String>(
|
||||||
|
'pushNotificationsGatewayUrl',
|
||||||
|
'https://push.fluffychat.im/_matrix/push/v1/notify',
|
||||||
|
),
|
||||||
|
pushNotificationsPusherFormat<String>(
|
||||||
|
'pushNotificationsPusherFormat',
|
||||||
|
'event_id_only',
|
||||||
|
);
|
||||||
|
|
||||||
final String key;
|
final String key;
|
||||||
final T defaultValue;
|
final T defaultValue;
|
||||||
|
|
@ -55,6 +63,7 @@ enum AppSettings<T> {
|
||||||
|
|
||||||
extension AppSettingsBoolExtension on AppSettings<bool> {
|
extension AppSettingsBoolExtension on AppSettings<bool> {
|
||||||
bool getItem(SharedPreferences store) => store.getBool(key) ?? defaultValue;
|
bool getItem(SharedPreferences store) => store.getBool(key) ?? defaultValue;
|
||||||
|
|
||||||
Future<void> setItem(SharedPreferences store, bool value) =>
|
Future<void> setItem(SharedPreferences store, bool value) =>
|
||||||
store.setBool(key, value);
|
store.setBool(key, value);
|
||||||
}
|
}
|
||||||
|
|
@ -62,12 +71,14 @@ extension AppSettingsBoolExtension on AppSettings<bool> {
|
||||||
extension AppSettingsStringExtension on AppSettings<String> {
|
extension AppSettingsStringExtension on AppSettings<String> {
|
||||||
String getItem(SharedPreferences store) =>
|
String getItem(SharedPreferences store) =>
|
||||||
store.getString(key) ?? defaultValue;
|
store.getString(key) ?? defaultValue;
|
||||||
|
|
||||||
Future<void> setItem(SharedPreferences store, String value) =>
|
Future<void> setItem(SharedPreferences store, String value) =>
|
||||||
store.setString(key, value);
|
store.setString(key, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
extension AppSettingsIntExtension on AppSettings<int> {
|
extension AppSettingsIntExtension on AppSettings<int> {
|
||||||
int getItem(SharedPreferences store) => store.getInt(key) ?? defaultValue;
|
int getItem(SharedPreferences store) => store.getInt(key) ?? defaultValue;
|
||||||
|
|
||||||
Future<void> setItem(SharedPreferences store, int value) =>
|
Future<void> setItem(SharedPreferences store, int value) =>
|
||||||
store.setInt(key, value);
|
store.setInt(key, value);
|
||||||
}
|
}
|
||||||
|
|
@ -75,6 +86,7 @@ extension AppSettingsIntExtension on AppSettings<int> {
|
||||||
extension AppSettingsDoubleExtension on AppSettings<double> {
|
extension AppSettingsDoubleExtension on AppSettings<double> {
|
||||||
double getItem(SharedPreferences store) =>
|
double getItem(SharedPreferences store) =>
|
||||||
store.getDouble(key) ?? defaultValue;
|
store.getDouble(key) ?? defaultValue;
|
||||||
|
|
||||||
Future<void> setItem(SharedPreferences store, double value) =>
|
Future<void> setItem(SharedPreferences store, double value) =>
|
||||||
store.setDouble(key, value);
|
store.setDouble(key, value);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -21,9 +21,10 @@ import 'dart:async';
|
||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
|
|
||||||
|
import 'package:fluffychat/utils/push_helper.dart';
|
||||||
|
import 'package:fluffychat/widgets/fluffy_chat_app.dart';
|
||||||
import 'package:flutter/foundation.dart';
|
import 'package:flutter/foundation.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
import 'package:flutter_gen/gen_l10n/l10n.dart';
|
import 'package:flutter_gen/gen_l10n/l10n.dart';
|
||||||
import 'package:flutter_local_notifications/flutter_local_notifications.dart';
|
import 'package:flutter_local_notifications/flutter_local_notifications.dart';
|
||||||
import 'package:flutter_new_badger/flutter_new_badger.dart';
|
import 'package:flutter_new_badger/flutter_new_badger.dart';
|
||||||
|
|
@ -32,8 +33,6 @@ import 'package:matrix/matrix.dart';
|
||||||
import 'package:unifiedpush/unifiedpush.dart';
|
import 'package:unifiedpush/unifiedpush.dart';
|
||||||
import 'package:unifiedpush_ui/unifiedpush_ui.dart';
|
import 'package:unifiedpush_ui/unifiedpush_ui.dart';
|
||||||
|
|
||||||
import 'package:fluffychat/utils/push_helper.dart';
|
|
||||||
import 'package:fluffychat/widgets/fluffy_chat_app.dart';
|
|
||||||
import '../config/app_config.dart';
|
import '../config/app_config.dart';
|
||||||
import '../config/setting_keys.dart';
|
import '../config/setting_keys.dart';
|
||||||
import '../widgets/matrix.dart';
|
import '../widgets/matrix.dart';
|
||||||
|
|
@ -186,7 +185,8 @@ class BackgroundPush {
|
||||||
currentPushers.first.lang == 'en' &&
|
currentPushers.first.lang == 'en' &&
|
||||||
currentPushers.first.data.url.toString() == gatewayUrl &&
|
currentPushers.first.data.url.toString() == gatewayUrl &&
|
||||||
currentPushers.first.data.format ==
|
currentPushers.first.data.format ==
|
||||||
AppConfig.pushNotificationsPusherFormat &&
|
AppSettings.pushNotificationsPusherFormat
|
||||||
|
.getItem(matrix!.store) &&
|
||||||
mapEquals(
|
mapEquals(
|
||||||
currentPushers.single.data.additionalProperties,
|
currentPushers.single.data.additionalProperties,
|
||||||
{"data_message": pusherDataMessageFormat},
|
{"data_message": pusherDataMessageFormat},
|
||||||
|
|
@ -226,7 +226,8 @@ class BackgroundPush {
|
||||||
lang: 'en',
|
lang: 'en',
|
||||||
data: PusherData(
|
data: PusherData(
|
||||||
url: Uri.parse(gatewayUrl!),
|
url: Uri.parse(gatewayUrl!),
|
||||||
format: AppConfig.pushNotificationsPusherFormat,
|
format: AppSettings.pushNotificationsPusherFormat
|
||||||
|
.getItem(matrix!.store),
|
||||||
additionalProperties: {"data_message": pusherDataMessageFormat},
|
additionalProperties: {"data_message": pusherDataMessageFormat},
|
||||||
),
|
),
|
||||||
kind: 'http',
|
kind: 'http',
|
||||||
|
|
@ -315,7 +316,8 @@ class BackgroundPush {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
await setupPusher(
|
await setupPusher(
|
||||||
gatewayUrl: AppConfig.pushNotificationsGatewayUrl,
|
gatewayUrl:
|
||||||
|
AppSettings.pushNotificationsGatewayUrl.getItem(matrix!.store),
|
||||||
token: _fcmToken,
|
token: _fcmToken,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
@ -427,7 +429,10 @@ class BackgroundPush {
|
||||||
}
|
}
|
||||||
|
|
||||||
class UPFunctions extends UnifiedPushFunctions {
|
class UPFunctions extends UnifiedPushFunctions {
|
||||||
final List<String> features = [/*list of features*/];
|
final List<String> features = [
|
||||||
|
/*list of features*/
|
||||||
|
];
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<String?> getDistributor() async {
|
Future<String?> getDistributor() async {
|
||||||
return await UnifiedPush.getDistributor();
|
return await UnifiedPush.getDistributor();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue