private async Task CreateReplyItem()

in Facebook/FacebookSDK/JobProcessorFB.cs [267:308]


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

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

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

                replyItem.ContentAttachments.Add(attachment);
            }

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