feat: Enhanced configuration
This commit is contained in:
parent
11c2a8bb26
commit
8eb2e2fb9d
22 changed files with 191 additions and 236 deletions
|
|
@ -1,6 +1,7 @@
|
|||
import 'dart:convert';
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:fluffychat/app_config.dart';
|
||||
import 'package:fluffychat/utils/platform_infos.dart';
|
||||
import 'package:flushbar/flushbar_helper.dart';
|
||||
import 'package:famedlysdk/famedlysdk.dart';
|
||||
|
|
@ -25,12 +26,6 @@ abstract class FirebaseController {
|
|||
static final FlutterLocalNotificationsPlugin
|
||||
_flutterLocalNotificationsPlugin = FlutterLocalNotificationsPlugin();
|
||||
static BuildContext context;
|
||||
static const String CHANNEL_ID = 'fluffychat_push';
|
||||
static const String CHANNEL_NAME = 'FluffyChat push channel';
|
||||
static const String CHANNEL_DESCRIPTION = 'Push notifications for FluffyChat';
|
||||
static const String APP_ID = 'chat.fluffy.fluffychat';
|
||||
static const String GATEWAY_URL = 'https://janian.de:7023/';
|
||||
static const String PUSHER_FORMAT = 'event_id_only';
|
||||
|
||||
static Future<void> setupFirebase(
|
||||
MatrixState matrix, String clientName) async {
|
||||
|
|
@ -65,12 +60,14 @@ abstract class FirebaseController {
|
|||
final currentPushers = pushers.where((pusher) => pusher.pushkey == token);
|
||||
if (currentPushers.length == 1 &&
|
||||
currentPushers.first.kind == 'http' &&
|
||||
currentPushers.first.appId == APP_ID &&
|
||||
currentPushers.first.appId == AppConfig.pushNotificationsAppId &&
|
||||
currentPushers.first.appDisplayName == clientName &&
|
||||
currentPushers.first.deviceDisplayName == client.deviceName &&
|
||||
currentPushers.first.lang == 'en' &&
|
||||
currentPushers.first.data.url.toString() == GATEWAY_URL &&
|
||||
currentPushers.first.data.format == PUSHER_FORMAT) {
|
||||
currentPushers.first.data.url.toString() ==
|
||||
AppConfig.pushNotificationsGatewayUrl &&
|
||||
currentPushers.first.data.format ==
|
||||
AppConfig.pushNotificationsPusherFormat) {
|
||||
debugPrint('[Push] Pusher already set');
|
||||
} else {
|
||||
if (currentPushers.isNotEmpty) {
|
||||
|
|
@ -88,13 +85,13 @@ abstract class FirebaseController {
|
|||
.setPusher(
|
||||
Pusher(
|
||||
token,
|
||||
APP_ID,
|
||||
AppConfig.pushNotificationsAppId,
|
||||
clientName,
|
||||
client.deviceName,
|
||||
'en',
|
||||
PusherData(
|
||||
url: Uri.parse(GATEWAY_URL),
|
||||
format: PUSHER_FORMAT,
|
||||
url: Uri.parse(AppConfig.pushNotificationsGatewayUrl),
|
||||
format: AppConfig.pushNotificationsPusherFormat,
|
||||
),
|
||||
kind: 'http',
|
||||
),
|
||||
|
|
@ -255,7 +252,9 @@ abstract class FirebaseController {
|
|||
|
||||
// Show notification
|
||||
var androidPlatformChannelSpecifics = AndroidNotificationDetails(
|
||||
CHANNEL_ID, CHANNEL_NAME, CHANNEL_DESCRIPTION,
|
||||
AppConfig.pushNotificationsChannelId,
|
||||
AppConfig.pushNotificationsChannelName,
|
||||
AppConfig.pushNotificationsChannelDescription,
|
||||
styleInformation: MessagingStyleInformation(
|
||||
person,
|
||||
conversationTitle: title,
|
||||
|
|
@ -328,8 +327,11 @@ abstract class FirebaseController {
|
|||
|
||||
// Display notification
|
||||
var androidPlatformChannelSpecifics = AndroidNotificationDetails(
|
||||
CHANNEL_ID, CHANNEL_NAME, CHANNEL_DESCRIPTION,
|
||||
importance: Importance.max, priority: Priority.high);
|
||||
AppConfig.pushNotificationsChannelId,
|
||||
AppConfig.pushNotificationsChannelName,
|
||||
AppConfig.pushNotificationsChannelDescription,
|
||||
importance: Importance.max,
|
||||
priority: Priority.high);
|
||||
var iOSPlatformChannelSpecifics = IOSNotificationDetails();
|
||||
var platformChannelSpecifics = NotificationDetails(
|
||||
android: androidPlatformChannelSpecifics,
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import 'package:adaptive_dialog/adaptive_dialog.dart';
|
||||
import 'package:flushbar/flushbar_helper.dart';
|
||||
import 'package:fluffychat/config/app_config.dart';
|
||||
import 'package:fluffychat/app_config.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter_gen/gen_l10n/l10n.dart';
|
||||
|
|
@ -11,6 +11,7 @@ import '../config/setting_keys.dart';
|
|||
|
||||
abstract class SentryController {
|
||||
static Future<void> toggleSentryAction(BuildContext context) async {
|
||||
if (!AppConfig.enableSentry) return;
|
||||
final enableSentry = await showOkCancelAlertDialog(
|
||||
context: context,
|
||||
title: L10n.of(context).sendBugReports,
|
||||
|
|
@ -28,11 +29,12 @@ abstract class SentryController {
|
|||
}
|
||||
|
||||
static Future<bool> getSentryStatus() async {
|
||||
if (!AppConfig.enableSentry) return false;
|
||||
final storage = Store();
|
||||
return await storage.getItemBool(SettingKeys.sentry);
|
||||
}
|
||||
|
||||
static final sentry = SentryClient(dsn: AppConfig.sentryDsn);
|
||||
static final sentry = SentryClient(dsn: AppConfig.sentryDns);
|
||||
|
||||
static void captureException(error, stackTrace) async {
|
||||
debugPrint(error.toString());
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ import 'package:adaptive_dialog/adaptive_dialog.dart';
|
|||
import 'package:famedlysdk/famedlysdk.dart';
|
||||
import 'package:fluffychat/components/dialogs/simple_dialogs.dart';
|
||||
import 'package:fluffychat/components/matrix.dart';
|
||||
import 'package:fluffychat/config/app_config.dart';
|
||||
import 'package:fluffychat/app_config.dart';
|
||||
import 'package:fluffychat/utils/app_route.dart';
|
||||
import 'package:fluffychat/views/chat.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
|
@ -15,7 +15,7 @@ class UrlLauncher {
|
|||
const UrlLauncher(this.context, this.url);
|
||||
|
||||
void launchUrl() {
|
||||
if (url.startsWith(AppConfig.matrixToLinkPrefix) ||
|
||||
if (url.startsWith(AppConfig.inviteLinkPrefix) ||
|
||||
{'#', '@', '!', '+', '\$'}.contains(url[0])) {
|
||||
return openMatrixToUrl();
|
||||
}
|
||||
|
|
@ -24,7 +24,7 @@ class UrlLauncher {
|
|||
|
||||
void openMatrixToUrl() async {
|
||||
final matrix = Matrix.of(context);
|
||||
final identifier = url.replaceAll(AppConfig.matrixToLinkPrefix, '');
|
||||
final identifier = url.replaceAll(AppConfig.inviteLinkPrefix, '');
|
||||
if (identifier[0] == '#' || identifier[0] == '!') {
|
||||
// sometimes we have identifiers which have an event id and additional query parameters
|
||||
// we want to separate those.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue