Documentation ¶
Index ¶
- func Deliver(ctx context.Context, t *webhook_model.HookTask) error
- func Init() error
- func IsValidHookTaskType(name string) bool
- func IsValidSlackChannel(name string) bool
- func MatrixLinkToRef(repoURL, ref string) string
- func NewNotifier() notify_service.Notifier
- func PrepareWebhook(ctx context.Context, w *webhook_model.Webhook, ...) error
- func PrepareWebhooks(ctx context.Context, source EventSource, event webhook_module.HookEventType, ...) error
- func ReplayHookTask(ctx context.Context, w *webhook_model.Webhook, uuid string) error
- func SlackLinkFormatter(url, text string) string
- func SlackLinkToRef(repoURL, ref string) string
- func SlackShortTextFormatter(s string) string
- func SlackTextFormatter(s string) string
- func ToHook(repoLink string, w *webhook_model.Webhook) (*api.Hook, error)
- type DingtalkPayload
- type DiscordEmbed
- type DiscordEmbedAuthor
- type DiscordEmbedField
- type DiscordEmbedFooter
- type DiscordMeta
- type DiscordPayload
- type EventSource
- type FeishuPayload
- type MSTeamsAction
- type MSTeamsActionTarget
- type MSTeamsFact
- type MSTeamsPayload
- type MSTeamsSection
- type MatrixMeta
- type MatrixPayload
- type PackagistMeta
- type PackagistPayload
- type SlackAttachment
- type SlackMeta
- type SlackPayload
- type TelegramMeta
- type TelegramPayload
- type WechatworkPayload
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Deliver ¶
func Deliver(ctx context.Context, t *webhook_model.HookTask) error
Deliver creates the http.Request (depending on the webhook type), sends it and records the status and response.
func IsValidHookTaskType ¶
IsValidHookTaskType returns true if a webhook registered
func IsValidSlackChannel ¶ added in v1.17.4
IsValidSlackChannel validates a channel name conforms to what slack expects: https://api.slack.com/methods/conversations.rename#naming Conversation names can only contain lowercase letters, numbers, hyphens, and underscores, and must be 80 characters or less. Gitea accepts if it starts with a #.
func MatrixLinkToRef ¶
MatrixLinkToRef Matrix-formatter link to a repo ref
func NewNotifier ¶ added in v1.19.0
func NewNotifier() notify_service.Notifier
NewNotifier create a new webhookNotifier notifier
func PrepareWebhook ¶
func PrepareWebhook(ctx context.Context, w *webhook_model.Webhook, event webhook_module.HookEventType, p api.Payloader) error
PrepareWebhook creates a hook task and enqueues it for processing. The payload is saved as-is. The adjustments depending on the webhook type happen right before delivery, in the Deliver method.
func PrepareWebhooks ¶
func PrepareWebhooks(ctx context.Context, source EventSource, event webhook_module.HookEventType, p api.Payloader) error
PrepareWebhooks adds new webhooks to task queue for given payload.
func ReplayHookTask ¶ added in v1.16.0
ReplayHookTask replays a webhook task
func SlackLinkFormatter ¶
SlackLinkFormatter creates a link compatible with slack
func SlackLinkToRef ¶
SlackLinkToRef slack-formatter link to a repo ref
func SlackShortTextFormatter ¶
SlackShortTextFormatter replaces &, <, > with HTML characters
func SlackTextFormatter ¶
SlackTextFormatter replaces &, <, > with HTML characters see: https://api.slack.com/docs/formatting
Types ¶
type DingtalkPayload ¶
type DiscordEmbed ¶
type DiscordEmbed struct { Title string `json:"title"` Description string `json:"description"` URL string `json:"url"` Color int `json:"color"` Author DiscordEmbedAuthor `json:"author"` Fields []DiscordEmbedField `json:"fields"` }
DiscordEmbed is for Embed Structure
type DiscordEmbedAuthor ¶
type DiscordEmbedAuthor struct { Name string `json:"name"` URL string `json:"url"` IconURL string `json:"icon_url"` }
DiscordEmbedAuthor for Embed Author Structure
type DiscordEmbedField ¶
DiscordEmbedField for Embed Field Structure
type DiscordEmbedFooter ¶
type DiscordEmbedFooter struct {
}DiscordEmbedFooter for Embed Footer Structure.
type DiscordMeta ¶
DiscordMeta contains the discord metadata
func GetDiscordHook ¶
func GetDiscordHook(w *webhook_model.Webhook) *DiscordMeta
GetDiscordHook returns discord metadata
type DiscordPayload ¶
type DiscordPayload struct { Wait bool `json:"wait"` Content string `json:"content"` Username string `json:"username"` AvatarURL string `json:"avatar_url,omitempty"` TTS bool `json:"tts"` Embeds []DiscordEmbed `json:"embeds"` }
DiscordPayload represents
type EventSource ¶ added in v1.17.4
type EventSource struct { Repository *repo_model.Repository Owner *user_model.User }
EventSource represents the source of a webhook action. Repository and/or Owner must be set.
type FeishuPayload ¶
type FeishuPayload struct { MsgType string `json:"msg_type"` // text / post / image / share_chat / interactive / file /audio / media Content struct { Text string `json:"text"` } `json:"content"` }
FeishuPayload represents
type MSTeamsAction ¶
type MSTeamsAction struct { Type string `json:"@type"` Name string `json:"name"` Targets []MSTeamsActionTarget `json:"targets,omitempty"` }
MSTeamsAction is an action (creates buttons, links etc)
type MSTeamsActionTarget ¶
MSTeamsActionTarget is the actual link to follow, etc
type MSTeamsFact ¶
MSTeamsFact for Fact Structure
type MSTeamsPayload ¶
type MSTeamsPayload struct { Type string `json:"@type"` Context string `json:"@context"` ThemeColor string `json:"themeColor"` Title string `json:"title"` Summary string `json:"summary"` Sections []MSTeamsSection `json:"sections"` PotentialAction []MSTeamsAction `json:"potentialAction"` }
MSTeamsPayload is the parent object
type MSTeamsSection ¶
type MSTeamsSection struct { ActivityTitle string `json:"activityTitle"` ActivitySubtitle string `json:"activitySubtitle"` ActivityImage string `json:"activityImage"` Facts []MSTeamsFact `json:"facts"` Text string `json:"text"` }
MSTeamsSection is a MessageCard section
type MatrixMeta ¶
type MatrixMeta struct { HomeserverURL string `json:"homeserver_url"` Room string `json:"room_id"` MessageType int `json:"message_type"` }
MatrixMeta contains the Matrix metadata
func GetMatrixHook ¶
func GetMatrixHook(w *webhook_model.Webhook) *MatrixMeta
GetMatrixHook returns Matrix metadata
type MatrixPayload ¶ added in v1.17.4
type MatrixPayload struct { Body string `json:"body"` MsgType string `json:"msgtype"` Format string `json:"format"` FormattedBody string `json:"formatted_body"` Commits []*api.PayloadCommit `json:"io.gitea.commits,omitempty"` }
MatrixPayload contains payload for a Matrix room
type PackagistMeta ¶ added in v1.17.0
type PackagistMeta struct { Username string `json:"username"` APIToken string `json:"api_token"` PackageURL string `json:"package_url"` }
PackagistMeta contains the metadata for the webhook
func GetPackagistHook ¶ added in v1.17.0
func GetPackagistHook(w *webhook_model.Webhook) *PackagistMeta
GetPackagistHook returns packagist metadata
type PackagistPayload ¶ added in v1.17.0
type PackagistPayload struct { PackagistRepository struct { URL string `json:"url"` } `json:"repository"` }
PackagistPayload represents
type SlackAttachment ¶
type SlackAttachment struct { Fallback string `json:"fallback"` Color string `json:"color"` Title string `json:"title"` TitleLink string `json:"title_link"` Text string `json:"text"` }
SlackAttachment contains the slack message
type SlackMeta ¶
type SlackMeta struct { Channel string `json:"channel"` Username string `json:"username"` IconURL string `json:"icon_url"` Color string `json:"color"` }
SlackMeta contains the slack metadata
func GetSlackHook ¶
func GetSlackHook(w *webhook_model.Webhook) *SlackMeta
GetSlackHook returns slack metadata
type SlackPayload ¶
type SlackPayload struct { Channel string `json:"channel"` Text string `json:"text"` Username string `json:"username"` IconURL string `json:"icon_url"` UnfurlLinks int `json:"unfurl_links"` LinkNames int `json:"link_names"` Attachments []SlackAttachment `json:"attachments"` }
SlackPayload contains the information about the slack channel
type TelegramMeta ¶
type TelegramMeta struct { BotToken string `json:"bot_token"` ChatID string `json:"chat_id"` ThreadID string `json:"thread_id"` }
TelegramMeta contains the telegram metadata
func GetTelegramHook ¶
func GetTelegramHook(w *webhook_model.Webhook) *TelegramMeta
GetTelegramHook returns telegram metadata
type TelegramPayload ¶
type TelegramPayload struct { Message string `json:"text"` ParseMode string `json:"parse_mode"` DisableWebPreview bool `json:"disable_web_page_preview"` }
TelegramPayload represents
type WechatworkPayload ¶ added in v1.16.0
type WechatworkPayload struct { Msgtype string `json:"msgtype"` Text struct { Content string `json:"content"` MentionedList []string `json:"mentioned_list"` MentionedMobileList []string `json:"mentioned_mobile_list"` } `json:"text"` Markdown struct { Content string `json:"content"` } `json:"markdown"` }
WechatworkPayload represents