You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

user.go 2.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. // Copyright 2014 The Gogs Authors. All rights reserved.
  2. // Use of this source code is governed by a MIT-style
  3. // license that can be found in the LICENSE file.
  4. package structs
  5. import (
  6. "time"
  7. "code.gitea.io/gitea/modules/json"
  8. )
  9. // User represents a user
  10. // swagger:model
  11. type User struct {
  12. // the user's id
  13. ID int64 `json:"id"`
  14. // the user's username
  15. UserName string `json:"login"`
  16. // the user's full name
  17. FullName string `json:"full_name"`
  18. // swagger:strfmt email
  19. Email string `json:"email"`
  20. // URL to the user's avatar
  21. AvatarURL string `json:"avatar_url"`
  22. // User locale
  23. Language string `json:"language"`
  24. // Is the user an administrator
  25. IsAdmin bool `json:"is_admin"`
  26. // swagger:strfmt date-time
  27. LastLogin time.Time `json:"last_login,omitempty"`
  28. // swagger:strfmt date-time
  29. Created time.Time `json:"created,omitempty"`
  30. // Is user restricted
  31. Restricted bool `json:"restricted"`
  32. // Is user active
  33. IsActive bool `json:"active"`
  34. // Is user login prohibited
  35. ProhibitLogin bool `json:"prohibit_login"`
  36. // the user's location
  37. Location string `json:"location"`
  38. // the user's website
  39. Website string `json:"website"`
  40. // the user's description
  41. Description string `json:"description"`
  42. // User visibility level option: public, limited, private
  43. Visibility string `json:"visibility"`
  44. // user counts
  45. Followers int `json:"followers_count"`
  46. Following int `json:"following_count"`
  47. StarredRepos int `json:"starred_repos_count"`
  48. }
  49. // MarshalJSON implements the json.Marshaler interface for User, adding field(s) for backward compatibility
  50. func (u User) MarshalJSON() ([]byte, error) {
  51. // Re-declaring User to avoid recursion
  52. type shadow User
  53. return json.Marshal(struct {
  54. shadow
  55. CompatUserName string `json:"username"`
  56. }{shadow(u), u.UserName})
  57. }
  58. // UserSettings represents user settings
  59. // swagger:model
  60. type UserSettings struct {
  61. FullName string `json:"full_name"`
  62. Website string `json:"website"`
  63. Description string `json:"description"`
  64. Location string `json:"location"`
  65. Language string `json:"language"`
  66. Theme string `json:"theme"`
  67. DiffViewStyle string `json:"diff_view_style"`
  68. // Privacy
  69. HideEmail bool `json:"hide_email"`
  70. HideActivity bool `json:"hide_activity"`
  71. }
  72. // UserSettingsOptions represents options to change user settings
  73. // swagger:model
  74. type UserSettingsOptions struct {
  75. FullName *string `json:"full_name" binding:"MaxSize(100)"`
  76. Website *string `json:"website" binding:"OmitEmpty;ValidUrl;MaxSize(255)"`
  77. Description *string `json:"description" binding:"MaxSize(255)"`
  78. Location *string `json:"location" binding:"MaxSize(50)"`
  79. Language *string `json:"language"`
  80. Theme *string `json:"theme"`
  81. DiffViewStyle *string `json:"diff_view_style"`
  82. // Privacy
  83. HideEmail *bool `json:"hide_email"`
  84. HideActivity *bool `json:"hide_activity"`
  85. }