Add support for established chat user mode. #1587 (#1681)

* Add support for established user mode. #1587

* Tweak tests

* Tweak tests

* Update test

* Fix test.
This commit is contained in:
Gabe Kangas
2022-03-06 23:26:24 -08:00
committed by GitHub
parent 123d559ba4
commit e0a75d5d54
10 changed files with 245 additions and 83 deletions

View File

@@ -11,6 +11,7 @@ import (
"github.com/gorilla/websocket"
"github.com/owncast/owncast/config"
"github.com/owncast/owncast/core/chat/events"
"github.com/owncast/owncast/core/data"
"github.com/owncast/owncast/core/user"
@@ -330,6 +331,16 @@ func SendActionToUser(userID string, text string) error {
}
func (s *Server) eventReceived(event chatClientEvent) {
c := event.client
u := c.User
// If established chat user only mode is enabled and the user is not old
// enough then reject this event and send them an informative message.
if u != nil && data.GetChatEstbalishedUsersOnlyMode() && time.Since(event.client.User.CreatedAt) < config.GetDefaults().ChatEstablishedUserModeTimeDuration && !u.IsModerator() {
s.sendActionToClient(c, "You have not been an established chat participant long enough to take part in chat. Please enjoy the stream and try again later.")
return
}
var typecheck map[string]interface{}
if err := json.Unmarshal(event.data, &typecheck); err != nil {
log.Debugln(err)