diff --git a/modules/scylladb/models.go b/modules/scylladb/models.go index 3ffc6e6..e399d1a 100644 --- a/modules/scylladb/models.go +++ b/modules/scylladb/models.go @@ -83,4 +83,18 @@ var ( }, PartKey: []string{"user_first_id", "user_second_id"}, }) + + UserPrivacySettings = table.New(table.Metadata{ + Name: "user_privacy_settings", + Columns: []string{ + "user_id", + "username", + "avatar", + "description", + "location", + "created_at", + "updated_at", + }, + PartKey: []string{"user_id"}, + }) ) diff --git a/modules/structs/user.go b/modules/structs/user.go index a669095..b25fd03 100644 --- a/modules/structs/user.go +++ b/modules/structs/user.go @@ -82,3 +82,19 @@ type UserRelationship struct { type UserRelationshipsResponse struct { Relationships []UserRelationship } + +// TABLE user_privacy_settings +type UserPrivacySettings struct { + UserId string + Username uint8 + Avatar uint8 + Description uint8 + Location uint8 + CreatedAt int64 + UpdatedAt int64 +} + +// swagger:model UserPrivacySettingsResponse +type UserPrivacySettingsResponse struct { + PrivacySettings []UserPrivacySettings +} diff --git a/routers/api/v1/users/users.go b/routers/api/v1/users/users.go index 378942f..03e954b 100644 --- a/routers/api/v1/users/users.go +++ b/routers/api/v1/users/users.go @@ -10,14 +10,13 @@ import ( func GetAllUsers(c *fiber.Ctx) error { // swagger:operation GET /users users usersGetAllUsers // --- - // summary: List of users + // summary: List of all users // consumes: // - application/json // produces: // - application/json // responses: // '200': - // description: List of users // schema: // "$ref": "#/definitions/UsersResponse" // '500': @@ -28,7 +27,7 @@ func GetAllUsers(c *fiber.Ctx) error { q := scylladb.Session.Query(scylladb.Users.SelectAll()) if err := q.SelectRelease(&users); err != nil { - logrus.Errorln("Failed to get users, err:", err) + logrus.Errorln("Failed to get all users, err:", err) } var nUsers []structs.User @@ -46,16 +45,15 @@ func GetAllUsers(c *fiber.Ctx) error { func GetAllUserSignUpProcesses(c *fiber.Ctx) error { // swagger:operation GET /users/signupprocesses users usersGetAllUserSignUpProcesses // --- - // summary: List of user sign up processes + // summary: List of all user sign up processes // consumes: // - application/json // produces: // - application/json // responses: // '200': - // description: List of user sign up processes // schema: - // "$ref": "#/definitions/UsersResponse" + // "$ref": "#/definitions/UserSignUpProcessesResponse" // '500': // description: Internal server error @@ -64,7 +62,7 @@ func GetAllUserSignUpProcesses(c *fiber.Ctx) error { q := scylladb.Session.Query(scylladb.UserSignUpProcess.SelectAll()) if err := q.SelectRelease(&userSignUpProcesses); err != nil { - logrus.Errorln("Failed to get user sign up processes, err:", err) + logrus.Errorln("Failed to get all user sign up processes, err:", err) } return c.JSON(structs.UserSignUpProcessesResponse{UserSignUpProcesses: userSignUpProcesses}) @@ -73,16 +71,15 @@ func GetAllUserSignUpProcesses(c *fiber.Ctx) error { func GetAllUserRelationships(c *fiber.Ctx) error { // swagger:operation GET /users/relationships users usersGetAllUserRelationships // --- - // summary: List of user relationships + // summary: List of all user relationships // consumes: // - application/json // produces: // - application/json // responses: // '200': - // description: List of user relationships // schema: - // "$ref": "#/definitions/UsersResponse" + // "$ref": "#/definitions/UserRelationshipsResponse" // '500': // description: Internal server error @@ -91,8 +88,34 @@ func GetAllUserRelationships(c *fiber.Ctx) error { q := scylladb.Session.Query(scylladb.UserRelationship.SelectAll()) if err := q.SelectRelease(&userRelationships); err != nil { - logrus.Errorln("Failed to get user relationships, err:", err) + logrus.Errorln("Failed to get all user relationships, err:", err) } return c.JSON(structs.UserRelationshipsResponse{Relationships: userRelationships}) } + +func GetAllUserPrivacySettings(c *fiber.Ctx) error { + // swagger:operation GET /users/privacysettings users usersGetAllUserPrivacySettings + // --- + // summary: List of all user privacy settings + // consumes: + // - application/json + // produces: + // - application/json + // responses: + // '200': + // schema: + // "$ref": "#/definitions/UserRelationshipsResponse" + // '500': + // description: Internal server error + + var userPrivacySettings []structs.UserPrivacySettings + + q := scylladb.Session.Query(scylladb.UserPrivacySettings.SelectAll()) + + if err := q.SelectRelease(&userPrivacySettings); err != nil { + logrus.Errorln("Failed to get all user privacy settings, err:", err) + } + + return c.JSON(structs.UserPrivacySettingsResponse{PrivacySettings: userPrivacySettings}) +} diff --git a/routers/router/router.go b/routers/router/router.go index ee09f66..1ad1c71 100644 --- a/routers/router/router.go +++ b/routers/router/router.go @@ -15,6 +15,7 @@ func SetupRoutes(app *fiber.App) { us.Get("/", ApiKeyValidation, users.GetAllUsers) us.Get("/signupprocesses", ApiKeyValidation, users.GetAllUserSignUpProcesses) us.Get("/relationships", ApiKeyValidation, users.GetAllUserRelationships) + us.Get("/privacysettings", ApiKeyValidation, users.GetAllUserPrivacySettings) wss := v1.Group("/wssessions") wss.Get("/", ApiKeyValidation, wssessions.GetAllWsSessions)