Ejemplo n.º 1
0
        public static async Task AddToPendingSubscriptionQueueAsync(OneDriveNotification notification)
        {
            QueryStringBuilder qsb = new QueryStringBuilder {
                StartCharacter = null
            };

            qsb.Add("id", notification.UserId);

            CloudQueueMessage message = new CloudQueueMessage(qsb.ToString());
            await SubscriptionQueue.AddMessageAsync(message);
        }
        public async Task <IHttpActionResult> CreateTestWebhook()
        {
            var cookies = Request.Headers.GetCookies("session").FirstOrDefault();

            if (cookies == null)
            {
                return(JsonResponseEx.Create(HttpStatusCode.Unauthorized, new { message = "Session cookie is missing." }));
            }
            var sessionCookieValue = cookies["session"].Values;
            var account            = await AuthorizationController.AccountFromCookie(sessionCookieValue, false);

            if (null == account)
            {
                return(JsonResponseEx.Create(HttpStatusCode.Unauthorized, new { message = "Failed to locate an account for the auth cookie." }));
            }

            OneDriveNotification notification = new OneDriveNotification {
                UserId = account.Id
            };
            await AzureStorage.AddToPendingSubscriptionQueueAsync(notification);

            return(Ok());
        }