diff --git a/src/Yavsc.Abstract/IT/BugReport.cs b/src/Yavsc.Abstract/IT/BugReport.cs new file mode 100644 index 00000000..51da68d1 --- /dev/null +++ b/src/Yavsc.Abstract/IT/BugReport.cs @@ -0,0 +1,14 @@ +using System.ComponentModel.DataAnnotations; + +namespace Yavsc.ApiControllers +{ + public class BugReport { + [Required] + public string ApiKey { get ; set; } + [Required] + public string Component { get ; set; } + [Required][StringLength(1024)] + public string ExceptionObjectJson { get ; set; } + } +} + diff --git a/src/Yavsc.Server/NotificationTypes.cs b/src/Yavsc.Server/NotificationTypes.cs index d3e8d02c..94568868 100644 --- a/src/Yavsc.Server/NotificationTypes.cs +++ b/src/Yavsc.Server/NotificationTypes.cs @@ -9,5 +9,7 @@ namespace Yavsc public const string PrivateMessageDenied = "deniedpv"; public const string Error = "error"; + + public const string BookQuery = "bookQuery"; } } diff --git a/src/Yavsc/Services/YavscMessageSender.cs b/src/Yavsc/Services/YavscMessageSender.cs index dd39b380..3100d765 100644 --- a/src/Yavsc/Services/YavscMessageSender.cs +++ b/src/Yavsc/Services/YavscMessageSender.cs @@ -57,42 +57,47 @@ namespace Yavsc.Services throw new Exception("No dest id"); try { - _logger.LogInformation($"Sending to {string.Join(" ",raa)} using signalR : "+JsonConvert.SerializeObject(ev)); List results = new List(); foreach(var clientId in raa) { MessageWithPayloadResponse.Result result = new MessageWithPayloadResponse.Result(); result.registration_id = clientId; + var user = _dbContext.Users.FirstOrDefault(u=> u.Id == clientId); + if (user==null) + { + response.failure++; + result.error = "no such user."; + continue; + } + if (!user.EmailConfirmed){ + response.failure++; + result.error = "user has not confirmed his email address."; + continue; + } + if (user.Email==null){ + response.failure++; + result.error = "user has no legacy email address."; + continue; + } + + var body = ev.CreateBody(); + + + var hubClient = hubContext.Clients.User(clientId); if (hubClient == null) { - var user = _dbContext.Users.FirstOrDefault(u=> u.Id == clientId); - if (user==null) - { - response.failure++; - result.error = "no such user."; - continue; - } - if (!user.EmailConfirmed){ - response.failure++; - result.error = "user has not confirmed his email address."; - continue; - } - var body = ev.CreateBody(); - - var mailSent = await _emailSender.SendEmailAsync( + _logger.LogDebug($"Sending to {user.UserName} <{user.Email}> : {body}"); + var mailSent = await _emailSender.SendEmailAsync( user.UserName, user.Email, - $"{ev.Sender} (un client) vous demande un rendez-vous", - $"{ev.CreateBody()}\r\n" + $"{ev.Sender} (un client) vous demande un rendez-vous", + body+Environment.NewLine ); - var sent = await _emailSender.SendEmailAsync(ev.Sender, user.Email, - ev.Topic, body - ); - if (!sent.Sent) { - result.message_id = sent.MessageId; - result.error = sent.ErrorMessage; + if (!mailSent.Sent) { + result.message_id = mailSent.MessageId; + result.error = mailSent.ErrorMessage; response.failure++; } else @@ -102,8 +107,16 @@ namespace Yavsc.Services } } else { + _logger.LogDebug($"Sending signal to {string.Join(" ",raa)} : "+JsonConvert.SerializeObject(ev)); // we assume that each hub connected client will handle this signal - result.message_id=hubClient.notify(ev); + + hubClient.notify(NotificationTypes.BookQuery, + $"# {ev.Sender} (un client) vous demande un rendez-vous\n"+body); + + result.message_id=MimeKit.Utils.MimeUtils.GenerateMessageId( + siteSettings.Authority + ); + response.success++; } results.Add(result); diff --git a/src/Yavsc/wwwroot/js/chat.js b/src/Yavsc/wwwroot/js/chat.js index 1d8b4adf..5388448b 100644 --- a/src/Yavsc/wwwroot/js/chat.js +++ b/src/Yavsc/wwwroot/js/chat.js @@ -31,7 +31,13 @@ var ChatView = function ($view, full) { + if (!full) throw "not implemented"; + + // build a channel list + var chans = Array(); + var frontRoomName; + var chat = $.connection.chatHub // Create a function that the hub can call back to display messages. chat.client.addMessage = function (name, room, message) { @@ -74,17 +80,18 @@ ) } - var activeRoom; - var activeRoomName; var setActiveRoom = function(room) { - if (activeRoom) { + var frontRoom; + if (frontRoomName!=='') { + frontRoom=$("#vroom_"+frontRoomName); // TODO animate - activeRoom.addClass("hidden"); - $("sel_"+activeRoomName).addClass("btn-primary"); - } - activeRoom=$("#vroom_"+room); - activeRoomName=room; - activeRoom.removeClass("hidden"); + frontRoom.addClass("hidden"); + $("#sel_"+frontRoomName).addClass("btn-primary"); + } + frontRoomName = room; + frontRoom=$("#vroom_"+room); + $("#sel_"+room).removeClass("btn-primary"); + frontRoom.removeClass("hidden"); } var roomlist = $('
'); @@ -94,7 +101,7 @@ var buildRoom = function (room) { - var roomTag = $(""+room+"").addClass("btn").addClass("btn-primary"); + var roomTag = $(""+room+"").addClass("btn"); roomTag.prop("id","sel_"+room) .click(function(){ setActiveRoom(room); @@ -124,9 +131,6 @@ setActiveRoom(room); } - // build a channel list - var chans = Array(); - $view.data("chans").split(",").forEach(function(chan) { buildRoom(chan) });