예제 #1
0
        private static FeedItemSharedStory TryCreateSharedStoryFromLink(DateTimeOffset timestamp, Link link)
        {
            if (string.IsNullOrEmpty(link.url) || string.IsNullOrEmpty(link.title) && string.IsNullOrEmpty(link.description))
            {
                return(null);
            }
            FeedItemSharedStory feedItemSharedStory1 = new FeedItemSharedStory();
            string url1 = link.url;

            feedItemSharedStory1.DefaultTarget = url1;
            FeedItemSharedStory feedItemSharedStory2 = feedItemSharedStory1;

            feedItemSharedStory2.Content.Title   = link.title;
            feedItemSharedStory2.Content.Message = link.description;
            feedItemSharedStory2.Content.Target  = link.url;
            Photo photo = link.photo;

            if (photo != null && !string.IsNullOrEmpty(photo.src))
            {
                FeedMediaThumbnail feedMediaThumbnail1 = new FeedMediaThumbnail();
                string             src = photo.src;
                feedMediaThumbnail1.ImageUrl = src;
                string url2 = link.url;
                feedMediaThumbnail1.Target = url2;
                FeedMediaThumbnail feedMediaThumbnail2 = feedMediaThumbnail1;
                feedItemSharedStory2.Thumbnail = feedMediaThumbnail2;
            }
            feedItemSharedStory2.Timestamp = timestamp;
            return(feedItemSharedStory2);
        }
예제 #2
0
 private void ProcessAttachmentsIntoFeedItem(WallPost wallPost, FeedItem feedItem, string secContentTitle = null, string secContentMessage = null, string photosMode = "PhotosByIds")
 {
     if (secContentTitle == null && secContentMessage == null)
     {
         secContentTitle   = SocialDataManager.FormatSecondaryContentTitle(wallPost.attachments, wallPost.geo);
         secContentMessage = SocialDataManager.FormatSecondaryContentMessage(wallPost.attachments, wallPost.geo);
     }
     if (wallPost.attachments != null)
     {
         List <Photo> list = wallPost.attachments.Where <Attachment>((Func <Attachment, bool>)(a => a.photo != null)).Select <Attachment, Photo>((Func <Attachment, Photo>)(a => a.photo)).ToList <Photo>();
         string       str1 = CacheManager.TrySerializeToString((IBinarySerializable) new PhotosList()
         {
             Photos = list
         }).ForURL();
         foreach (Attachment attachment in wallPost.attachments)
         {
             if (attachment.photo != null)
             {
                 FeedMediaThumbnail feedMediaThumbnail = new FeedMediaThumbnail();
                 feedMediaThumbnail.ImageUrl = attachment.photo.src_big;
                 string str2 = string.Format("/default?Action=ShowPhotos&ViewerMode={0}&PhotosCount={1}&SelectedPhotoIndex={2}&Photos={3}&HideLayout=True", (object)photosMode, (object)list.Count, (object)((ICollection <FeedMediaThumbnail>)feedItem.Thumbnails).Count, (object)str1);
                 feedMediaThumbnail.Target = str2;
                 if (((ICollection <FeedMediaThumbnail>)feedItem.Thumbnails).Count < 3)
                 {
                     ((ICollection <FeedMediaThumbnail>)feedItem.Thumbnails).Add(feedMediaThumbnail);
                 }
             }
             if (attachment.link != null)
             {
                 FeedItemSharedStory sharedStoryFromLink = SocialDataManager.TryCreateSharedStoryFromLink(feedItem.Timestamp, attachment.link);
                 if (sharedStoryFromLink != null)
                 {
                     feedItem.SharedStory = sharedStoryFromLink;
                 }
             }
             if (attachment.Page != null)
             {
                 FeedItemSharedStory sharedStoryFromPage = this.TryCreateSharedStoryFromPage(feedItem.Timestamp, attachment.Page);
                 if (sharedStoryFromPage != null)
                 {
                     feedItem.SharedStory = sharedStoryFromPage;
                 }
             }
         }
     }
     if (string.IsNullOrEmpty(secContentTitle) || string.IsNullOrEmpty(secContentMessage))
     {
         return;
     }
     feedItem.SecondaryContent.Title   = secContentTitle;
     feedItem.SecondaryContent.Message = secContentMessage;
 }
예제 #3
0
        private FeedItemSharedStory TryCreateSharedStoryFromPage(DateTimeOffset timestamp, Wiki wiki)
        {
            FeedItemSharedStory feedItemSharedStory = new FeedItemSharedStory();

            feedItemSharedStory.Content.Title   = BaseResources.WikiPage;
            feedItemSharedStory.Content.Message = wiki.title;
            string str1 = string.Format("https://vk.com/club{0}?w=page-{0}_{1}", (object)wiki.gid, (object)wiki.pid);

            feedItemSharedStory.Content.Target = str1;
            string str2 = str1;

            feedItemSharedStory.DefaultTarget = str2;
            DateTimeOffset dateTimeOffset = timestamp;

            feedItemSharedStory.Timestamp = dateTimeOffset;
            return(feedItemSharedStory);
        }
예제 #4
0
        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);
        }