Skip to content
This repository has been archived by the owner on Sep 12, 2022. It is now read-only.

Commit

Permalink
Restructure
Browse files Browse the repository at this point in the history
  • Loading branch information
0xdeafcafe committed Apr 28, 2020
1 parent 9bea635 commit 1a2678f
Show file tree
Hide file tree
Showing 15 changed files with 36 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
using Newtonsoft.Json;
using PuppeteerSharp;

namespace Branch.Global.Services
namespace Branch.Global.Libraries
{
public class ChromieTalkie : IDisposable
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System;

namespace Branch.Global.Contracts
namespace Branch.Global.Models.Domain
{
public class CacheInfo : ICacheInfo
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace Branch.Global.Contracts
namespace Branch.Global.Models.Domain
{
public interface IBranchResponse
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System;

namespace Branch.Global.Contracts
namespace Branch.Global.Models.Domain
{
public interface ICacheInfo
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace Branch.Global.Contracts
namespace Branch.Global.Models.Domain
{
public class ServiceConfig
{
Expand Down
30 changes: 24 additions & 6 deletions dotnet/Services/Identity/Libraries/XblIdentityCache.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Branch.Global.Contracts;
using Branch.Global.Extensions;
using Branch.Global.Libraries;
using Branch.Global.Models.Domain;
using Branch.Global.Models.XboxLive;
using Branch.Services.Token;
using Crpc.Exceptions;
using Microsoft.Extensions.Logging;
using Newtonsoft.Json;
using ServiceStack.Redis;
Expand Down Expand Up @@ -85,12 +86,29 @@ private async Task<GetXblIdentityRes> GetIdentity(LookupType type, string value,
options.Headers.Add("X-XBL-Contract-Version", "2");
query.Add("settings", "gamertag");

var response = await _client.Do<ProfileSettings>("GET", path, query, options);
var user = response.ProfileUsers[0];
var xuid = user.ID.ToString();
var gamertag = user.Settings.First(s => s.ID == "Gamertag").Value;
try
{
var response = await _client.Do<ProfileSettings>("GET", path, query, options);
var user = response.ProfileUsers[0];
var xuid = user.ID.ToString();
var gamertag = user.Settings.First(s => s.ID == "Gamertag").Value;

return (gamertag, xuid);
}
catch (CrpcException ex)
{
switch(ex.Message)
{
case "2": // XUIDInvalid
throw new CrpcException("invalid_xuid");

case "8": // ProfileNotFound
throw new CrpcException("profile_not_found");

return (gamertag, xuid);
default:
throw new CrpcException("resolve_identity_failed", null, ex);
}
}
}

private string GenerateRedisKey(LookupType type, string value)
Expand Down
2 changes: 1 addition & 1 deletion dotnet/Services/Identity/Models/Config.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using System.Collections.Generic;
using Branch.Global.Contracts;
using Branch.Global.Models.Domain;
using Branch.Global.Libraries;

namespace Branch.Services.Identity.Models
Expand Down
2 changes: 1 addition & 1 deletion dotnet/Services/Identity/Service.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using System.Threading.Tasks;
using Branch.Global.Contracts;
using Branch.Global.Models.Domain;
using Microsoft.AspNetCore.Http;

namespace Branch.Services.Identity
Expand Down
2 changes: 1 addition & 1 deletion dotnet/Services/Identity/Startup.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System.Threading.Tasks;
using Branch.Global.Attributes;
using Branch.Global.Contracts;
using Branch.Global.Models.Domain;
using Branch.Services.Identity.App;
using Branch.Services.Identity.Libraries;
using Branch.Services.Identity.Models;
Expand Down
1 change: 0 additions & 1 deletion dotnet/Services/Token/App/Application.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using System;
using Branch.Global.Libraries;
using Branch.Global.Services;
using Branch.Services.Token.Models;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
Expand Down
2 changes: 1 addition & 1 deletion dotnet/Services/Token/App/GetXblToken.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using System;
using System.Threading.Tasks;
using System.Web;
using Branch.Global.Contracts;
using Branch.Global.Models.Domain;
using Branch.Global.Extensions;
using Branch.Global.Libraries;
using Crpc.Exceptions;
Expand Down
2 changes: 1 addition & 1 deletion dotnet/Services/Token/Client.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System.Collections.Generic;
using System.Threading.Tasks;
using Branch.Global.Contracts;
using Branch.Global.Models.Domain;
using Branch.Global.Libraries;
using Microsoft.AspNetCore.Http;

Expand Down
1 change: 0 additions & 1 deletion dotnet/Services/Token/Models/Config.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using Branch.Global.Libraries;
using Branch.Global.Services;

namespace Branch.Services.Token.Models
{
Expand Down
2 changes: 1 addition & 1 deletion dotnet/Services/Token/Service.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using System.Threading.Tasks;
using Branch.Global.Contracts;
using Branch.Global.Models.Domain;
using Microsoft.AspNetCore.Http;

namespace Branch.Services.Token
Expand Down
3 changes: 1 addition & 2 deletions dotnet/Services/Token/Startup.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using System;
using System.Threading.Tasks;
using Branch.Global.Attributes;
using Branch.Global.Services;
using Branch.Global.Libraries;
using Branch.Services.Token.App;
using Branch.Services.Token.Models;
using Branch.Services.Token.Server;
Expand Down

0 comments on commit 1a2678f

Please sign in to comment.