diff --git a/routers/repo/cloudbrain.go b/routers/repo/cloudbrain.go index 4f484c3f2..5b46c4d67 100755 --- a/routers/repo/cloudbrain.go +++ b/routers/repo/cloudbrain.go @@ -813,10 +813,10 @@ func CloudBrainShowModels(ctx *context.Context) { } func GetPublicImages(ctx *context.Context) { - + uid := getUID(ctx) opts := models.SearchImageOptions{ IncludePublicOnly: true, - UID: -1, + UID: uid, Keyword: ctx.Query("q"), Topics: ctx.Query("topic"), IncludeOfficialOnly: ctx.QueryBool("recommend"), @@ -828,10 +828,7 @@ func GetPublicImages(ctx *context.Context) { } func GetCustomImages(ctx *context.Context) { - var uid int64 = -1 - if ctx.IsSigned { - uid = ctx.User.ID - } + uid := getUID(ctx) opts := models.SearchImageOptions{ UID: uid, IncludeOwnerOnly: true, @@ -844,10 +841,7 @@ func GetCustomImages(ctx *context.Context) { } func GetStarImages(ctx *context.Context) { - var uid int64 = -1 - if ctx.IsSigned { - uid = ctx.User.ID - } + uid := getUID(ctx) opts := models.SearchImageOptions{ UID: uid, IncludeStarByMe: true, @@ -859,10 +853,18 @@ func GetStarImages(ctx *context.Context) { } -func GetAllImages(ctx *context.Context) { +func getUID(ctx *context.Context) int64 { + var uid int64 = -1 + if ctx.IsSigned { + uid = ctx.User.ID + } + return uid +} +func GetAllImages(ctx *context.Context) { + uid := getUID(ctx) opts := models.SearchImageOptions{ - UID: -1, + UID: uid, Keyword: ctx.Query("q"), Topics: ctx.Query("topic"), SearchOrderBy: "id desc",