commit 9318feefa24114185b504d5e00f0ea42b880ef45
parent 60d092124f136aa9c7cad610553aaab107f86d3b
Author: n0tr1v <n0tr1v@protonmail.com>
Date: Wed, 20 Dec 2023 10:44:37 -0500
allow poker table to have own chat room
Diffstat:
2 files changed, 9 insertions(+), 4 deletions(-)
diff --git a/pkg/web/handlers/poker.go b/pkg/web/handlers/poker.go
@@ -335,6 +335,11 @@ func PokerStreamHandler(c echo.Context) error {
return c.Redirect(http.StatusFound, "/")
}
+ chatRoomSlug := "general"
+ //if _, err := db.GetChatRoomByName(roomID.String()); err == nil {
+ // chatRoomSlug = roomID.String()
+ //}
+
roomTopic := roomID.Topic()
roomUserTopic := roomID.UserTopic(authUser.ID)
send := func(s string) { _, _ = c.Response().Write([]byte(s)) }
@@ -353,7 +358,7 @@ func PokerStreamHandler(c echo.Context) error {
sub := poker.PokerPubSub.Subscribe([]string{roomTopic, roomUserTopic})
defer sub.Close()
- send(poker.BuildBaseHtml(g, authUser))
+ send(poker.BuildBaseHtml(g, authUser, chatRoomSlug))
c.Response().Flush()
Loop:
diff --git a/pkg/web/handlers/poker/poker.go b/pkg/web/handlers/poker/poker.go
@@ -1593,7 +1593,7 @@ func buildGameDiv(g *PokerGame, authUser *database.User) (html string) {
return
}
-func BuildBaseHtml(g *PokerGame, authUser *database.User) (html string) {
+func BuildBaseHtml(g *PokerGame, authUser *database.User, chatRoomSlug string) (html string) {
ongoing := g.ongoing
roomID := g.roomID
html += hutils.HtmlCssReset
@@ -1604,8 +1604,8 @@ func BuildBaseHtml(g *PokerGame, authUser *database.User) (html string) {
html += buildSoundsHtml(authUser)
html += buildHelpHtml()
html += `<div id="chat-div">`
- html += ` <iframe id="chat-top-bar" name="iframe1" src="/api/v1/chat/top-bar/general" sandbox="allow-forms allow-scripts allow-same-origin allow-top-navigation-by-user-activation"></iframe>`
- html += ` <iframe id="chat-content" name="iframe2" src="/api/v1/chat/messages/general/stream?hrm=1&hactions=1&hide_ts=1"></iframe>`
+ html += ` <iframe id="chat-top-bar" name="iframe1" src="/api/v1/chat/top-bar/` + chatRoomSlug + `" sandbox="allow-forms allow-scripts allow-same-origin allow-top-navigation-by-user-activation"></iframe>`
+ html += ` <iframe id="chat-content" name="iframe2" src="/api/v1/chat/messages/` + chatRoomSlug + `/stream?hrm=1&hactions=1&hide_ts=1"></iframe>`
html += `</div>`
html += `<iframe src="/poker/` + roomID.String() + `/logs" id="eventLogs"></iframe>`