public async Task ProcessWebHookData(FbHookData fbData) { if (fbData == null || !fbData.Entry.Any()) { return; } var changes = fbData.Entry.First().Changes; if (changes == null || !changes.Any()) { return; } if (fbData.Object != "page") { return; } string pageId = fbData.Entry.First().Id; SocialAccount socialAccount = await GetSoicalAccount(pageId); if (socialAccount == null) { return; } foreach (var change in changes) { if (socialAccount != null) { var strategory = _strategyFactory.Create(change); if (strategory != null) { FacebookProcessResult result = null; await UnitOfWorkManager.Run(TransactionScopeOption.RequiresNew, socialAccount.SiteId, async() => { result = await strategory.Process(socialAccount, change); }); if (result != null) { await result.Notify(socialAccount.SiteId); } } } } }
public async Task <FacebookProcessResult> PullTaggedVisitorPosts(SocialAccount account) { var result = new FacebookProcessResult(_notificationManager); if (!account.IfConvertVisitorPostToConversation) { return(result); } _account = account; var data = await _fbClient.GetTaggedVisitorPosts(_account.SocialUser.OriginalId, _account.Token); await Init(data); RemoveDuplicated(); await AddPosts(result, PostsToBeCreated); await AddComments(result, CommentsToBeCreated); await AddReplyComments(result, ReplyCommentsToBeCretaed); await result.Notify(account.SiteId); return(result); }