private static byte[] CalculateConversationCreatorSid(ConversationCreatorHelper.ConversationCreatorDefinitionData definitionData, ConversationCreatorHelper.MessageDeliveryScenario messageDeliveryScenario, byte[] itemOwnerSID)
        {
            if (messageDeliveryScenario == ConversationCreatorHelper.MessageDeliveryScenario.DeliveringRootMessage || messageDeliveryScenario == ConversationCreatorHelper.MessageDeliveryScenario.Unknown)
            {
                return(itemOwnerSID);
            }
            Conversation conversation = definitionData.Conversation;

            return(conversation.ConversationCreatorSID);
        }
 private static bool TryCalculateConversationCreatorSid(MailboxSession mailboxSession, ICorePropertyBag itemPropertyBag, ConversationIndex.FixupStage fixupStage, ConversationIndex conversationIndex, byte[] itemOwnerSID, out byte[] conversationCreatorSid, out bool updateAllConversationMessages)
 {
     ConversationCreatorHelper.ConversationCreatorDefinitionData definitionData          = new ConversationCreatorHelper.ConversationCreatorDefinitionData(mailboxSession, conversationIndex);
     ConversationCreatorHelper.MessageDeliveryScenario           messageDeliveryScenario = ConversationCreatorHelper.CalculateConversationDeliveryScenario(definitionData, itemPropertyBag, fixupStage);
     return(ConversationCreatorHelper.TryCalculateConversationCreatorSid(definitionData, messageDeliveryScenario, itemOwnerSID, out conversationCreatorSid, out updateAllConversationMessages));
 }
        private static bool TryCalculateConversationCreatorSid(ConversationCreatorHelper.ConversationCreatorDefinitionData definitionData, ConversationCreatorHelper.MessageDeliveryScenario messageDeliveryScenario, byte[] itemOwnerSID, out byte[] conversationCreatorSid, out bool updateAllConversationMessages)
        {
            updateAllConversationMessages = false;
            if (messageDeliveryScenario == ConversationCreatorHelper.MessageDeliveryScenario.DeliveringRootMessage || messageDeliveryScenario == ConversationCreatorHelper.MessageDeliveryScenario.Unknown)
            {
                conversationCreatorSid = itemOwnerSID;
                return(true);
            }
            if (messageDeliveryScenario == ConversationCreatorHelper.MessageDeliveryScenario.DeliveringOutOfOrderRootMessage)
            {
                conversationCreatorSid        = itemOwnerSID;
                updateAllConversationMessages = true;
                return(true);
            }
            Conversation conversation = definitionData.Conversation;

            conversationCreatorSid = conversation.ConversationCreatorSID;
            if (conversationCreatorSid == null)
            {
                IConversationTreeNode rootMessageNode = definitionData.Conversation.ConversationTree.RootMessageNode;
                if (rootMessageNode == null)
                {
                    return(false);
                }
                ExTraceGlobals.StorageTracer.TraceDebug <string>(0L, "ConversationCreatorHelper::TryCalculateConversationCreatorSid : Probably the conversation was created before we started tracking the ConversationCreatorSID or the conversation was created from a message sent by X-Prem user. ConversationID:{0}", conversation.ConversationId.ToString());
                conversationCreatorSid        = rootMessageNode.GetValueOrDefault <byte[]>(InternalSchema.SenderSID, null);
                updateAllConversationMessages = (conversationCreatorSid != null);
            }
            return(conversationCreatorSid != null);
        }