Example #1
0
 public async Task PublishTest(NotificationModel model, Settings settings, INotification type)
 {
     await type.NotifyAsync(model, settings);
 }
Example #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);
        }
Example #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);
        }
Example #4
0
        public async Task NotifyAsync(NotificationModel model)
        {
            var settings = Settings.GetSettings();

            await NotifyAsync(model, settings);
        }
Example #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);
        }
Example #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);
        }
Example #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
            }
        }
Example #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);
        }
Example #9
0
 protected abstract Task Test(NotificationModel model, T settings);
Example #10
0
        public async Task NotifyAsync(NotificationModel model)
        {
            var configuration = GetConfiguration();

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