示例#1
0
        public async Task AddMessage(string conversationId, string messageId, Message message)
        {
            if (message == null)
            {
                throw new ArgumentNullException(nameof(message));
            }

            if (string.IsNullOrWhiteSpace(conversationId))
            {
                throw new ArgumentNullException(nameof(conversationId));
            }

            if (string.IsNullOrWhiteSpace(messageId))
            {
                throw new ArgumentNullException(nameof(messageId));
            }

            if (string.IsNullOrWhiteSpace(message.SenderUsername))
            {
                throw new ArgumentNullException(nameof(message.SenderUsername));
            }

            // Add the message first
            await messagesStore.AddMessage(conversationId, messageId, message);

            // Then update the conversations modified date for each user
            ConversationEntity conversationEntity = await RetrieveConversationEntity(message.SenderUsername, conversationId);

            var tasks = new List <Task>();

            foreach (var participant in conversationEntity.Participants.Split(ParticipantsSeparator))
            {
                tasks.Add(UpdateConversationModifiedDateForUser(participant, conversationId, message));
            }
            await Task.WhenAll(tasks);
        }
示例#2
0
 public Task AddMessage(string conversationId, string messageId, Message message)
 {
     return(addMessageMetric.TrackTime(() => store.AddMessage(conversationId, messageId, message)));
 }
示例#3
0
 public Task AddMessage(string conversationId, string messageId, Message message)
 {
     return(faultTolerancePolicy.Execute(
                async() => await store.AddMessage(conversationId, messageId, message)
                ));
 }