-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implementation of discord webhook #2402
Conversation
models/webhook_discord.go
Outdated
|
||
"code.gitea.io/git" | ||
api "code.gitea.io/sdk/gitea" | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove this empty line.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
above is other packages on gitea, below is submodule on gitea repo.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Got it 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In that case they should be in the other order.
builtin
local package
external package
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@bkcsoft done.
models/webhook.go
Outdated
case DISCORD: | ||
payloader, err = GetDiscordPayload(p, event, w.Meta) | ||
if err != nil { | ||
return fmt.Errorf("GetSlackPayload: %v", err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Discord, not Slack
models/webhook_discord.go
Outdated
} | ||
|
||
var ( | ||
successColor = color("#1ac600") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do you add the # when it's anyway removed within the color function?
models/webhook_discord.go
Outdated
failedColor = color("#ff3232") | ||
) | ||
|
||
// SetSecret sets the slack secret |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Slack?
models/webhook_discord.go
Outdated
func (p *DiscordPayload) SetSecret(_ string) {} | ||
|
||
// JSONPayload Marshals the SlackPayload to json | ||
func (p *DiscordPayload) JSONPayload() ([]byte, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Slack?
models/webhook_discord.go
Outdated
}, nil | ||
} | ||
|
||
// GetDiscordPayload converts a slack webhook into a SlackPayload |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Slack?
models/webhook_discord.go
Outdated
|
||
discord := &DiscordMeta{} | ||
if err := json.Unmarshal([]byte(meta), &discord); err != nil { | ||
return s, errors.New("GetSlackPayload meta json:" + err.Error()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Slack?
modules/auth/repo_form.go
Outdated
@@ -183,6 +183,19 @@ func (f *NewSlackHookForm) Validate(ctx *macaron.Context, errs binding.Errors) b | |||
return validate(errs, ctx.Data, f, ctx.Locale) | |||
} | |||
|
|||
// NewDiscordHookForm form for creating slack hook |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Slack?
routers/repo/webhook.go
Outdated
@@ -443,6 +503,48 @@ func SlackHooksEditPost(ctx *context.Context, form auth.NewSlackHookForm) { | |||
ctx.Redirect(fmt.Sprintf("%s/settings/hooks/%d", orCtx.Link, w.ID)) | |||
} | |||
|
|||
// DiscordHooksEditPost response for editing slack hook |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Slack?
<input id="payload_url" name="payload_url" type="url" value="{{.Webhook.URL}}" autofocus required> | ||
</div> | ||
<div class="field"> | ||
<label for="username">{{.i18n.Tr "repo.settings.slack_username"}}</label> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Slack?
</div> | ||
<div class="field"> | ||
<label for="icon_url">{{.i18n.Tr "repo.settings.slack_icon_url"}}</label> | ||
<input id="icon_url" name="icon_url" value="{{.DiscordHook.IconURL}}" placeholder="e.g. https://example.com/img/favicon.png"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Slack?
@tboerger done. |
LGTM |
d0f0791
to
9810a44
Compare
rebased. |
LGTM |
@lunny (or any merger) Please squash the commits into 1 commit |
will fix #2191