Example #1
0
        public async Task SendMessage(string author, string message)
        {
            var chatMessage = new ChatMessage
            {
                Date            = DateTime.UtcNow,
                Message         = message,
                Source          = ApiSource.Rambler,
                SourceMessageId = Guid.NewGuid().ToString()
            };

            if (!string.IsNullOrWhiteSpace(author))
            {
                chatMessage.Author = await authorService.GetAuthors().SingleOrDefaultAsync(x => x.Name == author);
            }

            if (chatMessage.Author == null)
            {
                chatMessage.Author = await GetOrBuildAuthorFromClaims();
            }

            await chatService.ProcessIncomingMessage(chatMessage);

            await chatService.ProcessOutgoingMessage(chatMessage);
        }