From a22bbbf5ab858267e41e9ca6c70ab88e11441564 Mon Sep 17 00:00:00 2001 From: Ethan Wellenreiter Date: Mon, 23 Jun 2025 13:11:16 -0400 Subject: [PATCH] Adding function signatures for API handlers Signed-off-by: Ethan Wellenreiter --- backend/cmd/api/groups.go | 29 +++++++++++++++++++++++++++-- backend/cmd/api/users.go | 9 ++++++--- 2 files changed, 33 insertions(+), 5 deletions(-) diff --git a/backend/cmd/api/groups.go b/backend/cmd/api/groups.go index b46e6e3..7822655 100644 --- a/backend/cmd/api/groups.go +++ b/backend/cmd/api/groups.go @@ -9,8 +9,12 @@ import ( "github.com/go-chi/chi/v5" ) +type groupKey string + +const groupCtx groupKey = "group" + func (app *application) getUserGroups(ctx context.Context, userID int64) (*storage.UserGroups, error) { - if !app.config.redisCfg.enabled { + if !app.config.cacheCfg.enabled { return app.store.Groups.GetUserGroups(ctx, userID) } @@ -34,7 +38,7 @@ func (app *application) getUserGroups(ctx context.Context, userID int64) (*stora } func (app *application) getGroup(ctx context.Context, groupID int64) (*storage.Group, error) { - if !app.config.redisCfg.enabled { + if !app.config.cacheCfg.enabled { return app.store.Groups.GetByID(ctx, groupID) } @@ -104,3 +108,24 @@ func (app *application) getUsersGroupHandler(w http.ResponseWriter, r *http.Requ app.internalServerError(w, r, err) } } + +func (app *application) setGroupOwnerHandler(w http.ResponseWriter, r *http.Request) { +} + +func (app *application) getGroupOwnerHandler(w http.ResponseWriter, r *http.Request) { +} + +func (app *application) addGroupModeratorHandler(w http.ResponseWriter, r *http.Request) { +} + +func (app *application) removeModeratorPriviligesHandler(w http.ResponseWriter, r *http.Request) { +} + +func (app *application) getGroupUsersHandler(w http.ResponseWriter, r *http.Request) { +} + +func (app *application) addGroupUserHandler(w http.ResponseWriter, r *http.Request) { +} + +func (app *application) removeUserFromGroupHandler(w http.ResponseWriter, r *http.Request) { +} diff --git a/backend/cmd/api/users.go b/backend/cmd/api/users.go index eba84b1..1cb4176 100644 --- a/backend/cmd/api/users.go +++ b/backend/cmd/api/users.go @@ -51,9 +51,12 @@ func (app *application) getUsersHandler(w http.ResponseWriter, r *http.Request) func (app *application) deleteUserHandler(w http.ResponseWriter, r *http.Request) { } +func (app *application) removeUserGroupHandler(w http.ResponseWriter, r *http.Request) { +} + func (app *application) getUser(ctx context.Context, userID int64) (*storage.User, error) { - if !app.config.redisCfg.enabled { - return app.auth.Users.GetByID(ctx, userID) + if !app.config.cacheCfg.enabled { + return app.store.Users.GetByID(ctx, userID) } user, err := app.cacheStorage.Users.Get(ctx, userID) @@ -62,7 +65,7 @@ func (app *application) getUser(ctx context.Context, userID int64) (*storage.Use } if user == nil { - user, err = app.auth.Users.GetByID(ctx, userID) + user, err = app.store.Users.GetByID(ctx, userID) if err != nil { return nil, err }