c6c6f0233d
* Expand the linters and types of warnings to improve consistency and safety * Fail lint workflow if there are errors * golint has been replaced by revive * Hand-pick some of the default exclude list * Ignore error when trying to delete preview gif * Ignore linter warning opening playlist path * Rename user field Id -> ID * A bunch of renames to address linter warnings * Rename ChatClient -> Client per linter suggestion best practice * Rename ChatServer -> Server per linter suggestion best practice * More linter warning fixes * Add missing comments to all exported functions and properties
44 lines
1.1 KiB
Go
44 lines
1.1 KiB
Go
package webhooks
|
|
|
|
import (
|
|
"github.com/owncast/owncast/core/chat/events"
|
|
"github.com/owncast/owncast/models"
|
|
)
|
|
|
|
// SendChatEvent will send a chat event to webhook destinations.
|
|
func SendChatEvent(chatEvent *events.UserMessageEvent) {
|
|
webhookEvent := WebhookEvent{
|
|
Type: chatEvent.GetMessageType(),
|
|
EventData: &WebhookChatMessage{
|
|
User: chatEvent.User,
|
|
Body: chatEvent.Body,
|
|
RawBody: chatEvent.RawBody,
|
|
ID: chatEvent.ID,
|
|
Visible: chatEvent.HiddenAt == nil,
|
|
Timestamp: &chatEvent.Timestamp,
|
|
},
|
|
}
|
|
|
|
SendEventToWebhooks(webhookEvent)
|
|
}
|
|
|
|
// SendChatEventUsernameChanged will send a username changed event to webhook destinations.
|
|
func SendChatEventUsernameChanged(event events.NameChangeEvent) {
|
|
webhookEvent := WebhookEvent{
|
|
Type: models.UserNameChanged,
|
|
EventData: event,
|
|
}
|
|
|
|
SendEventToWebhooks(webhookEvent)
|
|
}
|
|
|
|
// SendChatEventUserJoined sends a webhook notifying that a user has joined.
|
|
func SendChatEventUserJoined(event events.UserJoinedEvent) {
|
|
webhookEvent := WebhookEvent{
|
|
Type: models.UserJoined,
|
|
EventData: event,
|
|
}
|
|
|
|
SendEventToWebhooks(webhookEvent)
|
|
}
|