Example #1
0
        public async Task <ActionResult> Logout(LoginParameters p)
        {
            await p.InitValidate(HttpContext).ConfigureAwait(false);

            p.Logout(true);
            HttpContext.Response.Headers.Add("Location", "/");
            return(StatusCode(StatusCodes.Status303SeeOther));
        }
Example #2
0
        public async Task <ActionResult> OnGetAsync()
        {
            var sw          = Stopwatch.StartNew();
            var RetweetTask = DB.SourceTweetRT(TweetId);

            Params = new LoginParameters();
            await Params.InitValidate(HttpContext).ConfigureAwait(false);

            //RTなら元ツイートにリダイレクトする
            await RetweetTask.ConfigureAwait(false);

            if (RetweetTask.Result.HasValue)
            {
                return(LocalRedirectPermanent("/tweet/" + RetweetTask.Result.Value.ToString() + (More ? "/more" : "")));
            }

            if (More)
            {
                Tweets = await DB.SimilarMediaTweet(TweetId, Params.ID, 99).ConfigureAwait(false);
            }
            else
            {
                Tweets = await DB.SimilarMediaTweet(TweetId, Params.ID).ConfigureAwait(false);
            }

            if (Tweets.Length == 0)
            {
                HttpContext.Response.StatusCode = StatusCodes.Status404NotFound;
            }
            else
            {
                //CanonicalTweetIdを探す
                var OldestIds = Tweets.Where(t =>
                {
                    var oldestSimilar = t.Similars.FirstOrDefault();
                    return(oldestSimilar != null && oldestSimilar.tweet.created_at < t.tweet.created_at);
                }).Select(t => t.Similars.First().tweet.tweet_id)
                                .ToArray();
                if (OldestIds.Length == Tweets.Length)
                {
                    long OldestId = OldestIds[0];
                    if (OldestIds.All(id => id == OldestId))
                    {
                        CanonicalTweetId = OldestId;
                    }
                }
            }
            QueryElapsedMilliseconds = sw.ElapsedMilliseconds;
            return(Page());
        }
Example #3
0
        public async Task <ActionResult> Wait()
        {
            var Params = new LoginParameters();
            await Params.InitValidate(HttpContext).ConfigureAwait(false);

            if (Params.ID.HasValue)
            {
                await CrawlManager.WhenCrawled(Params.ID.Value).ConfigureAwait(false);

                HttpContext.Response.Headers.Add("Location", "/users/" + Params.ID.Value.ToString());
                return(StatusCode(StatusCodes.Status303SeeOther));
            }
            else
            {
                HttpContext.Response.Headers.Add("Location", "/");
                return(StatusCode(StatusCodes.Status303SeeOther));
            }
        }