Exemple #1
0
        private string GetHighlightedText()
        {
            WallPost parsedParent1 = this._notification.ParsedParent as WallPost;

            if (parsedParent1 != null)
            {
                if (!string.IsNullOrEmpty(parsedParent1.text))
                {
                    return(this.CutText(parsedParent1.text));
                }
                if (parsedParent1.IsRepost())
                {
                    return(this.CutText(parsedParent1.copy_history[0].text));
                }
                return("");
            }
            Comment parsedParent2 = this._notification.ParsedParent as Comment;

            if (parsedParent2 != null)
            {
                return(this.CutText(parsedParent2.text ?? ""));
            }
            Topic parsedParent3 = this._notification.ParsedParent as Topic;

            if (parsedParent3 != null)
            {
                return(this.CutText(parsedParent3.title ?? ""));
            }
            return("");
        }
        private string GetHighlightedText()
        {
            WallPost wallPost = this._notification.ParsedParent as WallPost;

            if (wallPost != null)
            {
                if (!string.IsNullOrEmpty(wallPost.text))
                {
                    return(this.CutText(wallPost.text));
                }
                if (wallPost.IsRepost())
                {
                    return(this.CutText(wallPost.copy_history[0].text));
                }
                return("");
            }
            Comment comment = this._notification.ParsedParent as Comment;

            if (comment != null)
            {
                return(this.CutText(comment.text ?? ""));
            }
            Topic topic = this._notification.ParsedParent as Topic;

            if (topic != null)
            {
                return(this.CutText(topic.title ?? ""));
            }
            return("");
        }
 public static bool CanGoToOriginal(this WallPost wallPost)
 {
     if (!wallPost.IsRepost())
     {
         return(false);
     }
     if (!(wallPost.copy_history[0].post_type == "post"))
     {
         return(wallPost.copy_history[0].post_type == "reply");
     }
     return(true);
 }
        public static bool IsProfilePhotoUpdatePost(this WallPost wallPost, List <User> users, out bool isMale)
        {
            List <Attachment> attachments = wallPost.attachments;

            isMale = true;
            if (attachments != null)
            {
                Attachment attachment = attachments.FirstOrDefault <Attachment>((Func <Attachment, bool>)(a => a.type == "photo"));
                if (attachment != null && attachment.photo != null && (attachment.photo.aid == -6L && wallPost.post_source != null) && wallPost.post_source.data == "profile_photo")
                {
                    User user = !wallPost.IsRepost() ? users.FirstOrDefault <User>((Func <User, bool>)(u => u.uid == wallPost.to_id)) : users.FirstOrDefault <User>((Func <User, bool>)(u => u.uid == wallPost.copy_history[0].owner_id));
                    if (user != null)
                    {
                        if (user.sex == 1)
                        {
                            isMale = false;
                        }
                        return(true);
                    }
                }
            }
            return(false);
        }
        private FeedItem CreateFeedItem(WallPost wallPost, List <Group> groups, List <User> profiles, bool allowFocusComments = true)
        {
            FeedItem feedItem = new FeedItem();
            string   format   = "/default?Action=WallPost&PostId={0}&OwnerId={1}&FocusComments={2}&PollId={3}&PollOwnerId={4}&HideLayout=True";
            long     num1     = 0;
            long     num2     = 0;

            if (wallPost.attachments != null)
            {
                Attachment attachment = wallPost.attachments.FirstOrDefault <Attachment>((Func <Attachment, bool>)(a => a.poll != null));
                if (attachment != null)
                {
                    num1 = attachment.poll.poll_id;
                    num2 = wallPost.IsRepost() ? wallPost.copy_history[0].owner_id : wallPost.to_id;
                }
            }
            feedItem.DefaultTarget = string.Format(format, (object)wallPost.id, (object)wallPost.to_id, allowFocusComments, (object)num1, (object)num2);
            string str1 = string.Format(format, (object)wallPost.id, (object)wallPost.to_id, false, num1, (object)num2);

            feedItem.PrimaryContent.Target   = str1;
            feedItem.SecondaryContent.Target = str1;
            feedItem.Author.DisplayName      = wallPost.GetAuthorDisplayName(groups, profiles);
            Actor  author1         = feedItem.Author;
            long   num3            = wallPost.from_id;
            string uniqueRemoteId1 = RemoteIdHelper.GenerateUniqueRemoteId(num3.ToString(), RemoteIdHelper.RemoteIdItemType.UserOrGroup);

            author1.RemoteId              = uniqueRemoteId1;
            feedItem.ReactionDisplayKind  = (ReactionDisplayKind)2;
            feedItem.ReactionDisplayCount = wallPost.comments == null ? 0 : wallPost.comments.count;
            feedItem.Timestamp            = new DateTimeOffset(ExtensionsBase.UnixTimeStampToDateTime((double)wallPost.date, true));
            feedItem.Style    = FeedItemStyle.Photo;
            feedItem.RemoteId = RemoteIdHelper.GenerateUniqueRemoteId(wallPost.GloballyUniqueId, RemoteIdHelper.RemoteIdItemType.WallPost);
            string secContentTitle   = SocialDataManager.FormatSecondaryContentTitle(wallPost.attachments, wallPost.geo);
            string secContentMessage = SocialDataManager.FormatSecondaryContentMessage(wallPost.attachments, wallPost.geo);

            if (wallPost.IsRepost())
            {
                string str2 = string.Format(format, (object)wallPost.copy_history[0].WallPostOrReplyPostId, (object)wallPost.copy_history[0].owner_id, (object)false, (object)num1, (object)num2);
                if (!string.IsNullOrEmpty(wallPost.text))
                {
                    feedItem.PrimaryContent.Message = TextPreprocessor.PreprocessText(wallPost.text);
                }
                else
                {
                    feedItem.PrimaryContent.Title = wallPost.GetIsMale(profiles) ? BaseResources.SharedPostMale : BaseResources.SharedPostFemale;
                }
                feedItem.ChildItem = new FeedChildItem();
                feedItem.ChildItem.PrimaryContent.Target   = str2;
                feedItem.ChildItem.SecondaryContent.Target = str2;
                bool isMale = false;
                if (wallPost.IsProfilePhotoUpdatePost(profiles, out isMale))
                {
                    feedItem.ChildItem.PrimaryContent.Title = isMale ? BaseResources.Photo_UpdatedProfileMale : BaseResources.Photo_UpdatedProfileFemale;
                }
                feedItem.ChildItem.Timestamp          = feedItem.Timestamp;
                feedItem.ChildItem.Author.DisplayName = wallPost.GetChildAuthorDisplayName(groups, profiles);
                Actor author2 = feedItem.ChildItem.Author;
                num3 = wallPost.GetChildItemFromId();
                string uniqueRemoteId2 = RemoteIdHelper.GenerateUniqueRemoteId(num3.ToString(), RemoteIdHelper.RemoteIdItemType.UserOrGroup);
                author2.RemoteId = uniqueRemoteId2;
                feedItem.ChildItem.DefaultTarget = str2;
                if (!string.IsNullOrWhiteSpace(wallPost.copy_history[0].text))
                {
                    feedItem.ChildItem.PrimaryContent.Message = TextPreprocessor.PreprocessText(wallPost.copy_history[0].text);
                }
                if (wallPost.copy_history[0].attachments != null)
                {
                    List <Attachment> attachments = wallPost.copy_history[0].attachments;
                    List <Photo>      list        = attachments.Where <Attachment>((Func <Attachment, bool>)(a => a.photo != null)).Select <Attachment, Photo>((Func <Attachment, Photo>)(a => a.photo)).ToList <Photo>();
                    string            str3        = CacheManager.TrySerializeToString((IBinarySerializable) new PhotosList()
                    {
                        Photos = list
                    }).ForURL();
                    foreach (Attachment attachment in attachments)
                    {
                        if (attachment.photo != null)
                        {
                            FeedMediaThumbnail feedMediaThumbnail = new FeedMediaThumbnail();
                            feedMediaThumbnail.ImageUrl = attachment.photo.src_big;
                            string str4 = string.Format("/default?Action=ShowPhotos&ViewerMode={0}&PhotosCount={1}&SelectedPhotoIndex={2}&Photos={3}&HideLayout=True", "PhotosByIds", list.Count, ((ICollection <FeedMediaThumbnail>)feedItem.ChildItem.Thumbnails).Count, str3);
                            feedMediaThumbnail.Target = str4;
                            if (((ICollection <FeedMediaThumbnail>)feedItem.ChildItem.Thumbnails).Count < 3)
                            {
                                ((ICollection <FeedMediaThumbnail>)feedItem.ChildItem.Thumbnails).Add(feedMediaThumbnail);
                            }
                        }
                        if (attachment.link != null)
                        {
                            FeedItemSharedStory sharedStoryFromLink = SocialDataManager.TryCreateSharedStoryFromLink(feedItem.Timestamp, attachment.link);
                            if (sharedStoryFromLink != null)
                            {
                                feedItem.ChildItem.SharedStory = sharedStoryFromLink;
                            }
                        }
                        if (attachment.Page != null)
                        {
                            FeedItemSharedStory sharedStoryFromPage = this.TryCreateSharedStoryFromPage(feedItem.Timestamp, attachment.Page);
                            if (sharedStoryFromPage != null)
                            {
                                feedItem.ChildItem.SharedStory = sharedStoryFromPage;
                            }
                        }
                    }
                }
                if (!string.IsNullOrEmpty(secContentTitle) && !string.IsNullOrEmpty(secContentMessage))
                {
                    feedItem.ChildItem.SecondaryContent.Title   = secContentTitle;
                    feedItem.ChildItem.SecondaryContent.Message = secContentMessage;
                }
                if (string.IsNullOrEmpty(feedItem.ChildItem.PrimaryContent.Message) && string.IsNullOrEmpty(feedItem.ChildItem.SecondaryContent.Title) && string.IsNullOrEmpty(feedItem.ChildItem.SecondaryContent.Message))
                {
                    string titleIfNecessary = this.GenerateTitleIfNecessary(wallPost.copy_history[0]);
                    if (!string.IsNullOrEmpty(titleIfNecessary))
                    {
                        feedItem.ChildItem.PrimaryContent.Title = titleIfNecessary;
                    }
                    else
                    {
                        Debugger.Break();
                        feedItem = null;
                    }
                }
            }
            else
            {
                bool isMale = false;
                if (wallPost.text != string.Empty)
                {
                    feedItem.PrimaryContent.Message = TextPreprocessor.PreprocessText(wallPost.text);
                }
                this.ProcessAttachmentsIntoFeedItem(wallPost, feedItem, secContentTitle, secContentMessage, "PhotosByIds");
                if (wallPost.IsProfilePhotoUpdatePost(profiles, out isMale))
                {
                    feedItem.PrimaryContent.Title = isMale ? BaseResources.Photo_UpdatedProfileMale : BaseResources.Photo_UpdatedProfileFemale;
                }
                if (string.IsNullOrEmpty(feedItem.PrimaryContent.Title) && string.IsNullOrEmpty(feedItem.PrimaryContent.Message) && (string.IsNullOrEmpty(feedItem.SecondaryContent.Title) && string.IsNullOrEmpty(feedItem.SecondaryContent.Message)))
                {
                    string titleIfNecessary = this.GenerateTitleIfNecessary(wallPost);
                    if (!string.IsNullOrEmpty(titleIfNecessary))
                    {
                        feedItem.PrimaryContent.Title = titleIfNecessary;
                    }
                    else
                    {
                        Debugger.Break();
                        feedItem = null;
                    }
                }
                if (wallPost.from_id != wallPost.to_id && feedItem != null)
                {
                    feedItem.PrimaryContent.Title = wallPost.GetFromToString(groups, profiles);
                }
            }
            return(feedItem);
        }