|
|
|
@ -29,12 +29,11 @@ namespace Yavsc.Controllers
|
|
|
|
protected IStringLocalizer _localizer;
|
|
|
|
protected IStringLocalizer _localizer;
|
|
|
|
protected SiteSettings _siteSettings;
|
|
|
|
protected SiteSettings _siteSettings;
|
|
|
|
protected SmtpSettings _smtpSettings;
|
|
|
|
protected SmtpSettings _smtpSettings;
|
|
|
|
|
|
|
|
|
|
|
|
protected ICalendarManager _calendarManager;
|
|
|
|
protected ICalendarManager _calendarManager;
|
|
|
|
|
|
|
|
|
|
|
|
protected readonly ILogger _logger;
|
|
|
|
protected readonly ILogger _logger;
|
|
|
|
public CommandController(ApplicationDbContext context, IOptions<GoogleAuthSettings> googleSettings,
|
|
|
|
public CommandController(ApplicationDbContext context, IOptions<GoogleAuthSettings> googleSettings,
|
|
|
|
IYavscMessageSender GCMSender,
|
|
|
|
IYavscMessageSender messageSender,
|
|
|
|
UserManager<ApplicationUser> userManager,
|
|
|
|
UserManager<ApplicationUser> userManager,
|
|
|
|
ICalendarManager calendarManager,
|
|
|
|
ICalendarManager calendarManager,
|
|
|
|
IStringLocalizer<Yavsc.Resources.YavscLocalisation> localizer,
|
|
|
|
IStringLocalizer<Yavsc.Resources.YavscLocalisation> localizer,
|
|
|
|
@ -44,7 +43,7 @@ namespace Yavsc.Controllers
|
|
|
|
ILoggerFactory loggerFactory)
|
|
|
|
ILoggerFactory loggerFactory)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
_context = context;
|
|
|
|
_context = context;
|
|
|
|
_MessageSender = GCMSender;
|
|
|
|
_MessageSender = messageSender;
|
|
|
|
_emailSender = emailSender;
|
|
|
|
_emailSender = emailSender;
|
|
|
|
_googleSettings = googleSettings.Value;
|
|
|
|
_googleSettings = googleSettings.Value;
|
|
|
|
_userManager = userManager;
|
|
|
|
_userManager = userManager;
|
|
|
|
@ -136,7 +135,7 @@ namespace Yavsc.Controllers
|
|
|
|
);
|
|
|
|
);
|
|
|
|
var pro = _context.Performers.Include(
|
|
|
|
var pro = _context.Performers.Include(
|
|
|
|
u => u.Performer
|
|
|
|
u => u.Performer
|
|
|
|
).Include(u => u.Performer.DeviceDeclarations)
|
|
|
|
).Include(u => u.Performer.DeviceDeclaration)
|
|
|
|
.FirstOrDefault(
|
|
|
|
.FirstOrDefault(
|
|
|
|
x => x.PerformerId == command.PerformerId
|
|
|
|
x => x.PerformerId == command.PerformerId
|
|
|
|
);
|
|
|
|
);
|
|
|
|
@ -145,9 +144,6 @@ namespace Yavsc.Controllers
|
|
|
|
command.ClientId = uid;
|
|
|
|
command.ClientId = uid;
|
|
|
|
command.PerformerProfile = pro;
|
|
|
|
command.PerformerProfile = pro;
|
|
|
|
// FIXME Why!!
|
|
|
|
// FIXME Why!!
|
|
|
|
// ModelState.ClearValidationState("PerformerProfile.Avatar");
|
|
|
|
|
|
|
|
// ModelState.ClearValidationState("Client.Avatar");
|
|
|
|
|
|
|
|
// ModelState.ClearValidationState("ClientId");
|
|
|
|
|
|
|
|
ModelState.MarkFieldSkipped("ClientId");
|
|
|
|
ModelState.MarkFieldSkipped("ClientId");
|
|
|
|
|
|
|
|
|
|
|
|
if (ModelState.IsValid)
|
|
|
|
if (ModelState.IsValid)
|
|
|
|
@ -173,8 +169,8 @@ namespace Yavsc.Controllers
|
|
|
|
try
|
|
|
|
try
|
|
|
|
{
|
|
|
|
{
|
|
|
|
_logger.LogInformation("sending message");
|
|
|
|
_logger.LogInformation("sending message");
|
|
|
|
var regids = new [] { command.PerformerProfile.Performer.Id };
|
|
|
|
var uids = new[] { command.PerformerProfile.PerformerId };
|
|
|
|
nrep = await _MessageSender.NotifyBookQueryAsync(regids, yaev);
|
|
|
|
nrep = await _MessageSender.NotifyBookQueryAsync(uids, yaev);
|
|
|
|
// TODO setup a profile choice to allow notifications
|
|
|
|
// TODO setup a profile choice to allow notifications
|
|
|
|
// both on mailbox and mobile
|
|
|
|
// both on mailbox and mobile
|
|
|
|
// if (grep==null || grep.success<=0 || grep.failure>0)
|
|
|
|
// if (grep==null || grep.success<=0 || grep.failure>0)
|
|
|
|
@ -187,14 +183,19 @@ namespace Yavsc.Controllers
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
else
|
|
|
|
nrep = new MessageWithPayloadResponse { failure=1, results = new MessageWithPayloadResponse.Result[] {
|
|
|
|
{
|
|
|
|
|
|
|
|
nrep = new MessageWithPayloadResponse
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
failure = 1,
|
|
|
|
|
|
|
|
results = new MessageWithPayloadResponse.Result[] {
|
|
|
|
new MessageWithPayloadResponse.Result
|
|
|
|
new MessageWithPayloadResponse.Result
|
|
|
|
{
|
|
|
|
{
|
|
|
|
error=NotificationTypes.ContactRefused,
|
|
|
|
error=NotificationTypes.ContactRefused,
|
|
|
|
registration_id= pro.PerformerId
|
|
|
|
registration_id= pro.PerformerId
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} };
|
|
|
|
}
|
|
|
|
|
|
|
|
};
|
|
|
|
_logger.LogInformation("Command.Create && ( !pro.AcceptNotifications || |pro.AcceptPublicContact ) ");
|
|
|
|
_logger.LogInformation("Command.Create && ( !pro.AcceptNotifications || |pro.AcceptPublicContact ) ");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
ViewBag.MessagingResponsePayload = nrep;
|
|
|
|
ViewBag.MessagingResponsePayload = nrep;
|
|
|
|
|