Пример #1
0
        private static void CheckArticleInSelfThread(IResource article)
        {
            IResource from = article.GetLinkProp(Core.ContactManager.Props.LinkFrom);

            if (from != null && from.HasProp(Core.ContactManager.Props.Myself))
            {
                article.SetProp(NntpPlugin._propIsSelfThread, true);
            }
            else
            {
                IResource root;
                bool      hasProp = ConversationBuilder.CheckPropOnParents(article,
                                                                           NntpPlugin._propIsSelfThread,
                                                                           out root);
                if (hasProp)
                {
                    article.SetProp(NntpPlugin._propIsSelfThread, true);

                    //  We have not only to set property for this article, but
                    //  also check downwards the thread because it is possible
                    //  for replies to be downloaded before the source article.

                    IResourceList thread = ConversationBuilder.UnrollConversation(article);
                    foreach (IResource res in thread)
                    {
                        res.SetProp(NntpPlugin._propIsSelfThread, true);
                    }
                }
            }
        }
Пример #2
0
        /// <summary>
        /// When new article comes check whether it is linked to the thread
        /// which was paused for updates. In such case, simply delete the
        /// article (non-permanently, through registered IResourceDeleter).
        /// </summary>
        private static void CheckArticleInIgnoredThreads(IResource article)
        {
            IResource root;
            bool      ignore = ConversationBuilder.CheckPropOnParents(article,
                                                                      NntpPlugin._propIsIgnoredThread,
                                                                      out root);

            if (ignore)
            {
                //  We have not only to delete this article, but also check
                //  downwards the thread because it is possible for replies
                //  to be downloaded before the source article.

                IResourceDeleter deleter = Core.PluginLoader.GetResourceDeleter(article.Type);
                deleter.DeleteResource(article);

                DateTime      ignoreStartDate = root.GetDateProp(NntpPlugin._propThreadVisibilityToggleDate);
                IResourceList thread          = ConversationBuilder.UnrollConversation(article);
                foreach (IResource res in thread)
                {
                    DateTime dateTime = res.GetDateProp(Core.Props.Date);
                    if (!res.HasProp(Core.Props.IsDeleted) && dateTime > ignoreStartDate)
                    {
                        deleter.UndeleteResource(res);
                    }
                }
            }
        }