push messages are sent upon user ids
This commit is contained in:
@ -29,12 +29,11 @@ namespace Yavsc.Controllers
|
||||
protected IStringLocalizer _localizer;
|
||||
protected SiteSettings _siteSettings;
|
||||
protected SmtpSettings _smtpSettings;
|
||||
|
||||
protected ICalendarManager _calendarManager;
|
||||
|
||||
protected readonly ILogger _logger;
|
||||
public CommandController(ApplicationDbContext context, IOptions<GoogleAuthSettings> googleSettings,
|
||||
IYavscMessageSender GCMSender,
|
||||
IYavscMessageSender messageSender,
|
||||
UserManager<ApplicationUser> userManager,
|
||||
ICalendarManager calendarManager,
|
||||
IStringLocalizer<Yavsc.Resources.YavscLocalisation> localizer,
|
||||
@ -44,7 +43,7 @@ namespace Yavsc.Controllers
|
||||
ILoggerFactory loggerFactory)
|
||||
{
|
||||
_context = context;
|
||||
_MessageSender = GCMSender;
|
||||
_MessageSender = messageSender;
|
||||
_emailSender = emailSender;
|
||||
_googleSettings = googleSettings.Value;
|
||||
_userManager = userManager;
|
||||
@ -136,7 +135,7 @@ namespace Yavsc.Controllers
|
||||
);
|
||||
var pro = _context.Performers.Include(
|
||||
u => u.Performer
|
||||
).Include(u => u.Performer.DeviceDeclarations)
|
||||
).Include(u => u.Performer.DeviceDeclaration)
|
||||
.FirstOrDefault(
|
||||
x => x.PerformerId == command.PerformerId
|
||||
);
|
||||
@ -145,9 +144,6 @@ namespace Yavsc.Controllers
|
||||
command.ClientId = uid;
|
||||
command.PerformerProfile = pro;
|
||||
// FIXME Why!!
|
||||
// ModelState.ClearValidationState("PerformerProfile.Avatar");
|
||||
// ModelState.ClearValidationState("Client.Avatar");
|
||||
// ModelState.ClearValidationState("ClientId");
|
||||
ModelState.MarkFieldSkipped("ClientId");
|
||||
|
||||
if (ModelState.IsValid)
|
||||
@ -173,8 +169,8 @@ namespace Yavsc.Controllers
|
||||
try
|
||||
{
|
||||
_logger.LogInformation("sending message");
|
||||
var regids = new [] { command.PerformerProfile.Performer.Id };
|
||||
nrep = await _MessageSender.NotifyBookQueryAsync(regids, yaev);
|
||||
var uids = new[] { command.PerformerProfile.PerformerId };
|
||||
nrep = await _MessageSender.NotifyBookQueryAsync(uids, yaev);
|
||||
// TODO setup a profile choice to allow notifications
|
||||
// both on mailbox and mobile
|
||||
// if (grep==null || grep.success<=0 || grep.failure>0)
|
||||
@ -182,19 +178,24 @@ namespace Yavsc.Controllers
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError("Message sending failed with: "+ex.Message);
|
||||
_logger.LogError("Message sending failed with: " + ex.Message);
|
||||
throw;
|
||||
}
|
||||
|
||||
}
|
||||
else {
|
||||
nrep = new MessageWithPayloadResponse { failure=1, results = new MessageWithPayloadResponse.Result[] {
|
||||
new MessageWithPayloadResponse.Result
|
||||
{
|
||||
error=NotificationTypes.ContactRefused,
|
||||
registration_id= pro.PerformerId
|
||||
else
|
||||
{
|
||||
nrep = new MessageWithPayloadResponse
|
||||
{
|
||||
failure = 1,
|
||||
results = new MessageWithPayloadResponse.Result[] {
|
||||
new MessageWithPayloadResponse.Result
|
||||
{
|
||||
error=NotificationTypes.ContactRefused,
|
||||
registration_id= pro.PerformerId
|
||||
}
|
||||
} };
|
||||
}
|
||||
};
|
||||
_logger.LogInformation("Command.Create && ( !pro.AcceptNotifications || |pro.AcceptPublicContact ) ");
|
||||
}
|
||||
ViewBag.MessagingResponsePayload = nrep;
|
||||
|
@ -15,7 +15,7 @@ namespace Yavsc.Controllers
|
||||
|
||||
public CommandFormsController(ApplicationDbContext context)
|
||||
{
|
||||
_context = context;
|
||||
_context = context;
|
||||
}
|
||||
|
||||
// GET: CommandForms
|
||||
@ -48,9 +48,10 @@ namespace Yavsc.Controllers
|
||||
SetViewBag();
|
||||
return View();
|
||||
}
|
||||
private void SetViewBag(CommandForm commandForm=null) {
|
||||
private void SetViewBag(CommandForm commandForm = null)
|
||||
{
|
||||
ViewBag.ActivityCode = new SelectList(_context.Activities, "Code", "Name", commandForm?.ActivityCode);
|
||||
ViewBag.ActionName = Startup.Forms.Select( c => new SelectListItem { Value = c, Text = c, Selected = (commandForm?.ActionName == c) } );
|
||||
ViewBag.ActionName = Startup.Forms.Select(c => new SelectListItem { Value = c, Text = c, Selected = (commandForm?.ActionName == c) });
|
||||
}
|
||||
// POST: CommandForms/Create
|
||||
[HttpPost]
|
||||
|
@ -31,8 +31,8 @@ namespace Yavsc.Controllers
|
||||
{
|
||||
public HairCutCommandController(ApplicationDbContext context,
|
||||
IOptions<PayPalSettings> payPalSettings,
|
||||
IOptions<GoogleAuthSettings> googleSettings,
|
||||
IYavscMessageSender GCMSender,
|
||||
IOptions<GoogleAuthSettings> googleSettings,
|
||||
IYavscMessageSender GCMSender,
|
||||
UserManager<ApplicationUser> userManager,
|
||||
IStringLocalizer<Yavsc.Resources.YavscLocalisation> localizer,
|
||||
IEmailSender emailSender,
|
||||
@ -53,7 +53,7 @@ namespace Yavsc.Controllers
|
||||
.Include(x => x.PerformerProfile)
|
||||
.Include(x => x.Prestation)
|
||||
.Include(x => x.PerformerProfile.Performer)
|
||||
.Include(x => x.PerformerProfile.Performer.DeviceDeclarations)
|
||||
.Include(x => x.PerformerProfile.Performer.DeviceDeclaration)
|
||||
.Include(x => x.Regularisation)
|
||||
.SingleAsync(m => m.Id == id);
|
||||
query.SelectedProfile = await _context.BrusherProfile.SingleAsync(b => b.UserId == query.PerformerId);
|
||||
@ -100,11 +100,10 @@ namespace Yavsc.Controllers
|
||||
var yaev = command.CreatePaymentEvent(paymentInfo, _localizer);
|
||||
if (command.PerformerProfile.AcceptNotifications)
|
||||
{
|
||||
if (command.PerformerProfile.Performer.DeviceDeclarations.Count > 0)
|
||||
if (command.PerformerProfile.Performer.DeviceDeclaration.Count > 0)
|
||||
{
|
||||
var regids = command.PerformerProfile.Performer
|
||||
.DeviceDeclarations.Select(d => d.DeviceId);
|
||||
grep = await _MessageSender.NotifyAsync(regids, yaev);
|
||||
var regid = command.PerformerProfile.PerformerId;
|
||||
grep = await _MessageSender.NotifyAsync(new [] {regid}, yaev);
|
||||
}
|
||||
// TODO setup a profile choice to allow notifications
|
||||
// both on mailbox and mobile
|
||||
@ -217,7 +216,7 @@ namespace Yavsc.Controllers
|
||||
_logger.LogInformation("le Model _est_ valide.");
|
||||
var pro = _context.Performers.Include(
|
||||
u => u.Performer
|
||||
).Include(u => u.Performer.DeviceDeclarations)
|
||||
).Include(u => u.Performer.DeviceDeclaration)
|
||||
.FirstOrDefault(
|
||||
x => x.PerformerId == model.PerformerId
|
||||
);
|
||||
@ -268,10 +267,10 @@ namespace Yavsc.Controllers
|
||||
{
|
||||
if (pro.AcceptNotifications)
|
||||
{
|
||||
if (pro.Performer.DeviceDeclarations.Count > 0)
|
||||
if (pro.Performer.DeviceDeclaration.Count > 0)
|
||||
{
|
||||
var regids = pro.Performer.DeviceDeclarations.Select(d => d.DeviceId);
|
||||
grep = await _MessageSender.NotifyHairCutQueryAsync(regids, yaev);
|
||||
var uids = new[] { pro.PerformerId };
|
||||
grep = await _MessageSender.NotifyHairCutQueryAsync(uids, yaev);
|
||||
}
|
||||
// TODO setup a profile choice to allow notifications
|
||||
// both on mailbox and mobile
|
||||
@ -390,7 +389,7 @@ namespace Yavsc.Controllers
|
||||
);
|
||||
var pro = _context.Performers.Include(
|
||||
u => u.Performer
|
||||
).Include(u => u.Performer.DeviceDeclarations)
|
||||
).Include(u => u.Performer.DeviceDeclaration)
|
||||
.FirstOrDefault(
|
||||
x => x.PerformerId == command.PerformerId
|
||||
);
|
||||
@ -427,11 +426,10 @@ namespace Yavsc.Controllers
|
||||
if (pro.AcceptNotifications
|
||||
&& pro.AcceptPublicContact)
|
||||
{
|
||||
if (pro.Performer.DeviceDeclarations?.Count > 0)
|
||||
if (pro.Performer.DeviceDeclaration?.Count > 0)
|
||||
{
|
||||
var regids = command.PerformerProfile.Performer
|
||||
.DeviceDeclarations.Select(d => d.DeviceId);
|
||||
grep = await _MessageSender.NotifyHairCutQueryAsync(regids, yaev);
|
||||
var uids = new [] { command.PerformerProfile.PerformerId };
|
||||
grep = await _MessageSender.NotifyHairCutQueryAsync(uids, yaev);
|
||||
}
|
||||
// TODO setup a profile choice to allow notifications
|
||||
// both on mailbox and mobile, and to allow calendar event insertion.
|
||||
|
Reference in New Issue
Block a user