Exemplo n.º 1
0
 public async Task PublishTest(NotificationModel model, Settings settings, INotification type)
 {
     await type.NotifyAsync(model, settings);
 }
Exemplo n.º 2
0
        /// <summary>
        /// Sends a notification to the user, this is usually for testing the settings.
        /// </summary>
        /// <param name="model">The model.</param>
        /// <param name="settings">The settings.</param>
        /// <returns></returns>
        public async Task Publish(NotificationModel model, Settings settings)
        {
            var notificationTasks = Observers.Values.Select(notification => NotifyAsync(notification, model, settings));

            await Task.WhenAll(notificationTasks).ConfigureAwait(false);
        }
Exemplo n.º 3
0
        private async Task PushFaultQueue(NotificationModel model, DiscordNotificationSettings settings)
        {
            var message = $"Hello! The user '{model.User}' has requested {model.Title} but it could not be added. This has been added into the requests queue and will keep retrying";

            await Push(settings, message);
        }
Exemplo n.º 4
0
        public async Task NotifyAsync(NotificationModel model)
        {
            var settings = Settings.GetSettings();

            await NotifyAsync(model, settings);
        }
Exemplo n.º 5
0
        private async Task PushRequestDeclinedAsync(NotificationModel model, DiscordNotificationSettings settings)
        {
            var message = $"Hello! Your request for {model.Title} has been declined, Sorry!";

            await Push(settings, message);
        }
Exemplo n.º 6
0
        private async Task PushIssueAsync(NotificationModel model, DiscordNotificationSettings settings)
        {
            var message = $"A new issue: {model.Body} has been reported by user: {model.User} for the title: {model.Title}";

            await Push(settings, message);
        }
Exemplo n.º 7
0
        public async Task NotifyAsync(NotificationModel model, Settings settings)
        {
            if (settings == null)
            {
                await NotifyAsync(model);
            }

            var notificationSettings = (T)settings;

            if (!ValidateConfiguration(notificationSettings))
            {
                return;
            }

            try
            {
                switch (model.NotificationType)
                {
                case NotificationType.NewRequest:
                    await NewRequest(model, notificationSettings);

                    break;

                case NotificationType.Issue:
                    await Issue(model, notificationSettings);

                    break;

                case NotificationType.RequestAvailable:
                    await AvailableRequest(model, notificationSettings);

                    break;

                case NotificationType.RequestApproved:
                    await RequestApproved(model, notificationSettings);

                    break;

                case NotificationType.AdminNote:
                    throw new NotImplementedException();

                case NotificationType.Test:
                    await Test(model, notificationSettings);

                    break;

                case NotificationType.RequestDeclined:
                    await RequestDeclined(model, notificationSettings);

                    break;

                case NotificationType.ItemAddedToFaultQueue:
                    await AddedToRequestQueue(model, notificationSettings);

                    break;

                default:
                    throw new ArgumentOutOfRangeException();
                }
            }
            catch (NotImplementedException)
            {
                // Do nothing, it's not implimented meaning it might not be ready or even used
            }
        }
Exemplo n.º 8
0
        private async Task PushNewRequestAsync(NotificationModel model, DiscordNotificationSettings settings)
        {
            var message = $"{model.Title} has been requested by user: {model.User}";

            await Push(settings, message);
        }
Exemplo n.º 9
0
 protected abstract Task Test(NotificationModel model, T settings);
Exemplo n.º 10
0
        public async Task NotifyAsync(NotificationModel model)
        {
            var configuration = GetConfiguration();

            await NotifyAsync(model, configuration);
        }
Exemplo n.º 11
0
 protected abstract Task AvailableRequest(NotificationModel model, T settings);
Exemplo n.º 12
0
 protected abstract Task RequestApproved(NotificationModel model, T settings);
Exemplo n.º 13
0
 protected abstract Task RequestDeclined(NotificationModel model, T settings);
Exemplo n.º 14
0
 protected abstract Task AddedToRequestQueue(NotificationModel model, T settings);
Exemplo n.º 15
0
 protected abstract Task Issue(NotificationModel model, T settings);