private async Task CreateCommentItem()

in Facebook/FacebookSDK/JobProcessorFB.cs [223:265]


        private async Task<Item> CreateCommentItem(CommentDataFB comment, string pageId, Item postItem, ConnectorTask taskInfo, List<ItemMetadata> itemMetadata)
        {
            Item commentItem = new Item()
            {
                SchemaVersion = new Version(1, 0),
                Id = comment.Id,
                ContainerId = pageId,
                ContainerName = postItem.ContainerName,
                SourceType = "Facebook",
                ItemType = "Comment",
                ContentType = ContentType.Text,
                Content = comment.Message,
                ParentId = postItem.Id,
                ThreadId = postItem.Id,
                SentTimeUtc = DateTime.Parse(comment.CreatedTime),
                Sender = ToItemUser(comment.From),
                NumOfLikes = comment.LikeCount,
                MessagePreviewText = postItem.Content,
                Recipients = Array.Empty<User>(),
                PreContext = new List<Item>() { postItem },
            };

            if (comment.Attachment != null)
            {
                commentItem.ContentAttachments = new List<ContentAttachment>();
                string attachmentType = comment.Attachment.Type;
                string downloadedContent = await this.downloader.DownloadFileAsBase64EncodedString(comment.Attachment.Media?.Image?.Src);

                ContentAttachment attachment = new ContentAttachment()
                {
                    AttachmentFileName = attachmentType.Contains("share") ? "safe_image.jpg" : FetchNameFromUri(attachmentType.Contains("video") ? comment.Attachment.Media?.Source : comment.Attachment.Media?.Image?.Src),
                    AttachmentType = attachmentType,
                    Content = downloadedContent,
                    Uri = new Uri(attachmentType.Contains("video") ? comment.Attachment.Url : comment.Attachment.Media?.Image?.Src),
                };

                commentItem.ContentAttachments.Add(attachment);
            }

            string fileName = await uploader.UploadItem(taskInfo.JobId, taskInfo.TaskId, commentItem);
            itemMetadata.Add(new ItemMetadata(commentItem.Id, commentItem.SentTimeUtc, fileName));
            return commentItem;
        }