diff --git a/Vpdb/Models/User.cs b/Vpdb/Models/User.cs index 46eb4f8..18843ee 100644 --- a/Vpdb/Models/User.cs +++ b/Vpdb/Models/User.cs @@ -33,6 +33,7 @@ public class UserFull : User public string CreatedAt { get; set; } public bool IsActive { get; set; } public List Roles { get; set; } + public ChannelConfigDetails ChannelConfig { get; set; } public Permission Permissions { get; set; } public QuotaDetails Quota { get; set; } @@ -53,6 +54,13 @@ public class Permission public List Messages { get; set; } } + public class ChannelConfigDetails + { + public string ApiKey { get; set; } + public List SubscribedReleases { get; set; } + public bool SubscribeToStarred { get; set; } + } + public class PlanDetails { public string Id { get; set; } diff --git a/Vpdb/VpdbClient.cs b/Vpdb/VpdbClient.cs index e4e6f93..54b6074 100644 --- a/Vpdb/VpdbClient.cs +++ b/Vpdb/VpdbClient.cs @@ -140,12 +140,6 @@ public IVpdbClient Initialize() } }, exception => HandleApiError(exception, "subscribing to ApiAuthenticated for Pusher")); - // initialize pusher - _pusher = new Pusher("02ee40b62e1fb0696e02", new PusherOptions() { - Encrypted = true, - Authorizer = new PusherAuthorizer(this, _crashManager, _logger) - }); - return this; } @@ -236,9 +230,17 @@ protected override WebRequest GetWebRequest(Uri address) /// Connects to Pusher and subscribes to the user's private channel. /// /// - private void SetupPusher(User user) + private void SetupPusher(UserFull user) { + // initialize pusher + if (_pusher == null) { + _pusher = new Pusher(user.ChannelConfig.ApiKey, new PusherOptions() { + Encrypted = true, + Authorizer = new PusherAuthorizer(this, _crashManager, _logger) + }); + } + var isNewConnection = _connectedApiEndpoint == null; var isSameConnection = !isNewConnection && _connectedApiEndpoint.Equals(_settingsManager.Settings.Endpoint); var isDifferentConnection = !isNewConnection && !isSameConnection;