Beispiel #1
0
        public async Task UpdateNotification(Deployment deployment)
        {
            if (deployment == null)
            {
                throw new ArgumentNullException(nameof(deployment));
            }

            var deploymentNotificationDao = await _deploymentNotificationRepository.Query()
                                            .FirstOrDefaultAsync(x => x.DeploymentId == deployment.Id);

            if (deploymentNotificationDao != null)
            {
                var handle = new MessageHandle(deploymentNotificationDao.SlackMessageId);

                try
                {
                    _log.LogInformation("Submitting {@DeploymentUpdate} notification change to slack {@MessageHandle}. ", deployment, handle);
                    var notification = _deploymentNotificationBuilder.BuildNotification(deployment);
                    var newHandle    = await _slackClient.UpdateMessageAsync(handle, notification);

                    // NotificationHandles.TryUpdate(deployment.Id, newHandle, handle);
                }
                catch (Exception e)
                {
                    _log.LogError(e, "Failed to submit {@DeploymentUpdate} notification {@MessageHandle}", deployment, handle);
                }
            }
            else
            {
                _log.LogCritical("We received an UpdateNotification operation for deployment {DeploymentId} of {Image}:{Tag} but didn't find it in Db",
                                 deployment.Id,
                                 deployment.ImageRepository,
                                 deployment.TargetTag);
            }
        }