added get all users sessions

alpha
alex 2023-02-24 08:43:15 +01:00
parent f05d3392ed
commit a0694e8325
5 changed files with 35 additions and 1 deletions

2
go.mod
View File

@ -3,7 +3,7 @@ module clickandjoin.app/managementsystem
go 1.18 go 1.18
require ( require (
git.clickandjoin.umbach.dev/ClickandJoin/go-cnj-helper v1.0.67 git.clickandjoin.umbach.dev/ClickandJoin/go-cnj-helper v1.0.68
github.com/gocql/gocql v0.0.0-20211015133455-b225f9b53fa1 github.com/gocql/gocql v0.0.0-20211015133455-b225f9b53fa1
github.com/gofiber/fiber/v2 v2.42.0 github.com/gofiber/fiber/v2 v2.42.0
github.com/gofiber/websocket/v2 v2.1.4 github.com/gofiber/websocket/v2 v2.1.4

2
go.sum
View File

@ -4,6 +4,8 @@ git.clickandjoin.umbach.dev/ClickandJoin/go-cnj-helper v1.0.66 h1:ljNWOs0KDK5Hsv
git.clickandjoin.umbach.dev/ClickandJoin/go-cnj-helper v1.0.66/go.mod h1:rnEM9rcZy2dg4SaDCGmSf34fp7ECzdyxxnRut2HBmrs= git.clickandjoin.umbach.dev/ClickandJoin/go-cnj-helper v1.0.66/go.mod h1:rnEM9rcZy2dg4SaDCGmSf34fp7ECzdyxxnRut2HBmrs=
git.clickandjoin.umbach.dev/ClickandJoin/go-cnj-helper v1.0.67 h1:a5mZBmx5rBgnU9OKQja8eX6QfoaiubWBqsaXWUcidqY= git.clickandjoin.umbach.dev/ClickandJoin/go-cnj-helper v1.0.67 h1:a5mZBmx5rBgnU9OKQja8eX6QfoaiubWBqsaXWUcidqY=
git.clickandjoin.umbach.dev/ClickandJoin/go-cnj-helper v1.0.67/go.mod h1:rnEM9rcZy2dg4SaDCGmSf34fp7ECzdyxxnRut2HBmrs= git.clickandjoin.umbach.dev/ClickandJoin/go-cnj-helper v1.0.67/go.mod h1:rnEM9rcZy2dg4SaDCGmSf34fp7ECzdyxxnRut2HBmrs=
git.clickandjoin.umbach.dev/ClickandJoin/go-cnj-helper v1.0.68 h1:krwHGA+GLaK3tEhWT9MlA/X/WssGaHIQZtnVoZMqJrE=
git.clickandjoin.umbach.dev/ClickandJoin/go-cnj-helper v1.0.68/go.mod h1:rnEM9rcZy2dg4SaDCGmSf34fp7ECzdyxxnRut2HBmrs=
github.com/andybalholm/brotli v1.0.4 h1:V7DdXeJtZscaqfNuAdSRuRFzuiKlHSC/Zh3zl9qY3JY= github.com/andybalholm/brotli v1.0.4 h1:V7DdXeJtZscaqfNuAdSRuRFzuiKlHSC/Zh3zl9qY3JY=
github.com/andybalholm/brotli v1.0.4/go.mod h1:fO7iG3H7G2nSZ7m0zPUDn85XEX2GTukHGRSepvi9Eig= github.com/andybalholm/brotli v1.0.4/go.mod h1:fO7iG3H7G2nSZ7m0zPUDn85XEX2GTukHGRSepvi9Eig=
github.com/bitly/go-hostpool v0.0.0-20171023180738-a3a6125de932 h1:mXoPYz/Ul5HYEDvkta6I8/rnYM5gSdSV2tJ6XbZuEtY= github.com/bitly/go-hostpool v0.0.0-20171023180738-a3a6125de932 h1:mXoPYz/Ul5HYEDvkta6I8/rnYM5gSdSV2tJ6XbZuEtY=

View File

@ -22,6 +22,11 @@ type UserPrivacySettingsResponse struct {
PrivacySettings []dbstructs.UserPrivacySettings PrivacySettings []dbstructs.UserPrivacySettings
} }
// swagger:model UserSessionsResponse
type UserSessionsResponse struct {
UserSessions []dbstructs.UserSession
}
// swagger:model UpdateUserRequest // swagger:model UpdateUserRequest
type UpdateUserRequest struct { type UpdateUserRequest struct {
Username string Username string

View File

@ -120,3 +120,29 @@ func GetAllUserPrivacySettings(c *fiber.Ctx) error {
return c.JSON(structs.UserPrivacySettingsResponse{PrivacySettings: userPrivacySettings}) return c.JSON(structs.UserPrivacySettingsResponse{PrivacySettings: userPrivacySettings})
} }
func GetAllUserSessions(c *fiber.Ctx) error {
// swagger:operation GET /users/sessions users usersGetAllUserSessions
// ---
// summary: List of all user sessions
// consumes:
// - application/json
// produces:
// - application/json
// responses:
// '200':
// schema:
// "$ref": "#/definitions/UserSessionsResponse"
// '500':
// description: Internal server error
var userSessions []dbstructs.UserSession
q := scylladb.Session.Query(gocnjhelper.DbMSessions.SelectAll())
if err := q.SelectRelease(&userSessions); err != nil {
gocnjhelper.LogErrorf("Failed to get all user sessions, err: %s", err)
}
return c.JSON(structs.UserSessionsResponse{UserSessions: userSessions})
}

View File

@ -18,6 +18,7 @@ func SetupRoutes(app *fiber.App) {
us.Get("/signupprocesses", ApiKeyValidation, users.GetAllUserSignUpProcesses) us.Get("/signupprocesses", ApiKeyValidation, users.GetAllUserSignUpProcesses)
us.Get("/relationships", ApiKeyValidation, users.GetAllUserRelationships) us.Get("/relationships", ApiKeyValidation, users.GetAllUserRelationships)
us.Get("/privacysettings", ApiKeyValidation, users.GetAllUserPrivacySettings) us.Get("/privacysettings", ApiKeyValidation, users.GetAllUserPrivacySettings)
us.Get("/sessions", ApiKeyValidation, users.GetAllUserSessions)
u := v1.Group("/user") u := v1.Group("/user")
u.Patch("/:userId", ApiKeyValidation, user.UpdateUser) u.Patch("/:userId", ApiKeyValidation, user.UpdateUser)