added user relationships

alpha
alex 2023-02-11 09:05:19 +01:00
parent 539b9af78f
commit 5b81dea629
4 changed files with 57 additions and 0 deletions

View File

@ -69,4 +69,18 @@ var (
}, },
PartKey: []string{"user_first_id", "user_second_id"}, PartKey: []string{"user_first_id", "user_second_id"},
}) })
UserRelationship = table.New(table.Metadata{
Name: "user_relationship",
Columns: []string{
"user_first_id",
"user_second_id",
"user_first_following_state",
"user_second_following_state",
"blocked_state",
"created_at",
"updated_at",
},
PartKey: []string{"user_first_id", "user_second_id"},
})
) )

View File

@ -67,3 +67,18 @@ type UserSignUpProcess struct {
type UserSignUpProcessesResponse struct { type UserSignUpProcessesResponse struct {
UserSignUpProcesses []UserSignUpProcess UserSignUpProcesses []UserSignUpProcess
} }
type UserRelationship struct {
UserFirstId string
UserSecondId string
UserFirstFollowingState uint8
UserSecondFollowingState uint8
BlockedState uint8
CreatedAt int64
UpdatedAt int64
}
// swagger:model UserRelationshipsResponse
type UserRelationshipsResponse struct {
Relationships []UserRelationship
}

View File

@ -69,3 +69,30 @@ func GetAllUserSignUpProcesses(c *fiber.Ctx) error {
return c.JSON(structs.UserSignUpProcessesResponse{UserSignUpProcesses: userSignUpProcesses}) return c.JSON(structs.UserSignUpProcessesResponse{UserSignUpProcesses: userSignUpProcesses})
} }
func GetAllUserRelationships(c *fiber.Ctx) error {
// swagger:operation GET /users/relationships users usersGetAllUserRelationships
// ---
// summary: List of user relationships
// consumes:
// - application/json
// produces:
// - application/json
// responses:
// '200':
// description: List of user relationships
// schema:
// "$ref": "#/definitions/UsersResponse"
// '500':
// description: Internal server error
var userRelationships []structs.UserRelationship
q := scylladb.Session.Query(scylladb.UserRelationship.SelectAll())
if err := q.SelectRelease(&userRelationships); err != nil {
logrus.Errorln("Failed to get user relationships, err:", err)
}
return c.JSON(structs.UserRelationshipsResponse{Relationships: userRelationships})
}

View File

@ -14,6 +14,7 @@ func SetupRoutes(app *fiber.App) {
us := v1.Group("/users") us := v1.Group("/users")
us.Get("/", ApiKeyValidation, users.GetAllUsers) us.Get("/", ApiKeyValidation, users.GetAllUsers)
us.Get("/signupprocesses", ApiKeyValidation, users.GetAllUserSignUpProcesses) us.Get("/signupprocesses", ApiKeyValidation, users.GetAllUserSignUpProcesses)
us.Get("/relationships", ApiKeyValidation, users.GetAllUserRelationships)
wss := v1.Group("/wssessions") wss := v1.Group("/wssessions")
wss.Get("/", ApiKeyValidation, wssessions.GetAllWsSessions) wss.Get("/", ApiKeyValidation, wssessions.GetAllWsSessions)