public async Task <ActionResult <ChatViewModel> > SendChatMessage([FromRoute] long accountId, [FromBody] ChatInputModel input, CancellationToken cancellationToken) { if (!await _accountFriendManager.IsFriendAsync(AccountId, accountId, cancellationToken)) { return(Forbidden("not_friend", "This user is not a friend of you.")); } var chat = new Chat { SenderAccountId = AccountId, ReceiverAccountId = accountId, MessageText = input.Message, DateTime = DateTime.UtcNow, }; _context.Chats.Add(chat); await _context.SaveChangesAsync(cancellationToken); return(OkData(ChatViewModel.Map(chat))); }