Esempio n. 1
0
 public TweetNotification(RawTweet tweetWithVideo, long requestingTweetId, string requestedBy)
 {
     TweetWithVideo    = tweetWithVideo;
     RequestingTweetId = requestingTweetId;
     Id          = Guid.NewGuid();
     RequestedBy = requestedBy;
 }
Esempio n. 2
0
        public override async Task HandleAsync <T>(ContentRequestNotification notification, ILogger <T> logger)
        {
            RawTweet videoTweet = await twitterRepository.FindByIdAsync(notification.IdOfTweetBeingRepliedTo.Value);

            TweetNotification tweetNotification = new TweetNotification(videoTweet, notification.IdOfRequestingTweet, notification.RequestedBy);

            if (tweetNotification.HasVideo())
            {
                var video   = tweetNotification.GetVideo();
                var request = tweetNotification.GetVideoRequest(video.Id);

                await scraperRepository.CaptureTwitterVideoAndRequestAsync(request, video);

                string response = video.GetResponseContent(settings.BaseUrl, request.RequestedBy);
                //send back response
                await twitterRepository.ReplyToTweetAsync(request.RequestingTweetId, response);

                logger.LogInformation($"Sent back this response -> {response}");
            }
            else
            {
                logger.LogWarning($"The tweet being responded to didn't have a video -> {tweetNotification.TweetWithVideo.id}");
                await base.HandleAsync(notification, logger);
            }
        }
Esempio n. 3
0
        public static ContentRequestNotification CreateRequestNotification(this RawTweet rawTweet)
        {
            var requestNotification = new ContentRequestNotification
            {
                IdOfRequestingTweet     = rawTweet.id,
                IdOfTweetBeingRepliedTo = rawTweet.in_reply_to_status_id,
                RequestedBy             = rawTweet.user.screen_name
            };

            return(requestNotification);
        }
Esempio n. 4
0
        public async Task ProcessTweetAsync(string tweetJsonString)
        {
            Stopwatch stopwatch = new Stopwatch();

            stopwatch.Start();
            //deserialize tweet.
            RawTweet requestingTweet = DeserializeTweet(tweetJsonString);

            ITweetContentHandler handler = handlerFactory.BuildHandlerPipeline();
            var requestNotification      = requestingTweet.CreateRequestNotification();

            await handler.HandleAsync(requestNotification, logger);
        }