]> source.dussan.org Git - gitea.git/commitdiff
Add Location, Website and Biography to API (#15675)
authorKN4CK3R <KN4CK3R@users.noreply.github.com>
Sat, 1 May 2021 09:05:55 +0000 (11:05 +0200)
committerGitHub <noreply@github.com>
Sat, 1 May 2021 09:05:55 +0000 (10:05 +0100)
modules/convert/user.go
modules/structs/user.go
templates/swagger/v1_json.tmpl

index f3a33aee411d145d2d4aef4ec4edce7c0ba69039..364914f2ad02f08f5665fc952824ce01d4645c04 100644 (file)
@@ -38,13 +38,16 @@ func ToUserWithAccessMode(user *models.User, accessMode models.AccessMode) *api.
 // signed shall only be set if requester is logged in. authed shall only be set if user is site admin or user himself
 func toUser(user *models.User, signed, authed bool) *api.User {
        result := &api.User{
-               ID:         user.ID,
-               UserName:   user.Name,
-               FullName:   markup.Sanitize(user.FullName),
-               Email:      user.GetEmail(),
-               AvatarURL:  user.AvatarLink(),
-               Created:    user.CreatedUnix.AsTime(),
-               Restricted: user.IsRestricted,
+               ID:          user.ID,
+               UserName:    user.Name,
+               FullName:    markup.Sanitize(user.FullName),
+               Email:       user.GetEmail(),
+               AvatarURL:   user.AvatarLink(),
+               Created:     user.CreatedUnix.AsTime(),
+               Restricted:  user.IsRestricted,
+               Location:    user.Location,
+               Website:     user.Website,
+               Description: user.Description,
        }
        // hide primary email if API caller is anonymous or user keep email private
        if signed && (!user.KeepEmailPrivate || authed) {
index 9e021e40fe880b610365bc4afb05bd6de09154a0..efd246e566a8943df84689ab35541c6c44c5fd85 100644 (file)
@@ -33,6 +33,12 @@ type User struct {
        Created time.Time `json:"created,omitempty"`
        // Is user restricted
        Restricted bool `json:"restricted"`
+       // the user's location
+       Location string `json:"location"`
+       // the user's website
+       Website string `json:"website"`
+       // the user's biography
+       Description string `json:"bio"`
 }
 
 // MarshalJSON implements the json.Marshaler interface for User, adding field(s) for backward compatibility
index 5aeed4a30f49375c2a94a4fc8a5957236b82b443..6d690ba275ad3ab6e703a8eebf5e6199e5c95034 100644 (file)
           "type": "string",
           "x-go-name": "AvatarURL"
         },
+        "bio": {
+          "description": "the user's biography",
+          "type": "string",
+          "x-go-name": "Description"
+        },
         "created": {
           "type": "string",
           "format": "date-time",
           "format": "date-time",
           "x-go-name": "LastLogin"
         },
+        "location": {
+          "description": "the user's location",
+          "type": "string",
+          "x-go-name": "Location"
+        },
         "login": {
           "description": "the user's username",
           "type": "string",
           "description": "Is user restricted",
           "type": "boolean",
           "x-go-name": "Restricted"
+        },
+        "website": {
+          "description": "the user's website",
+          "type": "string",
+          "x-go-name": "Website"
         }
       },
       "x-go-package": "code.gitea.io/gitea/modules/structs"