Skip to content

Commit

Permalink
Updated model to new channel config.
Browse files Browse the repository at this point in the history
  • Loading branch information
freezy committed Dec 6, 2015
1 parent ae969df commit 0f18dea
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 7 deletions.
8 changes: 8 additions & 0 deletions Vpdb/Models/User.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ public class UserFull : User
public string CreatedAt { get; set; }
public bool IsActive { get; set; }
public List<string> Roles { get; set; }
public ChannelConfigDetails ChannelConfig { get; set; }
public Permission Permissions { get; set; }
public QuotaDetails Quota { get; set; }

Expand All @@ -53,6 +54,13 @@ public class Permission
public List<string> Messages { get; set; }
}

public class ChannelConfigDetails
{
public string ApiKey { get; set; }
public List<string> SubscribedReleases { get; set; }
public bool SubscribeToStarred { get; set; }
}

public class PlanDetails
{
public string Id { get; set; }
Expand Down
16 changes: 9 additions & 7 deletions Vpdb/VpdbClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down Expand Up @@ -236,9 +230,17 @@ protected override WebRequest GetWebRequest(Uri address)
/// Connects to Pusher and subscribes to the user's private channel.
/// </summary>
/// <param name="user"></param>
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;
Expand Down

0 comments on commit 0f18dea

Please sign in to comment.