예제 #1
0
        private async Task CallWebhook(File file, string type)
        {
            var foundWebhook = _webhookCache.FirstOrDefault(x => string.Equals(x.Type, type) && x.FolderId == file.FolderId);
            var foundFolder  = await _folderRepository.GetFolderName(file.FolderId);

            var folderName = foundFolder?.Data;

            if (foundWebhook is object && !string.IsNullOrWhiteSpace(foundWebhook.CallbackUrl))
            {
                var postObject = new { name = file.Name, path = file.GetFullPath(), version = file.Version, folder = folderName };

                WorkerLog.Instance.Debug($"Webhook of type '{type}' for folder '{folderName}' calling '{foundWebhook.CallbackUrl}'");
                var httpClient = _httpClientFactory.CreateClient("webhook");
                try
                {
                    await httpClient.PostAsync(foundWebhook.CallbackUrl, (object)postObject, throwErrorOnResponseNok : true);
                }
                catch (Exception ex)
                {
                    WorkerLog.Instance.Error(ex.InnerException, $"Failed to call webhook of type '{type}' for folder '{folderName}'");
                }
            }
            else
            {
                WorkerLog.Instance.Warning($"No webhook found of type '{type}' for folder '{folderName}'");
            }
        }
예제 #2
0
        public void UpdateFolder(Folder folder)
        {
            string oldFolderName = _folderRepository.GetFolderName(folder.ID);

            _folderRepository.UpdateFolder(folder);

            if (oldFolderName != folder.Title)
            {
                string parentFolderPath = GenerateFolderPath(folder.ParentFolderID);

                _storageService.UpdateFolderPath(parentFolderPath, oldFolderName, folder.Title);
            }
        }