notify using signal, and only email as fallback
Fixes chat room selector in web interface,
This commit is contained in:
parent
8414ab7ab3
commit
6b8180edde
4 changed files with 71 additions and 38 deletions
14
src/Yavsc.Abstract/IT/BugReport.cs
Normal file
14
src/Yavsc.Abstract/IT/BugReport.cs
Normal file
|
|
@ -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; }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
@ -9,5 +9,7 @@ namespace Yavsc
|
||||||
public const string PrivateMessageDenied = "deniedpv";
|
public const string PrivateMessageDenied = "deniedpv";
|
||||||
|
|
||||||
public const string Error = "error";
|
public const string Error = "error";
|
||||||
|
|
||||||
|
public const string BookQuery = "bookQuery";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -57,42 +57,47 @@ namespace Yavsc.Services
|
||||||
throw new Exception("No dest id");
|
throw new Exception("No dest id");
|
||||||
|
|
||||||
try {
|
try {
|
||||||
_logger.LogInformation($"Sending to {string.Join(" ",raa)} using signalR : "+JsonConvert.SerializeObject(ev));
|
|
||||||
List<MessageWithPayloadResponse.Result> results = new List<MessageWithPayloadResponse.Result>();
|
List<MessageWithPayloadResponse.Result> results = new List<MessageWithPayloadResponse.Result>();
|
||||||
foreach(var clientId in raa) {
|
foreach(var clientId in raa) {
|
||||||
MessageWithPayloadResponse.Result result = new MessageWithPayloadResponse.Result();
|
MessageWithPayloadResponse.Result result = new MessageWithPayloadResponse.Result();
|
||||||
result.registration_id = clientId;
|
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);
|
var hubClient = hubContext.Clients.User(clientId);
|
||||||
if (hubClient == null)
|
if (hubClient == null)
|
||||||
{
|
{
|
||||||
var user = _dbContext.Users.FirstOrDefault(u=> u.Id == clientId);
|
_logger.LogDebug($"Sending to {user.UserName} <{user.Email}> : {body}");
|
||||||
if (user==null)
|
var mailSent = await _emailSender.SendEmailAsync(
|
||||||
{
|
|
||||||
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(
|
|
||||||
user.UserName,
|
user.UserName,
|
||||||
user.Email,
|
user.Email,
|
||||||
$"{ev.Sender} (un client) vous demande un rendez-vous",
|
$"{ev.Sender} (un client) vous demande un rendez-vous",
|
||||||
$"{ev.CreateBody()}\r\n"
|
body+Environment.NewLine
|
||||||
);
|
);
|
||||||
|
|
||||||
var sent = await _emailSender.SendEmailAsync(ev.Sender, user.Email,
|
if (!mailSent.Sent) {
|
||||||
ev.Topic, body
|
result.message_id = mailSent.MessageId;
|
||||||
);
|
result.error = mailSent.ErrorMessage;
|
||||||
if (!sent.Sent) {
|
|
||||||
result.message_id = sent.MessageId;
|
|
||||||
result.error = sent.ErrorMessage;
|
|
||||||
response.failure++;
|
response.failure++;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
@ -102,8 +107,16 @@ namespace Yavsc.Services
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
_logger.LogDebug($"Sending signal to {string.Join(" ",raa)} : "+JsonConvert.SerializeObject(ev));
|
||||||
// we assume that each hub connected client will handle this signal
|
// 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++;
|
response.success++;
|
||||||
}
|
}
|
||||||
results.Add(result);
|
results.Add(result);
|
||||||
|
|
|
||||||
|
|
@ -31,7 +31,13 @@
|
||||||
var ChatView = function ($view, full)
|
var ChatView = function ($view, full)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
if (!full) throw "not implemented";
|
if (!full) throw "not implemented";
|
||||||
|
|
||||||
|
// build a channel list
|
||||||
|
var chans = Array();
|
||||||
|
var frontRoomName;
|
||||||
|
|
||||||
var chat = $.connection.chatHub
|
var chat = $.connection.chatHub
|
||||||
// Create a function that the hub can call back to display messages.
|
// Create a function that the hub can call back to display messages.
|
||||||
chat.client.addMessage = function (name, room, message) {
|
chat.client.addMessage = function (name, room, message) {
|
||||||
|
|
@ -74,17 +80,18 @@
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
var activeRoom;
|
|
||||||
var activeRoomName;
|
|
||||||
var setActiveRoom = function(room) {
|
var setActiveRoom = function(room) {
|
||||||
if (activeRoom) {
|
var frontRoom;
|
||||||
|
if (frontRoomName!=='') {
|
||||||
|
frontRoom=$("#vroom_"+frontRoomName);
|
||||||
// TODO animate
|
// TODO animate
|
||||||
activeRoom.addClass("hidden");
|
frontRoom.addClass("hidden");
|
||||||
$("sel_"+activeRoomName).addClass("btn-primary");
|
$("#sel_"+frontRoomName).addClass("btn-primary");
|
||||||
}
|
}
|
||||||
activeRoom=$("#vroom_"+room);
|
frontRoomName = room;
|
||||||
activeRoomName=room;
|
frontRoom=$("#vroom_"+room);
|
||||||
activeRoom.removeClass("hidden");
|
$("#sel_"+room).removeClass("btn-primary");
|
||||||
|
frontRoom.removeClass("hidden");
|
||||||
}
|
}
|
||||||
|
|
||||||
var roomlist = $('<div class="roomlist"></div>');
|
var roomlist = $('<div class="roomlist"></div>');
|
||||||
|
|
@ -94,7 +101,7 @@
|
||||||
|
|
||||||
var buildRoom = function (room)
|
var buildRoom = function (room)
|
||||||
{
|
{
|
||||||
var roomTag = $("<a>"+room+"</a>").addClass("btn").addClass("btn-primary");
|
var roomTag = $("<a>"+room+"</a>").addClass("btn");
|
||||||
roomTag.prop("id","sel_"+room)
|
roomTag.prop("id","sel_"+room)
|
||||||
.click(function(){
|
.click(function(){
|
||||||
setActiveRoom(room);
|
setActiveRoom(room);
|
||||||
|
|
@ -124,9 +131,6 @@
|
||||||
setActiveRoom(room);
|
setActiveRoom(room);
|
||||||
}
|
}
|
||||||
|
|
||||||
// build a channel list
|
|
||||||
var chans = Array();
|
|
||||||
|
|
||||||
$view.data("chans").split(",").forEach(function(chan) {
|
$view.data("chans").split(",").forEach(function(chan) {
|
||||||
buildRoom(chan)
|
buildRoom(chan)
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue