This commit is contained in:
Yvan
2026-09-22 20:20:23 +08:00
parent bf33e87d72
commit ceaea78b0f
42 changed files with 2845 additions and 154 deletions
+6 -4
View File
@@ -322,6 +322,11 @@ func (m *Manager) handleChat(session *melody.Session, payload chatSendPayload) {
m.send(session, "Error", map[string]any{"code": "CHAT_UNAVAILABLE", "message": "chat is only available in live rooms"})
return
}
available, err := m.roomCatalog.IsLive(context.Background(), roomID)
if err != nil || !available {
m.send(session, "Error", map[string]any{"code": "ROOM_UNAVAILABLE", "message": "live room is unavailable"})
return
}
item, err := m.chat.Send(context.Background(), roomID, p.userID, payload.Content)
if err != nil {
m.send(session, "Error", map[string]any{"code": "INVALID_CHAT", "message": err.Error()})
@@ -379,13 +384,10 @@ func (m *Manager) authorizeRoomPublisher(streamID string, userID uint) error {
if err != nil || id == 0 {
return errors.New("invalid live room stream id")
}
item, err := m.roomCatalog.Get(context.Background(), uint(id))
item, err := m.roomCatalog.GetPublic(context.Background(), uint(id))
if err != nil {
return errors.New("live room is unavailable")
}
if !item.Enabled {
return errors.New("live room is disabled")
}
if item.AnchorUserID != userID {
return errors.New("current user is not the room anchor")
}