mirror of
https://github.com/owncast/owncast.git
synced 2024-11-25 22:31:09 +03:00
10055664bb
* add tests for webhook events * atomic.Uint32 is not in Go 1.18
35 lines
906 B
Go
35 lines
906 B
Go
package chat
|
|
|
|
import (
|
|
"errors"
|
|
|
|
"github.com/owncast/owncast/core/chat/events"
|
|
"github.com/owncast/owncast/core/webhooks"
|
|
log "github.com/sirupsen/logrus"
|
|
)
|
|
|
|
// SetMessagesVisibility will set the visibility of multiple messages by ID.
|
|
func SetMessagesVisibility(messageIDs []string, visibility bool) error {
|
|
// Save new message visibility
|
|
if err := saveMessageVisibility(messageIDs, visibility); err != nil {
|
|
log.Errorln(err)
|
|
return err
|
|
}
|
|
|
|
// Send an event letting the chat clients know to hide or show
|
|
// the messages.
|
|
event := events.SetMessageVisibilityEvent{
|
|
MessageIDs: messageIDs,
|
|
Visible: visibility,
|
|
}
|
|
event.Event.SetDefaults()
|
|
|
|
payload := event.GetBroadcastPayload()
|
|
if err := _server.Broadcast(payload); err != nil {
|
|
return errors.New("error broadcasting message visibility payload " + err.Error())
|
|
}
|
|
|
|
webhooks.SendChatEventSetMessageVisibility(event)
|
|
|
|
return nil
|
|
}
|