44package  group
55
66import  (
7- 	group_model "code.gitea.io/gitea/models/group" 
8- 	repo_model "code.gitea.io/gitea/models/repo" 
97	"code.gitea.io/gitea/modules/json" 
108	"code.gitea.io/gitea/services/context" 
119	"code.gitea.io/gitea/services/forms" 
@@ -18,31 +16,14 @@ func MoveGroupItem(ctx *context.Context) {
1816		ctx .ServerError ("DecodeMovedGroupItemForm" , err )
1917		return 
2018	}
21- 	if  form .IsGroup  {
22- 		group , err  :=  group_model .GetGroupByID (ctx , form .ItemID )
23- 		if  err  !=  nil  {
24- 			ctx .ServerError ("GetGroupByID" , err )
25- 			return 
26- 		}
27- 		if  group .ParentGroupID  !=  form .NewParent  {
28- 			if  err  =  group_model .MoveGroup (ctx , group , form .NewParent , form .NewPos ); err  !=  nil  {
29- 				ctx .ServerError ("MoveGroup" , err )
30- 				return 
31- 			}
32- 			if  err  =  group_service .RecalculateGroupAccess (ctx , group , false ); err  !=  nil  {
33- 				ctx .ServerError ("RecalculateGroupAccess" , err )
34- 			}
35- 		}
36- 	} else  {
37- 		repo , err  :=  repo_model .GetRepositoryByID (ctx , form .ItemID )
38- 		if  err  !=  nil  {
39- 			ctx .ServerError ("GetRepositoryByID" , err )
40- 		}
41- 		if  repo .GroupID  !=  form .NewParent  {
42- 			if  err  =  group_service .MoveRepositoryToGroup (ctx , repo , form .NewParent , form .NewPos ); err  !=  nil  {
43- 				ctx .ServerError ("MoveRepositoryToGroup" , err )
44- 			}
45- 		}
19+ 	if  err  :=  group_service .MoveGroupItem (ctx , group_service.MoveGroupOptions {
20+ 		IsGroup :   form .IsGroup ,
21+ 		ItemID :    form .ItemID ,
22+ 		NewPos :    form .NewPos ,
23+ 		NewParent : form .NewParent ,
24+ 	}, ctx .Doer ); err  !=  nil  {
25+ 		ctx .ServerError ("MoveGroupItem" , err )
26+ 		return 
4627	}
4728	ctx .JSONOK ()
4829}
0 commit comments