always send an email, at notifying some performer
This commit is contained in:
parent
3e3729c79e
commit
0c8fe225ea
1 changed files with 62 additions and 53 deletions
|
|
@ -61,9 +61,11 @@ namespace Yavsc.Services
|
||||||
if (raa.Length < 1)
|
if (raa.Length < 1)
|
||||||
throw new Exception("No dest id");
|
throw new Exception("No dest id");
|
||||||
|
|
||||||
try {
|
try
|
||||||
|
{
|
||||||
List<MessageWithPayloadResponse.Result> results = new List<MessageWithPayloadResponse.Result>();
|
List<MessageWithPayloadResponse.Result> results = new List<MessageWithPayloadResponse.Result>();
|
||||||
foreach(var userId in raa) {
|
foreach (var userId in raa)
|
||||||
|
{
|
||||||
MessageWithPayloadResponse.Result result = new MessageWithPayloadResponse.Result();
|
MessageWithPayloadResponse.Result result = new MessageWithPayloadResponse.Result();
|
||||||
result.registration_id = userId;
|
result.registration_id = userId;
|
||||||
|
|
||||||
|
|
@ -74,12 +76,14 @@ namespace Yavsc.Services
|
||||||
result.error = "no such user.";
|
result.error = "no such user.";
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (!user.EmailConfirmed){
|
if (!user.EmailConfirmed)
|
||||||
|
{
|
||||||
response.failure++;
|
response.failure++;
|
||||||
result.error = "user has not confirmed his email address.";
|
result.error = "user has not confirmed his email address.";
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (user.Email==null){
|
if (user.Email == null)
|
||||||
|
{
|
||||||
response.failure++;
|
response.failure++;
|
||||||
result.error = "user has no legacy email address.";
|
result.error = "user has no legacy email address.";
|
||||||
continue;
|
continue;
|
||||||
|
|
@ -87,10 +91,7 @@ namespace Yavsc.Services
|
||||||
|
|
||||||
var body = ev.CreateBody();
|
var body = ev.CreateBody();
|
||||||
|
|
||||||
var cxids = _cxManager.GetConnexionIds(user.UserName).ToArray();
|
|
||||||
|
|
||||||
if (cxids.Length==0)
|
|
||||||
{
|
|
||||||
_logger.LogDebug($"Sending to {user.UserName} <{user.Email}> : {body}");
|
_logger.LogDebug($"Sending to {user.UserName} <{user.Email}> : {body}");
|
||||||
var mailSent = await _emailSender.SendEmailAsync(
|
var mailSent = await _emailSender.SendEmailAsync(
|
||||||
user.UserName,
|
user.UserName,
|
||||||
|
|
@ -99,7 +100,8 @@ namespace Yavsc.Services
|
||||||
body + Environment.NewLine
|
body + Environment.NewLine
|
||||||
);
|
);
|
||||||
|
|
||||||
if (!mailSent.Sent) {
|
if (!mailSent.Sent)
|
||||||
|
{
|
||||||
result.message_id = mailSent.MessageId;
|
result.message_id = mailSent.MessageId;
|
||||||
result.error = mailSent.ErrorMessage;
|
result.error = mailSent.ErrorMessage;
|
||||||
response.failure++;
|
response.failure++;
|
||||||
|
|
@ -109,11 +111,17 @@ namespace Yavsc.Services
|
||||||
result.message_id = mailSent.MessageId;
|
result.message_id = mailSent.MessageId;
|
||||||
response.success++;
|
response.success++;
|
||||||
}
|
}
|
||||||
|
var cxids = _cxManager.GetConnexionIds(user.UserName).ToArray();
|
||||||
|
if (cxids.Length == 0)
|
||||||
|
{
|
||||||
|
_logger.LogDebug($"no cx to {user.UserName} <{user.Email}> ");
|
||||||
}
|
}
|
||||||
else {
|
else
|
||||||
|
{
|
||||||
_logger.LogDebug($"Sending signal to {string.Join(" ", cxids)} : " + JsonConvert.SerializeObject(ev));
|
_logger.LogDebug($"Sending signal to {string.Join(" ", cxids)} : " + JsonConvert.SerializeObject(ev));
|
||||||
|
|
||||||
foreach( var cxid in cxids) {
|
foreach (var cxid in cxids)
|
||||||
|
{
|
||||||
var hubClient = hubContext.Clients.User(cxid);
|
var hubClient = hubContext.Clients.User(cxid);
|
||||||
var data = new Dictionary<string, object>();
|
var data = new Dictionary<string, object>();
|
||||||
data["event"] = ev;
|
data["event"] = ev;
|
||||||
|
|
@ -132,7 +140,8 @@ namespace Yavsc.Services
|
||||||
response.results = results.ToArray();
|
response.results = results.ToArray();
|
||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
catch (Exception ex) {
|
catch (Exception ex)
|
||||||
|
{
|
||||||
_logger.LogError("Quelque chose s'est mal passé à l'envoi: " + ex.Message);
|
_logger.LogError("Quelque chose s'est mal passé à l'envoi: " + ex.Message);
|
||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue