// Token: 0x06000114 RID: 276 RVA: 0x00006EAC File Offset: 0x000050AC
        private static void HandleSmsMessage(MailboxSession session, Item item, MailboxData mailboxData, ConversationIndexTrackingEx indexTrackingEx)
        {
            MessageItem messageItem = item as MessageItem;

            if (messageItem == null)
            {
                SentItemsProcessor.Tracer.TraceDebug(0L, "{0}: the SMS message is not MessageItem", new object[]
                {
                    TraceContext.Get()
                });
                return;
            }
            RecipientCollection recipients = messageItem.Recipients;

            if (recipients.Count == 0)
            {
                return;
            }
            using (SmsRecipientInfoCache smsRecipientInfoCache = SmsRecipientInfoCache.Create(session, SentItemsProcessor.Tracer))
            {
                Dictionary <ConversationIndex, Recipient> dictionary = new Dictionary <ConversationIndex, Recipient>(recipients.Count);
                for (int i = recipients.Count - 1; i >= 0; i--)
                {
                    Recipient   recipient   = recipients[i];
                    Participant participant = recipient.Participant;
                    if (!(participant == null) && !string.IsNullOrEmpty(participant.EmailAddress))
                    {
                        string text = null;
                        if (string.Equals(participant.RoutingType, "MOBILE", StringComparison.OrdinalIgnoreCase))
                        {
                            text = participant.EmailAddress;
                            smsRecipientInfoCache.AddRecipient(participant);
                        }
                        else if (string.Equals(participant.RoutingType, "SMTP", StringComparison.OrdinalIgnoreCase))
                        {
                            ProxyAddress proxyAddress;
                            if (SmtpProxyAddress.TryDeencapsulate(participant.EmailAddress, out proxyAddress) && string.Equals(proxyAddress.PrefixString, "MOBILE", StringComparison.OrdinalIgnoreCase))
                            {
                                text = proxyAddress.AddressString;
                            }
                            smsRecipientInfoCache.AddRecipient(new Participant(participant.DisplayName, text, "MOBILE"));
                        }
                        if (text != null)
                        {
                            ConversationIndex conversationIndex = ConversationIndex.GenerateFromPhoneNumber(text);
                            if (!(conversationIndex == ConversationIndex.Empty))
                            {
                                recipients.RemoveAt(i);
                                if (!dictionary.ContainsKey(conversationIndex))
                                {
                                    dictionary.Add(conversationIndex, recipient);
                                }
                            }
                        }
                    }
                }
                if (recipients.Count > 0)
                {
                    messageItem.Save(SaveMode.ResolveConflicts);
                    messageItem.Load();
                }
                int num = 0;
                foreach (KeyValuePair <ConversationIndex, Recipient> keyValuePair in dictionary)
                {
                    num++;
                    AggregationBySmsItemClassProcessor.ChunkSmsConversation(XSOFactory.Default, session, keyValuePair.Key, indexTrackingEx);
                    if (num < dictionary.Count || recipients.Count > 0)
                    {
                        SentItemsProcessor.CloneSmsItem(session, messageItem, mailboxData, keyValuePair.Value, keyValuePair.Key);
                    }
                    else
                    {
                        recipients.Add(keyValuePair.Value);
                        SentItemsProcessor.SaveSmsItem(messageItem, keyValuePair.Key);
                        messageItem.Load();
                    }
                }
                smsRecipientInfoCache.Commit();
            }
        }