MCPcopy Create free account
hub / github.com/OpenListTeam/OpenList / getBatchHandler

Function getBatchHandler

server/handles/task.go:102–125  ·  view source on GitHub ↗
(manager task.Manager[T], callback func(task T))

Source from the content-addressed store, hash-verified

100}
101
102func getBatchHandler[T task.TaskExtensionInfo](manager task.Manager[T], callback func(task T)) gin.HandlerFunc {
103 return func(c *gin.Context) {
104 isAdmin, uid, ok := getUserInfo(c)
105 if !ok {
106 common.ErrorStrResp(c, "user invalid", 401)
107 return
108 }
109 var tids []string
110 if err := c.ShouldBind(&tids); err != nil {
111 common.ErrorStrResp(c, "invalid request format", 400)
112 return
113 }
114 retErrs := make(map[string]string)
115 for _, tid := range tids {
116 t, ok := manager.GetByID(tid)
117 if !ok || (!isAdmin && uid != t.GetCreator().ID) {
118 retErrs[tid] = "task not found"
119 continue
120 }
121 callback(t)
122 }
123 common.SuccessResp(c, retErrs)
124 }
125}
126
127func taskRoute[T task.TaskExtensionInfo](g *gin.RouterGroup, manager task.Manager[T]) {
128 g.GET("/undone", func(c *gin.Context) {

Callers 1

taskRouteFunction · 0.85

Calls 5

ErrorStrRespFunction · 0.92
SuccessRespFunction · 0.92
getUserInfoFunction · 0.85
GetByIDMethod · 0.80
GetCreatorMethod · 0.65

Tested by

no test coverage detected