code.gitea.io/gitea@v1.21.7/routers/api/v1/settings/settings.go (about)

     1  // Copyright 2020 The Gitea Authors. All rights reserved.
     2  // SPDX-License-Identifier: MIT
     3  
     4  package settings
     5  
     6  import (
     7  	"net/http"
     8  
     9  	"code.gitea.io/gitea/modules/context"
    10  	"code.gitea.io/gitea/modules/setting"
    11  	api "code.gitea.io/gitea/modules/structs"
    12  )
    13  
    14  // GetGeneralUISettings returns instance's global settings for ui
    15  func GetGeneralUISettings(ctx *context.APIContext) {
    16  	// swagger:operation GET /settings/ui settings getGeneralUISettings
    17  	// ---
    18  	// summary: Get instance's global settings for ui
    19  	// produces:
    20  	// - application/json
    21  	// responses:
    22  	//   "200":
    23  	//     "$ref": "#/responses/GeneralUISettings"
    24  	ctx.JSON(http.StatusOK, api.GeneralUISettings{
    25  		DefaultTheme:     setting.UI.DefaultTheme,
    26  		AllowedReactions: setting.UI.Reactions,
    27  		CustomEmojis:     setting.UI.CustomEmojis,
    28  	})
    29  }
    30  
    31  // GetGeneralAPISettings returns instance's global settings for api
    32  func GetGeneralAPISettings(ctx *context.APIContext) {
    33  	// swagger:operation GET /settings/api settings getGeneralAPISettings
    34  	// ---
    35  	// summary: Get instance's global settings for api
    36  	// produces:
    37  	// - application/json
    38  	// responses:
    39  	//   "200":
    40  	//     "$ref": "#/responses/GeneralAPISettings"
    41  	ctx.JSON(http.StatusOK, api.GeneralAPISettings{
    42  		MaxResponseItems:       setting.API.MaxResponseItems,
    43  		DefaultPagingNum:       setting.API.DefaultPagingNum,
    44  		DefaultGitTreesPerPage: setting.API.DefaultGitTreesPerPage,
    45  		DefaultMaxBlobSize:     setting.API.DefaultMaxBlobSize,
    46  	})
    47  }
    48  
    49  // GetGeneralRepoSettings returns instance's global settings for repositories
    50  func GetGeneralRepoSettings(ctx *context.APIContext) {
    51  	// swagger:operation GET /settings/repository settings getGeneralRepositorySettings
    52  	// ---
    53  	// summary: Get instance's global settings for repositories
    54  	// produces:
    55  	// - application/json
    56  	// responses:
    57  	//   "200":
    58  	//     "$ref": "#/responses/GeneralRepoSettings"
    59  	ctx.JSON(http.StatusOK, api.GeneralRepoSettings{
    60  		MirrorsDisabled:      !setting.Mirror.Enabled,
    61  		HTTPGitDisabled:      setting.Repository.DisableHTTPGit,
    62  		MigrationsDisabled:   setting.Repository.DisableMigrations,
    63  		StarsDisabled:        setting.Repository.DisableStars,
    64  		TimeTrackingDisabled: !setting.Service.EnableTimetracking,
    65  		LFSDisabled:          !setting.LFS.StartServer,
    66  	})
    67  }
    68  
    69  // GetGeneralAttachmentSettings returns instance's global settings for Attachment
    70  func GetGeneralAttachmentSettings(ctx *context.APIContext) {
    71  	// swagger:operation GET /settings/attachment settings getGeneralAttachmentSettings
    72  	// ---
    73  	// summary: Get instance's global settings for Attachment
    74  	// produces:
    75  	// - application/json
    76  	// responses:
    77  	//   "200":
    78  	//     "$ref": "#/responses/GeneralAttachmentSettings"
    79  	ctx.JSON(http.StatusOK, api.GeneralAttachmentSettings{
    80  		Enabled:      setting.Attachment.Enabled,
    81  		AllowedTypes: setting.Attachment.AllowedTypes,
    82  		MaxFiles:     setting.Attachment.MaxFiles,
    83  		MaxSize:      setting.Attachment.MaxSize,
    84  	})
    85  }