dkforest

A forum and chat platform (onion)
git clone https://git.dasho.dev/n0tr1v/dkforest.git
Log | Files | Refs | LICENSE

streamModal.go (1171B)


      1 package streamModals
      2 
      3 import (
      4 	"dkforest/pkg/database"
      5 )
      6 
      7 type IStreamModal interface {
      8 	// Topics returns all the topics the modal is interested in
      9 	Topics() []string
     10 	// Handle a stream message
     11 	Handle(db *database.DkfDB, authUser database.IUserRenderMessage, topic, csrf string, msgTyp database.ChatMessageType, send func(string)) bool
     12 	// Implement interceptor
     13 	Show(database.UserID, database.RoomID, database.ChatMessageType)
     14 	Hide(database.UserID, database.RoomID)
     15 	Css() string
     16 }
     17 
     18 type StreamModal struct {
     19 	topics []string
     20 	idx    int
     21 	userID database.UserID
     22 	room   database.ChatRoom
     23 	name   string
     24 }
     25 
     26 func (m *StreamModal) Topics() []string {
     27 	return m.topics
     28 }
     29 
     30 func (m *StreamModal) showTopic(name string, userID database.UserID, roomID database.RoomID) string {
     31 	return m.topic(name, "show", userID, roomID)
     32 }
     33 
     34 func (m *StreamModal) hideTopic(name string, userID database.UserID, roomID database.RoomID) string {
     35 	return m.topic(name, "hide", userID, roomID)
     36 }
     37 
     38 func (_ *StreamModal) topic(name, action string, userID database.UserID, roomID database.RoomID) string {
     39 	return "modal_" + name + "_" + action + "_" + userID.String() + "_" + roomID.String()
     40 }