dropping GCM support
This commit is contained in:
parent
02160f1eaf
commit
df9ff16c5c
36 changed files with 6228 additions and 149 deletions
|
|
@ -29,7 +29,7 @@ namespace Yavsc.ApiControllers
|
|||
ApplicationDbContext dbContext;
|
||||
private IStringLocalizer _localizer;
|
||||
private GoogleAuthSettings _googleSettings;
|
||||
private IGoogleCloudMessageSender _GCMSender;
|
||||
private IYavscMessageSender _GCMSender;
|
||||
private IAuthorizationService authorizationService;
|
||||
|
||||
|
||||
|
|
@ -42,7 +42,7 @@ namespace Yavsc.ApiControllers
|
|||
IStringLocalizer<Yavsc.Resources.YavscLocalisation> SR,
|
||||
ApplicationDbContext context,
|
||||
IOptions<GoogleAuthSettings> googleSettings,
|
||||
IGoogleCloudMessageSender GCMSender,
|
||||
IYavscMessageSender GCMSender,
|
||||
IBillingService billingService
|
||||
)
|
||||
{
|
||||
|
|
@ -108,7 +108,7 @@ namespace Yavsc.ApiControllers
|
|||
public async Task<IActionResult> ProSign(string billingCode, long id)
|
||||
{
|
||||
var estimate = dbContext.Estimates.
|
||||
Include(e=>e.Client).Include(e=>e.Client.Devices)
|
||||
Include(e=>e.Client).Include(e=>e.Client.DeviceDeclarations)
|
||||
.Include(e=>e.Bill).Include(e=>e.Owner).Include(e=>e.Owner.Performer)
|
||||
.FirstOrDefault(e=>e.Id == id);
|
||||
if (estimate == null)
|
||||
|
|
@ -127,7 +127,7 @@ namespace Yavsc.ApiControllers
|
|||
|
||||
var yaev = new EstimationEvent(estimate,_localizer);
|
||||
|
||||
var regids = estimate.Client.Devices.Select(d => d.GCMRegistrationId).ToArray();
|
||||
var regids = estimate.Client.DeviceDeclarations.Select(d => d.DeviceId).ToArray();
|
||||
bool gcmSent = false;
|
||||
if (regids.Length>0) {
|
||||
var grep = await _GCMSender.NotifyEstimateAsync(regids,yaev);
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ namespace Yavsc.ApiControllers
|
|||
{
|
||||
private ApplicationDbContext _context;
|
||||
private IEmailSender _emailSender;
|
||||
private IGoogleCloudMessageSender _GCMSender;
|
||||
private IYavscMessageSender _GCMSender;
|
||||
private GoogleAuthSettings _googleSettings;
|
||||
private IStringLocalizer<YavscLocalisation> _localizer;
|
||||
private ILogger _logger;
|
||||
|
|
@ -40,7 +40,7 @@ namespace Yavsc.ApiControllers
|
|||
PayPalSettings _paymentSettings;
|
||||
public HairCutController(ApplicationDbContext context,
|
||||
IOptions<GoogleAuthSettings> googleSettings,
|
||||
IGoogleCloudMessageSender GCMSender,
|
||||
IYavscMessageSender GCMSender,
|
||||
UserManager<ApplicationUser> userManager,
|
||||
IStringLocalizer<Yavsc.Resources.YavscLocalisation> localizer,
|
||||
IEmailSender emailSender,
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
|
||||
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Security.Claims;
|
||||
|
|
@ -9,15 +9,15 @@ using Yavsc.Models;
|
|||
using Yavsc.Models.Identity;
|
||||
|
||||
[Authorize, Route("~/api/gcm")]
|
||||
public class GCMController : Controller
|
||||
public class NativeConfidentialController : Controller
|
||||
{
|
||||
ILogger _logger;
|
||||
ApplicationDbContext _context;
|
||||
|
||||
public GCMController(ApplicationDbContext context,
|
||||
public NativeConfidentialController(ApplicationDbContext context,
|
||||
ILoggerFactory loggerFactory)
|
||||
{
|
||||
_logger = loggerFactory.CreateLogger<GCMController>();
|
||||
_logger = loggerFactory.CreateLogger<NativeConfidentialController>();
|
||||
_context = context;
|
||||
}
|
||||
/// <summary>
|
||||
|
|
@ -28,7 +28,7 @@ public class GCMController : Controller
|
|||
/// <returns></returns>
|
||||
[Authorize, HttpPost("register")]
|
||||
public IActionResult Register(
|
||||
[FromBody] GoogleCloudMobileDeclaration declaration)
|
||||
[FromBody] DeviceDeclaration declaration)
|
||||
{
|
||||
var uid = User.GetUserId();
|
||||
|
||||
|
|
@ -40,15 +40,13 @@ public class GCMController : Controller
|
|||
declaration.LatestActivityUpdate = DateTime.Now;
|
||||
|
||||
_logger.LogInformation($"Registering device with id:{declaration.DeviceId} for {uid}");
|
||||
var alreadyRegisteredDevice = _context.GCMDevices.FirstOrDefault(d => d.DeviceId == declaration.DeviceId);
|
||||
var alreadyRegisteredDevice = _context.DeviceDeclaration.FirstOrDefault(d => d.DeviceId == declaration.DeviceId);
|
||||
var deviceAlreadyRegistered = (alreadyRegisteredDevice!=null);
|
||||
if (deviceAlreadyRegistered)
|
||||
{
|
||||
_logger.LogInformation($"deviceAlreadyRegistered");
|
||||
// Override an exiting owner
|
||||
alreadyRegisteredDevice.DeclarationDate = DateTime.Now;
|
||||
alreadyRegisteredDevice.DeviceOwnerId = uid;
|
||||
alreadyRegisteredDevice.GCMRegistrationId = declaration.GCMRegistrationId;
|
||||
alreadyRegisteredDevice.Model = declaration.Model;
|
||||
alreadyRegisteredDevice.Platform = declaration.Platform;
|
||||
alreadyRegisteredDevice.Version = declaration.Version;
|
||||
|
|
@ -60,7 +58,7 @@ public class GCMController : Controller
|
|||
_logger.LogInformation($"new device");
|
||||
declaration.DeclarationDate = DateTime.Now;
|
||||
declaration.DeviceOwnerId = uid;
|
||||
_context.GCMDevices.Add(declaration as GoogleCloudMobileDeclaration);
|
||||
_context.DeviceDeclaration.Add(declaration as DeviceDeclaration);
|
||||
_context.SaveChanges(User.GetUserId());
|
||||
}
|
||||
var latestActivityUpdate = _context.Activities.Max(a=>a.DateModified);
|
||||
Loading…
Add table
Add a link
Reference in a new issue