예제 #1
0
        public async Task UnSubscribeFromPublishEvent(IDialogContext context, LuisResult result)
        {
            var isAuthenticated = await context.IsAuthenticated();

            if (!isAuthenticated)
            {
                context.SetUnauthorizedMessageText(result.Query);
                await context.Forward(new AuthenticationDialog(), this.ResumeAfterAuth, context.MakeMessage(), CancellationToken.None);
            }
            else if (context.IsAdministrator())
            {
                var response = await SitecorePublishAPI.Instance(context.AccessToken()).UnSubscribe();

                NotificationController.UnSubscribeToPublishUpdates(context);

                await context.PostAsync($"Unsubscribed from publish events");
            }
        }
예제 #2
0
        public async Task SmartPublish(IDialogContext context, LuisResult result)
        {
            var isAuthenticated = await context.IsAuthenticated();

            if (!isAuthenticated)
            {
                context.SetUnauthorizedMessageText(result.Query);
                await context.Forward(new AuthenticationDialog(), this.ResumeAfterAuth, context.MakeMessage(), CancellationToken.None);
            }
            else if (context.IsAdministrator())
            {
                var response = await SitecorePublishAPI.Instance(context.AccessToken()).SmartPublish();

                if (!NotificationController.SubscribedPublishConversations.ContainsKey(context.Activity.Conversation.Id))
                {
                    await context.PostAsync($"Alright, you have just started a smart publish on {response.ProducedByInstanceName}");

                    await context.PostAsync("If you would like to receive a notification for publish event just ask me!");
                }
            }
        }