private async Task SendMessage(Message message, List <FileModel> attachments, Guid stamp) { var dto = Dto.CreateMessage(message, attachments); var ack = Dto.CreateMessageAck(message, stamp); await Task.WhenAll( Clients.OthersInGroup($"R{message.RoomId}").SendAsync("NewMessage", dto), Clients.Caller.SendAsync("MessageAck", ack) ); }
public async Task <ActionResult <RoomMessagesResponse> > GetMessages([FromRoute] Guid id, [FromQuery] DateTime?before = null) { var user = await userManager.GetUserAsyncOrFail(User); if (!await roomService.InRoom(user, id)) { return(Forbid()); } var messages = (await messageService.GetMessages(id, beforeUtc: before)) .Select(m => { return(Dto.CreateMessage(m, m.MessageAttachments.Select(a => a.FileModel).ToList())); }) .ToList(); return(new RoomMessagesResponse { Messages = messages }); }