mirror of
https://github.com/go-gitea/gitea
synced 2025-12-07 13:28:25 +00:00
Merge branch 'main' into feature/bots
This commit is contained in:
@@ -4,6 +4,7 @@
|
||||
package composer
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"net/http"
|
||||
@@ -200,7 +201,11 @@ func UploadPackage(ctx *context.Context) {
|
||||
|
||||
cp, err := composer_module.ParsePackage(buf, buf.Size())
|
||||
if err != nil {
|
||||
apiError(ctx, http.StatusBadRequest, err)
|
||||
if errors.Is(err, util.ErrInvalidArgument) {
|
||||
apiError(ctx, http.StatusBadRequest, err)
|
||||
} else {
|
||||
apiError(ctx, http.StatusInternalServerError, err)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
package helm
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"net/http"
|
||||
@@ -163,7 +164,11 @@ func UploadPackage(ctx *context.Context) {
|
||||
|
||||
metadata, err := helm_module.ParseChartArchive(buf)
|
||||
if err != nil {
|
||||
apiError(ctx, http.StatusBadRequest, err)
|
||||
if errors.Is(err, util.ErrInvalidArgument) {
|
||||
apiError(ctx, http.StatusBadRequest, err)
|
||||
} else {
|
||||
apiError(ctx, http.StatusInternalServerError, err)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
@@ -158,7 +158,11 @@ func DownloadPackageFileByName(ctx *context.Context) {
|
||||
func UploadPackage(ctx *context.Context) {
|
||||
npmPackage, err := npm_module.ParsePackage(ctx.Req.Body)
|
||||
if err != nil {
|
||||
apiError(ctx, http.StatusBadRequest, err)
|
||||
if errors.Is(err, util.ErrInvalidArgument) {
|
||||
apiError(ctx, http.StatusBadRequest, err)
|
||||
} else {
|
||||
apiError(ctx, http.StatusInternalServerError, err)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
@@ -411,7 +411,11 @@ func UploadSymbolPackage(ctx *context.Context) {
|
||||
|
||||
pdbs, err := nuget_module.ExtractPortablePdb(buf, buf.Size())
|
||||
if err != nil {
|
||||
apiError(ctx, http.StatusBadRequest, err)
|
||||
if errors.Is(err, util.ErrInvalidArgument) {
|
||||
apiError(ctx, http.StatusBadRequest, err)
|
||||
} else {
|
||||
apiError(ctx, http.StatusInternalServerError, err)
|
||||
}
|
||||
return
|
||||
}
|
||||
defer pdbs.Close()
|
||||
@@ -507,7 +511,7 @@ func processUploadedFile(ctx *context.Context, expectedType nuget_module.Package
|
||||
|
||||
np, err := nuget_module.ParsePackageMetaData(buf, buf.Size())
|
||||
if err != nil {
|
||||
if err == nuget_module.ErrMissingNuspecFile || err == nuget_module.ErrNuspecFileTooLarge || err == nuget_module.ErrNuspecInvalidID || err == nuget_module.ErrNuspecInvalidVersion {
|
||||
if errors.Is(err, util.ErrInvalidArgument) {
|
||||
apiError(ctx, http.StatusBadRequest, err)
|
||||
} else {
|
||||
apiError(ctx, http.StatusInternalServerError, err)
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
package pub
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"net/http"
|
||||
@@ -19,6 +20,7 @@ import (
|
||||
packages_module "code.gitea.io/gitea/modules/packages"
|
||||
pub_module "code.gitea.io/gitea/modules/packages/pub"
|
||||
"code.gitea.io/gitea/modules/setting"
|
||||
"code.gitea.io/gitea/modules/util"
|
||||
"code.gitea.io/gitea/routers/api/packages/helper"
|
||||
packages_service "code.gitea.io/gitea/services/packages"
|
||||
)
|
||||
@@ -173,7 +175,11 @@ func UploadPackageFile(ctx *context.Context) {
|
||||
|
||||
pck, err := pub_module.ParsePackage(buf)
|
||||
if err != nil {
|
||||
apiError(ctx, http.StatusInternalServerError, err)
|
||||
if errors.Is(err, util.ErrInvalidArgument) {
|
||||
apiError(ctx, http.StatusBadRequest, err)
|
||||
} else {
|
||||
apiError(ctx, http.StatusInternalServerError, err)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@ package rubygems
|
||||
import (
|
||||
"compress/gzip"
|
||||
"compress/zlib"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"net/http"
|
||||
@@ -217,7 +218,11 @@ func UploadPackageFile(ctx *context.Context) {
|
||||
|
||||
rp, err := rubygems_module.ParsePackageMetaData(buf)
|
||||
if err != nil {
|
||||
apiError(ctx, http.StatusInternalServerError, err)
|
||||
if errors.Is(err, util.ErrInvalidArgument) {
|
||||
apiError(ctx, http.StatusBadRequest, err)
|
||||
} else {
|
||||
apiError(ctx, http.StatusInternalServerError, err)
|
||||
}
|
||||
return
|
||||
}
|
||||
if _, err := buf.Seek(0, io.SeekStart); err != nil {
|
||||
|
||||
@@ -6,12 +6,12 @@ package org
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"code.gitea.io/gitea/models/webhook"
|
||||
webhook_model "code.gitea.io/gitea/models/webhook"
|
||||
"code.gitea.io/gitea/modules/context"
|
||||
api "code.gitea.io/gitea/modules/structs"
|
||||
"code.gitea.io/gitea/modules/web"
|
||||
"code.gitea.io/gitea/routers/api/v1/utils"
|
||||
"code.gitea.io/gitea/services/convert"
|
||||
webhook_service "code.gitea.io/gitea/services/webhook"
|
||||
)
|
||||
|
||||
// ListHooks list an organziation's webhooks
|
||||
@@ -39,18 +39,18 @@ func ListHooks(ctx *context.APIContext) {
|
||||
// "200":
|
||||
// "$ref": "#/responses/HookList"
|
||||
|
||||
opts := &webhook.ListWebhookOptions{
|
||||
opts := &webhook_model.ListWebhookOptions{
|
||||
ListOptions: utils.GetListOptions(ctx),
|
||||
OrgID: ctx.Org.Organization.ID,
|
||||
}
|
||||
|
||||
count, err := webhook.CountWebhooksByOpts(opts)
|
||||
count, err := webhook_model.CountWebhooksByOpts(opts)
|
||||
if err != nil {
|
||||
ctx.InternalServerError(err)
|
||||
return
|
||||
}
|
||||
|
||||
orgHooks, err := webhook.ListWebhooksByOpts(ctx, opts)
|
||||
orgHooks, err := webhook_model.ListWebhooksByOpts(ctx, opts)
|
||||
if err != nil {
|
||||
ctx.InternalServerError(err)
|
||||
return
|
||||
@@ -58,7 +58,7 @@ func ListHooks(ctx *context.APIContext) {
|
||||
|
||||
hooks := make([]*api.Hook, len(orgHooks))
|
||||
for i, hook := range orgHooks {
|
||||
hooks[i], err = convert.ToHook(ctx.Org.Organization.AsUser().HomeLink(), hook)
|
||||
hooks[i], err = webhook_service.ToHook(ctx.Org.Organization.AsUser().HomeLink(), hook)
|
||||
if err != nil {
|
||||
ctx.InternalServerError(err)
|
||||
return
|
||||
@@ -99,7 +99,7 @@ func GetHook(ctx *context.APIContext) {
|
||||
return
|
||||
}
|
||||
|
||||
apiHook, err := convert.ToHook(org.AsUser().HomeLink(), hook)
|
||||
apiHook, err := webhook_service.ToHook(org.AsUser().HomeLink(), hook)
|
||||
if err != nil {
|
||||
ctx.InternalServerError(err)
|
||||
return
|
||||
@@ -200,8 +200,8 @@ func DeleteHook(ctx *context.APIContext) {
|
||||
|
||||
org := ctx.Org.Organization
|
||||
hookID := ctx.ParamsInt64(":id")
|
||||
if err := webhook.DeleteWebhookByOrgID(org.ID, hookID); err != nil {
|
||||
if webhook.IsErrWebhookNotExist(err) {
|
||||
if err := webhook_model.DeleteWebhookByOrgID(org.ID, hookID); err != nil {
|
||||
if webhook_model.IsErrWebhookNotExist(err) {
|
||||
ctx.NotFound()
|
||||
} else {
|
||||
ctx.Error(http.StatusInternalServerError, "DeleteWebhookByOrgID", err)
|
||||
|
||||
@@ -14,6 +14,7 @@ import (
|
||||
"code.gitea.io/gitea/modules/setting"
|
||||
api "code.gitea.io/gitea/modules/structs"
|
||||
"code.gitea.io/gitea/modules/web"
|
||||
webhook_module "code.gitea.io/gitea/modules/webhook"
|
||||
"code.gitea.io/gitea/routers/api/v1/utils"
|
||||
"code.gitea.io/gitea/services/convert"
|
||||
webhook_service "code.gitea.io/gitea/services/webhook"
|
||||
@@ -68,7 +69,7 @@ func ListHooks(ctx *context.APIContext) {
|
||||
|
||||
apiHooks := make([]*api.Hook, len(hooks))
|
||||
for i := range hooks {
|
||||
apiHooks[i], err = convert.ToHook(ctx.Repo.RepoLink, hooks[i])
|
||||
apiHooks[i], err = webhook_service.ToHook(ctx.Repo.RepoLink, hooks[i])
|
||||
if err != nil {
|
||||
ctx.InternalServerError(err)
|
||||
return
|
||||
@@ -115,7 +116,7 @@ func GetHook(ctx *context.APIContext) {
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
apiHook, err := convert.ToHook(repo.RepoLink, hook)
|
||||
apiHook, err := webhook_service.ToHook(repo.RepoLink, hook)
|
||||
if err != nil {
|
||||
ctx.InternalServerError(err)
|
||||
return
|
||||
@@ -176,7 +177,7 @@ func TestHook(ctx *context.APIContext) {
|
||||
commit := convert.ToPayloadCommit(ctx.Repo.Repository, ctx.Repo.Commit)
|
||||
|
||||
commitID := ctx.Repo.Commit.ID.String()
|
||||
if err := webhook_service.PrepareWebhook(ctx, hook, webhook.HookEventPush, &api.PushPayload{
|
||||
if err := webhook_service.PrepareWebhook(ctx, hook, webhook_module.HookEventPush, &api.PushPayload{
|
||||
Ref: ref,
|
||||
Before: commitID,
|
||||
After: commitID,
|
||||
|
||||
@@ -345,10 +345,11 @@ func CreatePushMirror(ctx *context.APIContext, mirrorOption *api.CreatePushMirro
|
||||
}
|
||||
|
||||
pushMirror := &repo_model.PushMirror{
|
||||
RepoID: repo.ID,
|
||||
Repo: repo,
|
||||
RemoteName: fmt.Sprintf("remote_mirror_%s", remoteSuffix),
|
||||
Interval: interval,
|
||||
RepoID: repo.ID,
|
||||
Repo: repo,
|
||||
RemoteName: fmt.Sprintf("remote_mirror_%s", remoteSuffix),
|
||||
Interval: interval,
|
||||
SyncOnCommit: mirrorOption.SyncOnCommit,
|
||||
}
|
||||
|
||||
if err = repo_model.InsertPushMirror(ctx, pushMirror); err != nil {
|
||||
|
||||
@@ -13,7 +13,7 @@ import (
|
||||
"code.gitea.io/gitea/modules/json"
|
||||
api "code.gitea.io/gitea/modules/structs"
|
||||
"code.gitea.io/gitea/modules/util"
|
||||
"code.gitea.io/gitea/services/convert"
|
||||
webhook_module "code.gitea.io/gitea/modules/webhook"
|
||||
webhook_service "code.gitea.io/gitea/services/webhook"
|
||||
)
|
||||
|
||||
@@ -98,7 +98,7 @@ func AddRepoHook(ctx *context.APIContext, form *api.CreateHookOption) {
|
||||
// toAPIHook converts the hook to its API representation.
|
||||
// If there is an error, write to `ctx` accordingly. Return (hook, ok)
|
||||
func toAPIHook(ctx *context.APIContext, repoLink string, hook *webhook.Webhook) (*api.Hook, bool) {
|
||||
apiHook, err := convert.ToHook(repoLink, hook)
|
||||
apiHook, err := webhook_service.ToHook(repoLink, hook)
|
||||
if err != nil {
|
||||
ctx.Error(http.StatusInternalServerError, "ToHook", err)
|
||||
return nil, false
|
||||
@@ -127,9 +127,9 @@ func addHook(ctx *context.APIContext, form *api.CreateHookOption, orgID, repoID
|
||||
ContentType: webhook.ToHookContentType(form.Config["content_type"]),
|
||||
Secret: form.Config["secret"],
|
||||
HTTPMethod: "POST",
|
||||
HookEvent: &webhook.HookEvent{
|
||||
HookEvent: &webhook_module.HookEvent{
|
||||
ChooseEvents: true,
|
||||
HookEvents: webhook.HookEvents{
|
||||
HookEvents: webhook_module.HookEvents{
|
||||
Create: util.IsStringInSlice(string(webhook.HookEventCreate), form.Events, true),
|
||||
Delete: util.IsStringInSlice(string(webhook.HookEventDelete), form.Events, true),
|
||||
Fork: util.IsStringInSlice(string(webhook.HookEventFork), form.Events, true),
|
||||
@@ -160,7 +160,7 @@ func addHook(ctx *context.APIContext, form *api.CreateHookOption, orgID, repoID
|
||||
ctx.Error(http.StatusInternalServerError, "SetHeaderAuthorization", err)
|
||||
return nil, false
|
||||
}
|
||||
if w.Type == webhook.SLACK {
|
||||
if w.Type == webhook_module.SLACK {
|
||||
channel, ok := form.Config["channel"]
|
||||
if !ok {
|
||||
ctx.Error(http.StatusUnprocessableEntity, "", "Missing config option: channel")
|
||||
@@ -253,7 +253,7 @@ func editHook(ctx *context.APIContext, form *api.EditHookOption, w *webhook.Webh
|
||||
w.ContentType = webhook.ToHookContentType(ct)
|
||||
}
|
||||
|
||||
if w.Type == webhook.SLACK {
|
||||
if w.Type == webhook_module.SLACK {
|
||||
if channel, ok := form.Config["channel"]; ok {
|
||||
meta, err := json.Marshal(&webhook_service.SlackMeta{
|
||||
Channel: channel,
|
||||
|
||||
@@ -121,6 +121,7 @@ func GlobalInitInstalled(ctx context.Context) {
|
||||
log.Info("Log path: %s", setting.LogRootPath)
|
||||
log.Info("Configuration file: %s", setting.CustomConf)
|
||||
log.Info("Run Mode: %s", util.ToTitleCase(setting.RunMode))
|
||||
log.Info("Gitea v%s%s", setting.AppVer, setting.AppBuiltWith)
|
||||
|
||||
// Setup i18n
|
||||
translation.InitLocales(ctx)
|
||||
|
||||
+23
-22
@@ -23,6 +23,7 @@ import (
|
||||
api "code.gitea.io/gitea/modules/structs"
|
||||
"code.gitea.io/gitea/modules/util"
|
||||
"code.gitea.io/gitea/modules/web"
|
||||
webhook_module "code.gitea.io/gitea/modules/webhook"
|
||||
"code.gitea.io/gitea/services/convert"
|
||||
"code.gitea.io/gitea/services/forms"
|
||||
webhook_service "code.gitea.io/gitea/services/webhook"
|
||||
@@ -119,7 +120,7 @@ func checkHookType(ctx *context.Context) string {
|
||||
// WebhooksNew render creating webhook page
|
||||
func WebhooksNew(ctx *context.Context) {
|
||||
ctx.Data["Title"] = ctx.Tr("repo.settings.add_webhook")
|
||||
ctx.Data["Webhook"] = webhook.Webhook{HookEvent: &webhook.HookEvent{}}
|
||||
ctx.Data["Webhook"] = webhook.Webhook{HookEvent: &webhook_module.HookEvent{}}
|
||||
|
||||
orCtx, err := getOrgRepoCtx(ctx)
|
||||
if err != nil {
|
||||
@@ -154,12 +155,12 @@ func WebhooksNew(ctx *context.Context) {
|
||||
}
|
||||
|
||||
// ParseHookEvent convert web form content to webhook.HookEvent
|
||||
func ParseHookEvent(form forms.WebhookForm) *webhook.HookEvent {
|
||||
return &webhook.HookEvent{
|
||||
func ParseHookEvent(form forms.WebhookForm) *webhook_module.HookEvent {
|
||||
return &webhook_module.HookEvent{
|
||||
PushOnly: form.PushOnly(),
|
||||
SendEverything: form.SendEverything(),
|
||||
ChooseEvents: form.ChooseEvents(),
|
||||
HookEvents: webhook.HookEvents{
|
||||
HookEvents: webhook_module.HookEvents{
|
||||
Create: form.Create,
|
||||
Delete: form.Delete,
|
||||
Fork: form.Fork,
|
||||
@@ -201,7 +202,7 @@ func createWebhook(ctx *context.Context, params webhookParams) {
|
||||
ctx.Data["Title"] = ctx.Tr("repo.settings.add_webhook")
|
||||
ctx.Data["PageIsSettingsHooks"] = true
|
||||
ctx.Data["PageIsSettingsHooksNew"] = true
|
||||
ctx.Data["Webhook"] = webhook.Webhook{HookEvent: &webhook.HookEvent{}}
|
||||
ctx.Data["Webhook"] = webhook.Webhook{HookEvent: &webhook_module.HookEvent{}}
|
||||
ctx.Data["HookType"] = params.Type
|
||||
|
||||
orCtx, err := getOrgRepoCtx(ctx)
|
||||
@@ -326,7 +327,7 @@ func giteaHookParams(ctx *context.Context) webhookParams {
|
||||
}
|
||||
|
||||
return webhookParams{
|
||||
Type: webhook.GITEA,
|
||||
Type: webhook_module.GITEA,
|
||||
URL: form.PayloadURL,
|
||||
ContentType: contentType,
|
||||
Secret: form.Secret,
|
||||
@@ -354,7 +355,7 @@ func gogsHookParams(ctx *context.Context) webhookParams {
|
||||
}
|
||||
|
||||
return webhookParams{
|
||||
Type: webhook.GOGS,
|
||||
Type: webhook_module.GOGS,
|
||||
URL: form.PayloadURL,
|
||||
ContentType: contentType,
|
||||
Secret: form.Secret,
|
||||
@@ -376,7 +377,7 @@ func discordHookParams(ctx *context.Context) webhookParams {
|
||||
form := web.GetForm(ctx).(*forms.NewDiscordHookForm)
|
||||
|
||||
return webhookParams{
|
||||
Type: webhook.DISCORD,
|
||||
Type: webhook_module.DISCORD,
|
||||
URL: form.PayloadURL,
|
||||
ContentType: webhook.ContentTypeJSON,
|
||||
WebhookForm: form.WebhookForm,
|
||||
@@ -401,7 +402,7 @@ func dingtalkHookParams(ctx *context.Context) webhookParams {
|
||||
form := web.GetForm(ctx).(*forms.NewDingtalkHookForm)
|
||||
|
||||
return webhookParams{
|
||||
Type: webhook.DINGTALK,
|
||||
Type: webhook_module.DINGTALK,
|
||||
URL: form.PayloadURL,
|
||||
ContentType: webhook.ContentTypeJSON,
|
||||
WebhookForm: form.WebhookForm,
|
||||
@@ -422,7 +423,7 @@ func telegramHookParams(ctx *context.Context) webhookParams {
|
||||
form := web.GetForm(ctx).(*forms.NewTelegramHookForm)
|
||||
|
||||
return webhookParams{
|
||||
Type: webhook.TELEGRAM,
|
||||
Type: webhook_module.TELEGRAM,
|
||||
URL: fmt.Sprintf("https://api.telegram.org/bot%s/sendMessage?chat_id=%s", url.PathEscape(form.BotToken), url.QueryEscape(form.ChatID)),
|
||||
ContentType: webhook.ContentTypeJSON,
|
||||
WebhookForm: form.WebhookForm,
|
||||
@@ -447,7 +448,7 @@ func matrixHookParams(ctx *context.Context) webhookParams {
|
||||
form := web.GetForm(ctx).(*forms.NewMatrixHookForm)
|
||||
|
||||
return webhookParams{
|
||||
Type: webhook.MATRIX,
|
||||
Type: webhook_module.MATRIX,
|
||||
URL: fmt.Sprintf("%s/_matrix/client/r0/rooms/%s/send/m.room.message", form.HomeserverURL, url.PathEscape(form.RoomID)),
|
||||
ContentType: webhook.ContentTypeJSON,
|
||||
HTTPMethod: http.MethodPut,
|
||||
@@ -474,7 +475,7 @@ func mSTeamsHookParams(ctx *context.Context) webhookParams {
|
||||
form := web.GetForm(ctx).(*forms.NewMSTeamsHookForm)
|
||||
|
||||
return webhookParams{
|
||||
Type: webhook.MSTEAMS,
|
||||
Type: webhook_module.MSTEAMS,
|
||||
URL: form.PayloadURL,
|
||||
ContentType: webhook.ContentTypeJSON,
|
||||
WebhookForm: form.WebhookForm,
|
||||
@@ -495,7 +496,7 @@ func slackHookParams(ctx *context.Context) webhookParams {
|
||||
form := web.GetForm(ctx).(*forms.NewSlackHookForm)
|
||||
|
||||
return webhookParams{
|
||||
Type: webhook.SLACK,
|
||||
Type: webhook_module.SLACK,
|
||||
URL: form.PayloadURL,
|
||||
ContentType: webhook.ContentTypeJSON,
|
||||
WebhookForm: form.WebhookForm,
|
||||
@@ -522,7 +523,7 @@ func feishuHookParams(ctx *context.Context) webhookParams {
|
||||
form := web.GetForm(ctx).(*forms.NewFeishuHookForm)
|
||||
|
||||
return webhookParams{
|
||||
Type: webhook.FEISHU,
|
||||
Type: webhook_module.FEISHU,
|
||||
URL: form.PayloadURL,
|
||||
ContentType: webhook.ContentTypeJSON,
|
||||
WebhookForm: form.WebhookForm,
|
||||
@@ -543,7 +544,7 @@ func wechatworkHookParams(ctx *context.Context) webhookParams {
|
||||
form := web.GetForm(ctx).(*forms.NewWechatWorkHookForm)
|
||||
|
||||
return webhookParams{
|
||||
Type: webhook.WECHATWORK,
|
||||
Type: webhook_module.WECHATWORK,
|
||||
URL: form.PayloadURL,
|
||||
ContentType: webhook.ContentTypeJSON,
|
||||
WebhookForm: form.WebhookForm,
|
||||
@@ -564,7 +565,7 @@ func packagistHookParams(ctx *context.Context) webhookParams {
|
||||
form := web.GetForm(ctx).(*forms.NewPackagistHookForm)
|
||||
|
||||
return webhookParams{
|
||||
Type: webhook.PACKAGIST,
|
||||
Type: webhook_module.PACKAGIST,
|
||||
URL: fmt.Sprintf("https://packagist.org/api/update-package?username=%s&apiToken=%s", url.QueryEscape(form.Username), url.QueryEscape(form.APIToken)),
|
||||
ContentType: webhook.ContentTypeJSON,
|
||||
WebhookForm: form.WebhookForm,
|
||||
@@ -603,15 +604,15 @@ func checkWebhook(ctx *context.Context) (*orgRepoCtx, *webhook.Webhook) {
|
||||
|
||||
ctx.Data["HookType"] = w.Type
|
||||
switch w.Type {
|
||||
case webhook.SLACK:
|
||||
case webhook_module.SLACK:
|
||||
ctx.Data["SlackHook"] = webhook_service.GetSlackHook(w)
|
||||
case webhook.DISCORD:
|
||||
case webhook_module.DISCORD:
|
||||
ctx.Data["DiscordHook"] = webhook_service.GetDiscordHook(w)
|
||||
case webhook.TELEGRAM:
|
||||
case webhook_module.TELEGRAM:
|
||||
ctx.Data["TelegramHook"] = webhook_service.GetTelegramHook(w)
|
||||
case webhook.MATRIX:
|
||||
case webhook_module.MATRIX:
|
||||
ctx.Data["MatrixHook"] = webhook_service.GetMatrixHook(w)
|
||||
case webhook.PACKAGIST:
|
||||
case webhook_module.PACKAGIST:
|
||||
ctx.Data["PackagistHook"] = webhook_service.GetPackagistHook(w)
|
||||
}
|
||||
|
||||
@@ -688,7 +689,7 @@ func TestWebhook(ctx *context.Context) {
|
||||
Pusher: apiUser,
|
||||
Sender: apiUser,
|
||||
}
|
||||
if err := webhook_service.PrepareWebhook(ctx, w, webhook.HookEventPush, p); err != nil {
|
||||
if err := webhook_service.PrepareWebhook(ctx, w, webhook_module.HookEventPush, p); err != nil {
|
||||
ctx.Flash.Error("PrepareWebhook: " + err.Error())
|
||||
ctx.Status(http.StatusInternalServerError)
|
||||
} else {
|
||||
|
||||
@@ -26,7 +26,7 @@ func CodeSearch(ctx *context.Context) {
|
||||
|
||||
ctx.Data["IsPackageEnabled"] = setting.Packages.Enabled
|
||||
ctx.Data["IsRepoIndexerEnabled"] = setting.Indexer.RepoIndexerEnabled
|
||||
ctx.Data["Title"] = ctx.Tr("code.title")
|
||||
ctx.Data["Title"] = ctx.Tr("explore.code")
|
||||
ctx.Data["ContextUser"] = ctx.ContextUser
|
||||
|
||||
language := ctx.FormTrim("l")
|
||||
|
||||
@@ -99,14 +99,18 @@ func KeysPost(ctx *context.Context) {
|
||||
loadKeysData(ctx)
|
||||
ctx.Data["Err_Content"] = true
|
||||
ctx.Data["Err_Signature"] = true
|
||||
ctx.Data["KeyID"] = err.(asymkey_model.ErrGPGInvalidTokenSignature).ID
|
||||
keyID := err.(asymkey_model.ErrGPGInvalidTokenSignature).ID
|
||||
ctx.Data["KeyID"] = keyID
|
||||
ctx.Data["PaddedKeyID"] = asymkey_model.PaddedKeyID(keyID)
|
||||
ctx.RenderWithErr(ctx.Tr("settings.gpg_invalid_token_signature"), tplSettingsKeys, &form)
|
||||
case asymkey_model.IsErrGPGNoEmailFound(err):
|
||||
loadKeysData(ctx)
|
||||
|
||||
ctx.Data["Err_Content"] = true
|
||||
ctx.Data["Err_Signature"] = true
|
||||
ctx.Data["KeyID"] = err.(asymkey_model.ErrGPGNoEmailFound).ID
|
||||
keyID := err.(asymkey_model.ErrGPGNoEmailFound).ID
|
||||
ctx.Data["KeyID"] = keyID
|
||||
ctx.Data["PaddedKeyID"] = asymkey_model.PaddedKeyID(keyID)
|
||||
ctx.RenderWithErr(ctx.Tr("settings.gpg_no_key_email_found"), tplSettingsKeys, &form)
|
||||
default:
|
||||
ctx.ServerError("AddPublicKey", err)
|
||||
@@ -138,7 +142,9 @@ func KeysPost(ctx *context.Context) {
|
||||
loadKeysData(ctx)
|
||||
ctx.Data["VerifyingID"] = form.KeyID
|
||||
ctx.Data["Err_Signature"] = true
|
||||
ctx.Data["KeyID"] = err.(asymkey_model.ErrGPGInvalidTokenSignature).ID
|
||||
keyID := err.(asymkey_model.ErrGPGInvalidTokenSignature).ID
|
||||
ctx.Data["KeyID"] = keyID
|
||||
ctx.Data["PaddedKeyID"] = asymkey_model.PaddedKeyID(keyID)
|
||||
ctx.RenderWithErr(ctx.Tr("settings.gpg_invalid_token_signature"), tplSettingsKeys, &form)
|
||||
default:
|
||||
ctx.ServerError("VerifyGPG", err)
|
||||
|
||||
Reference in New Issue
Block a user