From ec5bd506dfae53cfb9b31302bcbd3fc9d3daa1fa Mon Sep 17 00:00:00 2001 From: Felipe Benevides Date: Thu, 15 Sep 2022 10:13:43 +0200 Subject: [PATCH] Swapping checks for private and private-encrypted channels (#72) * Swapping checks for private and private-encrypted channels * Remove whitespace * Bump to version 2.0.2 Co-authored-by: Pusher CI --- CHANGELOG.md | 4 ++++ .../pusher/channels_flutter/PusherChannelsFlutterPlugin.kt | 4 ++-- pubspec.yaml | 2 +- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a2cd2c1..34fd7bf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## 2.0.2 + +* [FIXED] Fix private-encrypted channels subscriptions + ## 2.0.1 * [FIXED] Change `getSocketId` function to return a `Future` * [FIXED] Replace `FlutterActivity` with general Activity diff --git a/android/src/main/kotlin/com/pusher/channels_flutter/PusherChannelsFlutterPlugin.kt b/android/src/main/kotlin/com/pusher/channels_flutter/PusherChannelsFlutterPlugin.kt index 0878bf6..0436f6a 100644 --- a/android/src/main/kotlin/com/pusher/channels_flutter/PusherChannelsFlutterPlugin.kt +++ b/android/src/main/kotlin/com/pusher/channels_flutter/PusherChannelsFlutterPlugin.kt @@ -140,10 +140,10 @@ class PusherChannelsFlutterPlugin : FlutterPlugin, MethodCallHandler, ActivityAw private fun subscribe(channelName: String, result: Result) { val channel = when { - channelName.startsWith("private-") -> pusher!!.subscribePrivate(channelName, this) channelName.startsWith("private-encrypted-") -> pusher!!.subscribePrivateEncrypted( channelName, this ) + channelName.startsWith("private-") -> pusher!!.subscribePrivate(channelName, this) channelName.startsWith("presence-") -> pusher!!.subscribePresence( channelName, this ) @@ -160,9 +160,9 @@ class PusherChannelsFlutterPlugin : FlutterPlugin, MethodCallHandler, ActivityAw private fun trigger(channelName: String, eventName: String, data: String, result: Result) { when { + channelName.startsWith("private-encrypted-") -> throw Exception("It's not currently possible to send a message using private encrypted channels.") channelName.startsWith("private-") -> pusher!!.getPrivateChannel(channelName) .trigger(eventName, data) - channelName.startsWith("private-encrypted-") -> throw Exception("It's not currently possible to send a message using private encrypted channels.") channelName.startsWith("presence-") -> pusher!!.getPresenceChannel(channelName) .trigger(eventName, data) else -> throw Exception("Messages can only be sent to private and presence channels.") diff --git a/pubspec.yaml b/pubspec.yaml index b96af5c..8c662cf 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: pusher_channels_flutter description: Pusher Channels Flutter Plugin -version: 2.0.1 +version: 2.0.2 homepage: https://github.com/pusher/pusher-channels-flutter repository: https://github.com/pusher/pusher-channels-flutter issue_tracker: https://github.com/pusher/pusher-channels-flutter/issues