Skip to content

Commit 01911db

Browse files
FIX (notifiers & storages): Avoid request for workspace_id for storages and notifiers removal
1 parent 1a16f27 commit 01911db

File tree

5 files changed

+4
-32
lines changed

5 files changed

+4
-32
lines changed

backend/internal/features/backups/config/controller.go

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,6 @@ func (c *BackupConfigController) GetBackupConfigByDbID(ctx *gin.Context) {
9494
// @Tags backup-configs
9595
// @Produce json
9696
// @Param id path string true "Storage ID"
97-
// @Param workspace_id query string true "Workspace ID"
9897
// @Success 200 {object} map[string]bool
9998
// @Failure 400
10099
// @Failure 401
@@ -113,19 +112,7 @@ func (c *BackupConfigController) IsStorageUsing(ctx *gin.Context) {
113112
return
114113
}
115114

116-
workspaceIDStr := ctx.Query("workspace_id")
117-
if workspaceIDStr == "" {
118-
ctx.JSON(http.StatusBadRequest, gin.H{"error": "workspace_id query parameter is required"})
119-
return
120-
}
121-
122-
workspaceID, err := uuid.Parse(workspaceIDStr)
123-
if err != nil {
124-
ctx.JSON(http.StatusBadRequest, gin.H{"error": "invalid workspace_id"})
125-
return
126-
}
127-
128-
isUsing, err := c.backupConfigService.IsStorageUsing(user, workspaceID, id)
115+
isUsing, err := c.backupConfigService.IsStorageUsing(user, id)
129116
if err != nil {
130117
ctx.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()})
131118
return

backend/internal/features/backups/config/controller_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,7 @@ func Test_IsStorageUsing_PermissionsEnforced(t *testing.T) {
341341
test_utils.MakeGetRequestAndUnmarshal(
342342
t,
343343
router,
344-
"/api/v1/backup-configs/storage/"+storage.ID.String()+"/is-using?workspace_id="+workspace.ID.String(),
344+
"/api/v1/backup-configs/storage/"+storage.ID.String()+"/is-using",
345345
"Bearer "+testUserToken,
346346
tt.expectedStatusCode,
347347
&response,
@@ -354,7 +354,7 @@ func Test_IsStorageUsing_PermissionsEnforced(t *testing.T) {
354354
testResp := test_utils.MakeGetRequest(
355355
t,
356356
router,
357-
"/api/v1/backup-configs/storage/"+storage.ID.String()+"/is-using?workspace_id="+workspace.ID.String(),
357+
"/api/v1/backup-configs/storage/"+storage.ID.String()+"/is-using",
358358
"Bearer "+testUserToken,
359359
tt.expectedStatusCode,
360360
)

backend/internal/features/backups/config/service.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,6 @@ func (s *BackupConfigService) GetBackupConfigByDbId(
119119

120120
func (s *BackupConfigService) IsStorageUsing(
121121
user *users_models.User,
122-
workspaceID uuid.UUID,
123122
storageID uuid.UUID,
124123
) (bool, error) {
125124
_, err := s.storageService.GetStorage(user, storageID)

backend/internal/features/databases/controller.go

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,6 @@ func (c *DatabaseController) TestDatabaseConnectionDirect(ctx *gin.Context) {
271271
// @Tags databases
272272
// @Produce json
273273
// @Param id path string true "Notifier ID"
274-
// @Param workspace_id query string true "Workspace ID"
275274
// @Success 200 {object} map[string]bool
276275
// @Failure 400
277276
// @Failure 401
@@ -290,19 +289,7 @@ func (c *DatabaseController) IsNotifierUsing(ctx *gin.Context) {
290289
return
291290
}
292291

293-
workspaceIDStr := ctx.Query("workspace_id")
294-
if workspaceIDStr == "" {
295-
ctx.JSON(http.StatusBadRequest, gin.H{"error": "workspace_id query parameter is required"})
296-
return
297-
}
298-
299-
workspaceID, err := uuid.Parse(workspaceIDStr)
300-
if err != nil {
301-
ctx.JSON(http.StatusBadRequest, gin.H{"error": "invalid workspace_id"})
302-
return
303-
}
304-
305-
isUsing, err := c.databaseService.IsNotifierUsing(user, workspaceID, id)
292+
isUsing, err := c.databaseService.IsNotifierUsing(user, id)
306293
if err != nil {
307294
ctx.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()})
308295
return

backend/internal/features/databases/service.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,6 @@ func (s *DatabaseService) GetDatabasesByWorkspace(
219219

220220
func (s *DatabaseService) IsNotifierUsing(
221221
user *users_models.User,
222-
workspaceID uuid.UUID,
223222
notifierID uuid.UUID,
224223
) (bool, error) {
225224
_, err := s.notifierService.GetNotifier(user, notifierID)

0 commit comments

Comments
 (0)