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 3.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. // Copyright 2014 The Gogs Authors. All rights reserved.
  2. // SPDX-License-Identifier: MIT
  3. package structs
  4. import (
  5. "time"
  6. "code.gitea.io/gitea/modules/json"
  7. )
  8. // User represents a user
  9. // swagger:model
  10. type User struct {
  11. // the user's id
  12. ID int64 `json:"id"`
  13. // the user's username
  14. UserName string `json:"login"`
  15. // the user's authentication sign-in name.
  16. // default: empty
  17. LoginName string `json:"login_name"`
  18. // the user's full name
  19. FullName string `json:"full_name"`
  20. // swagger:strfmt email
  21. Email string `json:"email"`
  22. // URL to the user's avatar
  23. AvatarURL string `json:"avatar_url"`
  24. // User locale
  25. Language string `json:"language"`
  26. // Is the user an administrator
  27. IsAdmin bool `json:"is_admin"`
  28. // swagger:strfmt date-time
  29. LastLogin time.Time `json:"last_login,omitempty"`
  30. // swagger:strfmt date-time
  31. Created time.Time `json:"created,omitempty"`
  32. // Is user restricted
  33. Restricted bool `json:"restricted"`
  34. // Is user active
  35. IsActive bool `json:"active"`
  36. // Is user login prohibited
  37. ProhibitLogin bool `json:"prohibit_login"`
  38. // the user's location
  39. Location string `json:"location"`
  40. // the user's website
  41. Website string `json:"website"`
  42. // the user's description
  43. Description string `json:"description"`
  44. // User visibility level option: public, limited, private
  45. Visibility string `json:"visibility"`
  46. // user counts
  47. Followers int `json:"followers_count"`
  48. Following int `json:"following_count"`
  49. StarredRepos int `json:"starred_repos_count"`
  50. }
  51. // MarshalJSON implements the json.Marshaler interface for User, adding field(s) for backward compatibility
  52. func (u User) MarshalJSON() ([]byte, error) {
  53. // Re-declaring User to avoid recursion
  54. type shadow User
  55. return json.Marshal(struct {
  56. shadow
  57. CompatUserName string `json:"username"`
  58. }{shadow(u), u.UserName})
  59. }
  60. // UserSettings represents user settings
  61. // swagger:model
  62. type UserSettings struct {
  63. FullName string `json:"full_name"`
  64. Website string `json:"website"`
  65. Description string `json:"description"`
  66. Location string `json:"location"`
  67. Language string `json:"language"`
  68. Theme string `json:"theme"`
  69. DiffViewStyle string `json:"diff_view_style"`
  70. // Privacy
  71. HideEmail bool `json:"hide_email"`
  72. HideActivity bool `json:"hide_activity"`
  73. }
  74. // UserSettingsOptions represents options to change user settings
  75. // swagger:model
  76. type UserSettingsOptions struct {
  77. FullName *string `json:"full_name" binding:"MaxSize(100)"`
  78. Website *string `json:"website" binding:"OmitEmpty;ValidUrl;MaxSize(255)"`
  79. Description *string `json:"description" binding:"MaxSize(255)"`
  80. Location *string `json:"location" binding:"MaxSize(50)"`
  81. Language *string `json:"language"`
  82. Theme *string `json:"theme"`
  83. DiffViewStyle *string `json:"diff_view_style"`
  84. // Privacy
  85. HideEmail *bool `json:"hide_email"`
  86. HideActivity *bool `json:"hide_activity"`
  87. }
  88. // RenameUserOption options when renaming a user
  89. type RenameUserOption struct {
  90. // New username for this user. This name cannot be in use yet by any other user.
  91. //
  92. // required: true
  93. // unique: true
  94. NewName string `json:"new_username" binding:"Required"`
  95. }
  96. // UpdateUserAvatarUserOption options when updating the user avatar
  97. type UpdateUserAvatarOption struct {
  98. // image must be base64 encoded
  99. Image string `json:"image" binding:"Required"`
  100. }