* Add support for established user mode. #1587 * Tweak tests * Tweak tests * Update test * Fix test.
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user