feat(chat): add support for chat part messages. Closes #3201 (#3291)

This commit is contained in:
Gabe Kangas
2023-09-10 10:58:11 -07:00
committed by GitHub
parent fb0ac492b2
commit 169c11596c
15 changed files with 205 additions and 21 deletions

View File

@@ -8,6 +8,8 @@ const (
MessageSent EventType = "CHAT"
// UserJoined is the event sent when a chat user join action takes place.
UserJoined EventType = "USER_JOINED"
// UserParted is the event sent when a chat user part action takes place.
UserParted EventType = "USER_PARTED"
// UserNameChanged is the event sent when a chat username change takes place.
UserNameChanged EventType = "NAME_CHANGE"
// UserColorChanged is the event sent when a chat user color change takes place.

View File

@@ -0,0 +1,17 @@
package events
// UserPartEvent is the event fired when a user leaves chat.
type UserPartEvent struct {
Event
UserEvent
}
// GetBroadcastPayload will return the object to send to all chat users.
func (e *UserPartEvent) GetBroadcastPayload() EventPayload {
return EventPayload{
"type": UserParted,
"id": e.ID,
"timestamp": e.Timestamp,
"user": e.User,
}
}