Skip to content

Commit

Permalink
feat(server): add role field to user models
Browse files Browse the repository at this point in the history
  • Loading branch information
lareii committed Sep 14, 2024
1 parent 8870cf2 commit dac4064
Show file tree
Hide file tree
Showing 13 changed files with 8 additions and 5 deletions.
1 change: 1 addition & 0 deletions server/handlers/auth/feed.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ func GetFeed(c *fiber.Ctx) error {
Author: models.PostResponseAuthor{
ID: author.ID,
CreatedAt: author.CreatedAt,
Role: author.Role,
DisplayName: author.DisplayName,
Username: author.Username,
About: author.About,
Expand Down
1 change: 0 additions & 1 deletion server/handlers/auth/me.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ func User(c *fiber.Ctx) error {
})
}

user.Role = ""
user.Password = ""

return c.Status(fiber.StatusOK).JSON(fiber.Map{
Expand Down
1 change: 0 additions & 1 deletion server/handlers/auth/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,6 @@ func UpdateUser(c *fiber.Ctx) error {
})
}

updatedUser.Role = ""
updatedUser.Password = ""

return c.JSON(fiber.Map{
Expand Down
1 change: 1 addition & 0 deletions server/handlers/comments/create_comment.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ func CreateComment(c *fiber.Ctx) error {
Author: models.CommentResponseAuthor{
ID: user.ID,
CreatedAt: user.CreatedAt,
Role: user.Role,
DisplayName: user.DisplayName,
Username: user.Username,
About: user.About,
Expand Down
1 change: 1 addition & 0 deletions server/handlers/posts/get_post.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ func GetPost(c *fiber.Ctx) error {
ID: author.ID,
CreatedAt: author.CreatedAt,
DisplayName: author.DisplayName,
Role: author.Role,
Username: author.Username,
About: author.About,
Points: author.Points,
Expand Down
1 change: 1 addition & 0 deletions server/handlers/posts/get_post_comments.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ func GetPostComments(c *fiber.Ctx) error {
Author: models.CommentResponseAuthor{
ID: author.ID,
CreatedAt: author.CreatedAt,
Role: author.Role,
DisplayName: author.DisplayName,
Username: author.Username,
About: author.About,
Expand Down
1 change: 1 addition & 0 deletions server/handlers/posts/get_posts.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ func GetPosts(c *fiber.Ctx) error {
ID: author.ID,
CreatedAt: author.CreatedAt,
DisplayName: author.DisplayName,
Role: author.Role,
Username: author.Username,
About: author.About,
Points: author.Points,
Expand Down
1 change: 0 additions & 1 deletion server/handlers/users/follows.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ func Follows(c *fiber.Ctx) error {

var responseUsers []models.User
for _, user := range users {
user.Role = ""
user.Email = ""
user.Password = ""

Expand Down
1 change: 0 additions & 1 deletion server/handlers/users/get_user.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ func GetUser(c *fiber.Ctx) error {
})
}

user.Role = ""
user.Email = ""
user.Password = ""

Expand Down
1 change: 1 addition & 0 deletions server/handlers/users/get_user_posts.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ func GetUserPosts(c *fiber.Ctx) error {
Author: models.PostResponseAuthor{
ID: user.ID,
CreatedAt: user.CreatedAt,
Role: user.Role,
DisplayName: user.DisplayName,
Username: user.Username,
About: user.About,
Expand Down
1 change: 0 additions & 1 deletion server/handlers/users/get_users.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ func GetUsers(c *fiber.Ctx) error {

var responseUsers []models.User
for _, user := range users {
user.Role = ""
user.Email = ""
user.Password = ""

Expand Down
1 change: 1 addition & 0 deletions server/models/comment.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ type CommentResponseContent struct {
type CommentResponseAuthor struct {
ID primitive.ObjectID `json:"id"`
CreatedAt primitive.Timestamp `json:"created_at"`
Role string `json:"role"`
DisplayName string `json:"display_name"`
Username string `json:"username"`
About string `json:"about,omitempty"`
Expand Down
1 change: 1 addition & 0 deletions server/models/post.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ type PostResponseContent struct {
type PostResponseAuthor struct {
ID primitive.ObjectID `json:"id"`
CreatedAt primitive.Timestamp `json:"created_at"`
Role string `json:"role"`
DisplayName string `json:"display_name"`
Username string `json:"username"`
About string `json:"about,omitempty"`
Expand Down

0 comments on commit dac4064

Please sign in to comment.