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); }
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); }
public static bool TryCalculateConversationCreatorSidOnReplying(MailboxSession mailboxSession, ConversationIndex conversationIndex, out byte[] conversationCreatorSid) { conversationCreatorSid = null; if (!ConversationCreatorHelper.SupportsConversationCreator(mailboxSession)) { return(false); } ConversationCreatorHelper.ConversationCreatorDefinitionData definitionData = new ConversationCreatorHelper.ConversationCreatorDefinitionData(mailboxSession, conversationIndex); conversationCreatorSid = ConversationCreatorHelper.CalculateConversationCreatorSid(definitionData, ConversationCreatorHelper.MessageDeliveryScenario.DeliveringNonRootMessage, null); return(conversationCreatorSid != null); }
public static void FixupConversationMessagesCreatorSid(MailboxSession mailboxSession, ConversationIndex conversationIndex, byte[] conversationCreatorSid) { ConversationCreatorHelper.ConversationCreatorDefinitionData conversationCreatorDefinitionData = new ConversationCreatorHelper.ConversationCreatorDefinitionData(mailboxSession, conversationIndex); foreach (IConversationTreeNode conversationTreeNode in conversationCreatorDefinitionData.Conversation.ConversationTree) { ConversationTreeNode conversationTreeNode2 = (ConversationTreeNode)conversationTreeNode; foreach (StoreObjectId storeId in conversationTreeNode2.ToListStoreObjectId()) { using (Item item = Item.Bind(mailboxSession, storeId, null)) { item.OpenAsReadWrite(); item.SetOrDeleteProperty(ItemSchema.ConversationCreatorSID, conversationCreatorSid); item.Save(SaveMode.ResolveConflicts); } } } }
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 ConversationCreatorHelper.MessageDeliveryScenario CalculateConversationDeliveryScenario(ConversationCreatorHelper.ConversationCreatorDefinitionData definitionData, ICorePropertyBag itemPropertyBag, ConversationIndex.FixupStage fixupStage) { if (ConversationIndex.CheckStageValue(fixupStage, ConversationIndex.FixupStage.Error)) { return(ConversationCreatorHelper.MessageDeliveryScenario.Unknown); } if (ConversationIndex.IsFixUpCreatingNewConversation(fixupStage)) { return(ConversationCreatorHelper.MessageDeliveryScenario.DeliveringRootMessage); } if (definitionData.Conversation.RootMessageId == null) { ExTraceGlobals.StorageTracer.TraceDebug <string, string>(0L, "ConversationCreatorHelper::CalculateConversationDeliveryScenario : On some corner cases, the conversation is loaded without nodes and then root node is null. MessageClassConversationID:{0} FixupStage:{1}", definitionData.Conversation.ConversationId.ToString(), fixupStage.ToString()); return(ConversationCreatorHelper.MessageDeliveryScenario.DeliveringRootMessage); } if (ConversationIndex.IsFixupAddingOutOfOrderMessageToConversation(fixupStage) && ConversationCreatorHelper.IsRootMessage(definitionData.Conversation, itemPropertyBag)) { return(ConversationCreatorHelper.MessageDeliveryScenario.DeliveringOutOfOrderRootMessage); } return(ConversationCreatorHelper.MessageDeliveryScenario.Unknown); }