diff --git a/apps/client/integration_test/plugin_integration_test.dart b/apps/client/integration_test/plugin_integration_test.dart index 05b38220..7fb95265 100644 --- a/apps/client/integration_test/plugin_integration_test.dart +++ b/apps/client/integration_test/plugin_integration_test.dart @@ -1,17 +1,17 @@ import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:integration_test/integration_test.dart'; -import 'package:mattermost_push_plugin/mattermost_push_plugin.dart'; +import 'package:nexo_messaging/nexo_messaging.dart'; import 'package:nexo_client/main.dart'; void main() { IntegrationTestWidgetsFlutterBinding.ensureInitialized(); testWidgets('singleton instance is accessible', (WidgetTester tester) async { - expect(MattermostPushPlugin.instance, isNotNull); + expect(NexoMessagingPlugin.instance, isNotNull); expect( - MattermostPushPlugin.notificationChannelName, - 'com.tokilabs.mattermost/notifications', + NexoMessagingPlugin.notificationChannelName, + 'com.tokilabs.nexo.messaging/notifications', ); }); @@ -20,10 +20,10 @@ void main() { ) async { await tester.pumpWidget(const MyApp()); - MattermostPushPlugin.instance.listenNativeChannelForTesting(); - await MattermostPushPlugin.instance.debugSendNativeEventForTesting(const { + NexoMessagingPlugin.instance.listenNativeChannelForTesting(); + await NexoMessagingPlugin.instance.debugSendNativeEventForTesting(const { 'type': PushNotificationType.opened, - 'server_url': 'https://mm.example.com', + 'server_url': 'https://nexo.example.com', 'channel_id': 'channel-integration', }); @@ -33,7 +33,7 @@ void main() { expect(find.textContaining('channel-integration'), findsWidgets); expect( find.text( - 'Last navigation: channel:https://mm.example.com/channel-integration', + 'Last navigation: channel:https://nexo.example.com/channel-integration', ), findsOneWidget, ); @@ -46,10 +46,10 @@ void main() { ) async { await tester.pumpWidget(const MyApp()); - MattermostPushPlugin.instance.listenNativeChannelForTesting(); - await MattermostPushPlugin.instance.debugSendNativeEventForTesting(const { + NexoMessagingPlugin.instance.listenNativeChannelForTesting(); + await NexoMessagingPlugin.instance.debugSendNativeEventForTesting(const { 'type': PushNotificationType.opened, - 'server_url': 'https://mm.example.com', + 'server_url': 'https://nexo.example.com', 'channel_id': 'channel-integration', 'root_id': 'root-integration', 'is_crt_enabled': 'true', @@ -61,7 +61,7 @@ void main() { expect(find.textContaining('root-integration'), findsWidgets); expect( find.text( - 'Last navigation: thread:https://mm.example.com/root-integration', + 'Last navigation: thread:https://nexo.example.com/root-integration', ), findsOneWidget, ); diff --git a/apps/client/lib/main.dart b/apps/client/lib/main.dart index 87027304..3fe7c1e1 100644 --- a/apps/client/lib/main.dart +++ b/apps/client/lib/main.dart @@ -1,7 +1,7 @@ import 'dart:async'; import 'package:flutter/material.dart'; -import 'package:mattermost_push_plugin/mattermost_push_plugin.dart'; +import 'package:nexo_messaging/nexo_messaging.dart'; void main() { runApp(const MyApp()); @@ -25,7 +25,7 @@ class _MyAppState extends State { @override void initState() { super.initState(); - final plugin = MattermostPushPlugin.instance; + final plugin = NexoMessagingPlugin.instance; plugin.onDeviceTokenReady = (token) { if (!mounted) return; setState(() => _deviceToken = token); @@ -52,7 +52,7 @@ class _MyAppState extends State { void dispose() { _notificationSubscription?.cancel(); _openedSubscription?.cancel(); - final plugin = MattermostPushPlugin.instance; + final plugin = NexoMessagingPlugin.instance; plugin.onDeviceTokenReady = null; plugin.onNavigateToChannel = null; plugin.onNavigateToThread = null; diff --git a/apps/client/macos/Flutter/GeneratedPluginRegistrant.swift b/apps/client/macos/Flutter/GeneratedPluginRegistrant.swift index 688c1eef..71642dda 100644 --- a/apps/client/macos/Flutter/GeneratedPluginRegistrant.swift +++ b/apps/client/macos/Flutter/GeneratedPluginRegistrant.swift @@ -7,7 +7,7 @@ import Foundation import firebase_core import firebase_messaging -import mattermost_push_plugin +import nexo_messaging func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) { FLTFirebaseCorePlugin.register(with: registry.registrar(forPlugin: "FLTFirebaseCorePlugin")) diff --git a/apps/client/pubspec.lock b/apps/client/pubspec.lock index e54abebc..5f5f3c70 100644 --- a/apps/client/pubspec.lock +++ b/apps/client/pubspec.lock @@ -207,13 +207,6 @@ packages: url: "https://pub.dev" source: hosted version: "0.13.0" - mattermost_push_plugin: - dependency: "direct main" - description: - path: "../../packages/messaging_flutter" - relative: true - source: path - version: "0.0.1" meta: dependency: transitive description: @@ -222,6 +215,13 @@ packages: url: "https://pub.dev" source: hosted version: "1.17.0" + nexo_messaging: + dependency: "direct main" + description: + path: "../../packages/messaging_flutter" + relative: true + source: path + version: "0.0.1" path: dependency: transitive description: diff --git a/apps/client/pubspec.yaml b/apps/client/pubspec.yaml index fa4577cb..85082a30 100644 --- a/apps/client/pubspec.yaml +++ b/apps/client/pubspec.yaml @@ -17,7 +17,7 @@ dependencies: flutter: sdk: flutter - mattermost_push_plugin: + nexo_messaging: path: ../../packages/messaging_flutter # The following adds the Cupertino Icons font to your application. diff --git a/apps/client/test/widget_test.dart b/apps/client/test/widget_test.dart index b5458452..016e4246 100644 --- a/apps/client/test/widget_test.dart +++ b/apps/client/test/widget_test.dart @@ -1,6 +1,6 @@ import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; -import 'package:mattermost_push_plugin/mattermost_push_plugin.dart'; +import 'package:nexo_messaging/nexo_messaging.dart'; import 'package:nexo_client/main.dart'; void main() { @@ -20,9 +20,9 @@ void main() { ) async { await tester.pumpWidget(const MyApp()); - MattermostPushPlugin.instance.handleNativeEvent(const { + NexoMessagingPlugin.instance.handleNativeEvent(const { 'type': PushNotificationType.opened, - 'server_url': 'https://mm.example.com', + 'server_url': 'https://nexo.example.com', 'channel_id': 'channel-123', 'is_crt_enabled': 'false', }); @@ -30,18 +30,18 @@ void main() { expect( find.text( - 'Last notification: type: opened, server_url: https://mm.example.com, channel_id: channel-123, is_crt_enabled: false', + 'Last notification: type: opened, server_url: https://nexo.example.com, channel_id: channel-123, is_crt_enabled: false', ), findsOneWidget, ); expect( find.text( - 'Last opened: server_url: https://mm.example.com, channel_id: channel-123, root_id: null, is_crt_enabled: false', + 'Last opened: server_url: https://nexo.example.com, channel_id: channel-123, root_id: null, is_crt_enabled: false', ), findsOneWidget, ); expect( - find.text('Last navigation: channel:https://mm.example.com/channel-123'), + find.text('Last navigation: channel:https://nexo.example.com/channel-123'), findsOneWidget, ); @@ -53,9 +53,9 @@ void main() { (WidgetTester tester) async { await tester.pumpWidget(const MyApp()); - MattermostPushPlugin.instance.handleNativeEvent(const { + NexoMessagingPlugin.instance.handleNativeEvent(const { 'type': PushNotificationType.opened, - 'server_url': 'https://mm.example.com', + 'server_url': 'https://nexo.example.com', 'channel_id': 'channel-123', 'root_id': 'thread-456', 'is_crt_enabled': 'true', @@ -64,18 +64,18 @@ void main() { expect( find.text( - 'Last notification: type: opened, server_url: https://mm.example.com, channel_id: channel-123, root_id: thread-456, is_crt_enabled: true', + 'Last notification: type: opened, server_url: https://nexo.example.com, channel_id: channel-123, root_id: thread-456, is_crt_enabled: true', ), findsOneWidget, ); expect( find.text( - 'Last opened: server_url: https://mm.example.com, channel_id: channel-123, root_id: thread-456, is_crt_enabled: true', + 'Last opened: server_url: https://nexo.example.com, channel_id: channel-123, root_id: thread-456, is_crt_enabled: true', ), findsOneWidget, ); expect( - find.text('Last navigation: thread:https://mm.example.com/thread-456'), + find.text('Last navigation: thread:https://nexo.example.com/thread-456'), findsOneWidget, ); @@ -88,7 +88,7 @@ void main() { ) async { await tester.pumpWidget(const MyApp()); - MattermostPushPlugin.instance.onDeviceTokenReady?.call( + NexoMessagingPlugin.instance.onDeviceTokenReady?.call( 'test-device-token-123', ); await tester.pump(); diff --git a/packages/messaging_flutter/lib/mattermost_push_plugin.dart b/packages/messaging_flutter/lib/nexo_messaging.dart similarity index 67% rename from packages/messaging_flutter/lib/mattermost_push_plugin.dart rename to packages/messaging_flutter/lib/nexo_messaging.dart index b4cf6230..8497b12e 100644 --- a/packages/messaging_flutter/lib/mattermost_push_plugin.dart +++ b/packages/messaging_flutter/lib/nexo_messaging.dart @@ -1,3 +1,3 @@ -export 'src/mattermost_push_plugin.dart'; +export 'src/nexo_messaging_plugin.dart'; export 'src/notification_opened_event.dart'; export 'src/push_notification_type.dart'; diff --git a/packages/messaging_flutter/lib/src/mattermost_push_plugin.dart b/packages/messaging_flutter/lib/src/nexo_messaging_plugin.dart similarity index 96% rename from packages/messaging_flutter/lib/src/mattermost_push_plugin.dart rename to packages/messaging_flutter/lib/src/nexo_messaging_plugin.dart index df834d17..01557f90 100644 --- a/packages/messaging_flutter/lib/src/mattermost_push_plugin.dart +++ b/packages/messaging_flutter/lib/src/nexo_messaging_plugin.dart @@ -8,14 +8,14 @@ import 'notification_opened_event.dart'; import 'push_notification_type.dart'; const String _kNotificationChannelName = - 'com.tokilabs.mattermost/notifications'; + 'com.tokilabs.nexo.messaging/notifications'; const String _kActionChannelName = - 'com.tokilabs.mattermost/notification_actions'; + 'com.tokilabs.nexo.messaging/notification_actions'; const String _kDeviceTokenPrefix = 'android_rn'; -class MattermostPushPlugin { - MattermostPushPlugin._(); - static final MattermostPushPlugin instance = MattermostPushPlugin._(); +class NexoMessagingPlugin { + NexoMessagingPlugin._(); + static final NexoMessagingPlugin instance = NexoMessagingPlugin._(); @visibleForTesting static const String notificationChannelName = _kNotificationChannelName; diff --git a/packages/messaging_flutter/pubspec.yaml b/packages/messaging_flutter/pubspec.yaml index 9e9d32bd..ea66432a 100644 --- a/packages/messaging_flutter/pubspec.yaml +++ b/packages/messaging_flutter/pubspec.yaml @@ -1,5 +1,5 @@ -name: mattermost_push_plugin -description: "Mattermost push notification Flutter plugin. Android-first; iOS/macOS scaffold only." +name: nexo_messaging +description: "Nexo messaging and notification Flutter plugin. Android-first; iOS/macOS scaffold only." version: 0.0.1 publish_to: 'none' homepage: diff --git a/packages/messaging_flutter/test/mattermost_push_plugin_test.dart b/packages/messaging_flutter/test/nexo_messaging_test.dart similarity index 76% rename from packages/messaging_flutter/test/mattermost_push_plugin_test.dart rename to packages/messaging_flutter/test/nexo_messaging_test.dart index 73fcbee4..a0712a87 100644 --- a/packages/messaging_flutter/test/mattermost_push_plugin_test.dart +++ b/packages/messaging_flutter/test/nexo_messaging_test.dart @@ -2,7 +2,7 @@ import 'dart:async'; import 'package:flutter/services.dart'; import 'package:flutter_test/flutter_test.dart'; -import 'package:mattermost_push_plugin/mattermost_push_plugin.dart'; +import 'package:nexo_messaging/nexo_messaging.dart'; void main() { TestWidgetsFlutterBinding.ensureInitialized(); @@ -10,13 +10,13 @@ void main() { group('NotificationOpenedEvent.fromMap', () { test('parses server_url, channel_id, root_id, is_crt_enabled', () { final event = NotificationOpenedEvent.fromMap({ - 'server_url': 'https://mm.example.com', + 'server_url': 'https://nexo.example.com', 'channel_id': 'channel-123', 'root_id': 'root-456', 'is_crt_enabled': 'true', }); - expect(event.serverUrl, 'https://mm.example.com'); + expect(event.serverUrl, 'https://nexo.example.com'); expect(event.channelId, 'channel-123'); expect(event.rootId, 'root-456'); expect(event.isCRTEnabled, isTrue); @@ -24,7 +24,7 @@ void main() { test('defaults isCRTEnabled to false when flag is absent or non-true', () { final missing = NotificationOpenedEvent.fromMap({ - 'server_url': 'https://mm.example.com', + 'server_url': 'https://nexo.example.com', 'channel_id': 'channel-123', }); expect(missing.isCRTEnabled, isFalse); @@ -36,12 +36,12 @@ void main() { }); }); - group('MattermostPushPlugin.handleNativeEvent', () { - late MattermostPushPlugin plugin; - final actionChannel = MethodChannel(MattermostPushPlugin.actionChannelName); + group('NexoMessagingPlugin.handleNativeEvent', () { + late NexoMessagingPlugin plugin; + final actionChannel = MethodChannel(NexoMessagingPlugin.actionChannelName); setUp(() { - plugin = MattermostPushPlugin.instance; + plugin = NexoMessagingPlugin.instance; plugin.onNavigateToChannel = null; plugin.onNavigateToThread = null; plugin.onDeviceTokenReady = null; @@ -57,12 +57,12 @@ void main() { plugin.handleNativeEvent({ 'type': PushNotificationType.opened, - 'server_url': 'https://mm.example.com', + 'server_url': 'https://nexo.example.com', 'channel_id': 'channel-123', }); final event = await future; - expect(event.serverUrl, 'https://mm.example.com'); + expect(event.serverUrl, 'https://nexo.example.com'); expect(event.channelId, 'channel-123'); }); @@ -79,11 +79,11 @@ void main() { plugin.handleNativeEvent({ 'type': PushNotificationType.message, 'userInteraction': true, - 'server_url': 'https://mm.example.com', + 'server_url': 'https://nexo.example.com', 'channel_id': 'channel-xyz', }); - expect(navServer, 'https://mm.example.com'); + expect(navServer, 'https://nexo.example.com'); expect(navChannel, 'channel-xyz'); }, ); @@ -98,13 +98,13 @@ void main() { plugin.handleNativeEvent({ 'type': PushNotificationType.opened, - 'server_url': 'https://mm.example.com', + 'server_url': 'https://nexo.example.com', 'channel_id': 'channel-123', 'root_id': 'root-789', 'is_crt_enabled': 'true', }); - expect(navServer, 'https://mm.example.com'); + expect(navServer, 'https://nexo.example.com'); expect(navRoot, 'root-789'); }); @@ -141,13 +141,13 @@ void main() { () async { String? channelToken; TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger - .setMockMethodCallHandler(actionChannel, (call) async { - if (call.method == 'saveDeviceToken') { - final args = call.arguments as Map; - channelToken = args['token'] as String?; - } - return null; - }); + .setMockMethodCallHandler(actionChannel, (call) async { + if (call.method == 'saveDeviceToken') { + final args = call.arguments as Map; + channelToken = args['token'] as String?; + } + return null; + }); final completer = Completer(); plugin.onDeviceTokenReady = completer.complete; @@ -168,21 +168,21 @@ void main() { () async { MethodCall? capturedCall; TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger - .setMockMethodCallHandler(actionChannel, (call) async { - capturedCall = call; - return null; - }); + .setMockMethodCallHandler(actionChannel, (call) async { + capturedCall = call; + return null; + }); await plugin.debugSendNativeEventForTesting({ 'type': PushNotificationType.opened, - 'server_url': 'https://mm.example.com', + 'server_url': 'https://nexo.example.com', 'channel_id': 'channel-debug', }); expect(capturedCall?.method, 'debugSendNativeEvent'); expect(capturedCall?.arguments, { 'type': PushNotificationType.opened, - 'server_url': 'https://mm.example.com', + 'server_url': 'https://nexo.example.com', 'channel_id': 'channel-debug', }); }, @@ -192,12 +192,12 @@ void main() { group('Channel constants', () { test('notification and action channel names are preserved', () { expect( - MattermostPushPlugin.notificationChannelName, - 'com.tokilabs.mattermost/notifications', + NexoMessagingPlugin.notificationChannelName, + 'com.tokilabs.nexo.messaging/notifications', ); expect( - MattermostPushPlugin.actionChannelName, - 'com.tokilabs.mattermost/notification_actions', + NexoMessagingPlugin.actionChannelName, + 'com.tokilabs.nexo.messaging/notification_actions', ); }); });