public System.Threading.Tasks.Task <notifyResponse> notifyAsync(NotificationDelivery notify)
        {
            notifyRequest inValue = new notifyRequest();

            inValue.notify = notify;
            return(((ServicePortv3)(this)).notifyAsync(inValue));
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="SentNotificationsController"/> class.
 /// </summary>
 /// <param name="notificationDataRepository">Notification data repository service that deals with the table storage in azure.</param>
 /// <param name="notificationDelivery">Notification delivery service instance.</param>
 /// <param name="teamDataRepository">Team data repository instance.</param>
 public SentNotificationsController(
     NotificationDataRepository notificationDataRepository,
     NotificationDelivery notificationDelivery,
     TeamDataRepository teamDataRepository)
 {
     this.notificationDataRepository = notificationDataRepository;
     this.notificationDelivery       = notificationDelivery;
     this.teamDataRepository         = teamDataRepository;
 }
예제 #3
0
        private string GetEmailHtmlSignature(NotificationDelivery delivery)
        {
            /* Email signature is disabled from 2018.02.11 */
            return("");

            /*
             *      var courseId = delivery.Notification.CourseId;
             *      var courseTitle = courseManager.GetCourse(courseId).Title;
             *      return GetEmailHtmlSignature(delivery.NotificationTransportId, delivery.Notification.GetNotificationType(), courseId, courseTitle);
             */
        }
예제 #4
0
        public async Task Send(NotificationDelivery notificationDelivery)
        {
            var transport = notificationDelivery.NotificationTransport;

            metricSender.SendCount($"send_notification.{notificationDelivery.Notification.GetNotificationType()}");

            if (transport is MailNotificationTransport || transport is TelegramNotificationTransport)
            {
                await Send((dynamic)transport, notificationDelivery);
            }
        }
예제 #5
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ChatNotificationsController"/> class.
 /// </summary>
 /// <param name="notificationDataRepository">Notification data repository instance.</param>
 /// <param name="teamDataRepository">Team data repository instance.</param>
 /// <param name="notificationDelivery">TODO</param>
 /// <param name="draftNotificationPreviewService">Draft notification preview service.</param>
 public ChatNotificationsController(
     NotificationDataRepository notificationDataRepository,
     TeamDataRepository teamDataRepository,
     NotificationDelivery notificationDelivery,
     DraftNotificationPreviewService draftNotificationPreviewService)
 {
     this.notificationDataRepository      = notificationDataRepository;
     this.teamDataRepository              = teamDataRepository;
     this.notificationDelivery            = notificationDelivery;
     this.draftNotificationPreviewService = draftNotificationPreviewService;
 }
    public async static void DequeueTask(object state)
    {
        CancellationToken token = (CancellationToken)state;

        while (!token.IsCancellationRequested)
        {
            if (dequeueSignal.WaitOne())             // block untill we have items in the queue
            {
                NotificationDelivery delivery = null;

                if (deliveryQueue.TryDequeue(out delivery))
                {
                    NotificationDeliveryStatus ns = NotificationDeliveryStatus.Pending;
                    if (delivery.Subscription.Status == SubscriptionStatus.Subscribed)
                    {
                        PushResult result = await PushService.DoPushAsync(delivery);

                        switch (result)
                        {
                        case PushResult.Pushed:
                            ns = NotificationDeliveryStatus.Delivered;
                            break;

                        case PushResult.Error:
                            ns = NotificationDeliveryStatus.FailureError;
                            break;

                        case PushResult.NotSupported:
                            ns = NotificationDeliveryStatus.FailureNotSupported;
                            break;

                        case PushResult.UnSubscribed:
                            ns = NotificationDeliveryStatus.FailureUnSubscribed;
                            delivery.Subscription.Status = SubscriptionStatus.UnSubscribed;
                            break;
                        }
                    }
                    else
                    {
                        ns = NotificationDeliveryStatus.FailureUnSubscribed;
                    }

                    delivery.Status      = ns;
                    delivery.DeliveredAt = DateTime.Now;
                }
                else
                {
                    // empty queue, no more items
                    // stop dequeueing untill new items added by EnqueueTask
                    dequeueSignal.Reset();
                }
            }
        }
    }
예제 #7
0
        private async Task Send(TelegramNotificationTransport transport, NotificationDelivery notificationDelivery)
        {
            if (!transport.User.TelegramChatId.HasValue)
            {
                return;
            }

            var notification = notificationDelivery.Notification;
            var course       = await courseManager.GetCourseAsync(notification.CourseId);

            var notificationButton = notification.GetNotificationButton(transport, notificationDelivery, course, baseUrl);

            await telegramSender.SendMessageAsync(
                transport.User.TelegramChatId.Value,
                notification.GetHtmlMessageForDelivery(transport, notificationDelivery, course, baseUrl),
                button : notificationButton != null?new TelegramButton(notificationButton) : null
                );
        }
예제 #8
0
        private async Task Send(MailNotificationTransport transport, NotificationDelivery notificationDelivery)
        {
            if (string.IsNullOrEmpty(transport.User.Email))
            {
                return;
            }

            var notification = notificationDelivery.Notification;
            var course       = await courseManager.GetCourseAsync(notification.CourseId);

            var notificationButton = notification.GetNotificationButton(transport, notificationDelivery, course, baseUrl);
            var htmlMessage        = notification.GetHtmlMessageForDelivery(transport, notificationDelivery, course, baseUrl);
            var textMessage        = notification.GetTextMessageForDelivery(transport, notificationDelivery, course, baseUrl);
            await emailSender.SendEmailAsync(
                transport.User.Email,
                notification.GetNotificationType().GetDisplayName(),
                textMessage,
                "<p>" + htmlMessage + "</p>",
                button : notificationButton != null?new EmailButton(notificationButton) : null,
                textContentAfterButton : GetEmailTextSignature(),
                htmlContentAfterButton : GetEmailHtmlSignature(notificationDelivery)
                );
        }
예제 #9
0
 public Task MarkDeliveryAsFailed(NotificationDelivery delivery)
 {
     return(MarkDeliveriesAsFailed(new List <NotificationDelivery> {
         delivery
     }));
 }
예제 #10
0
 public async Task MarkDeliveryAsFailed(NotificationDelivery delivery)
 {
     await MarkDeliveriesAsFailed(new List <NotificationDelivery> {
         delivery
     });
 }