31 lines
673 B
Go
31 lines
673 B
Go
package meet
|
|
|
|
import (
|
|
"strings"
|
|
"time"
|
|
|
|
"github.com/google/uuid"
|
|
|
|
meetpkg "github.com/ultisuite/ulti-backend/internal/meet"
|
|
)
|
|
|
|
type Service struct {
|
|
cfg *meetpkg.Config
|
|
}
|
|
|
|
func NewService(cfg *meetpkg.Config) *Service {
|
|
return &Service{cfg: cfg}
|
|
}
|
|
|
|
func (s *Service) CreateRoom(name string, user *meetpkg.UserInfo) (*meetpkg.RoomToken, error) {
|
|
roomID := uuid.New().String()[:8]
|
|
if strings.TrimSpace(name) != "" {
|
|
roomID = strings.TrimSpace(name)
|
|
}
|
|
return s.cfg.GenerateToken(roomID, user, 24*time.Hour)
|
|
}
|
|
|
|
func (s *Service) GetToken(roomID string, user *meetpkg.UserInfo) (*meetpkg.RoomToken, error) {
|
|
return s.cfg.GenerateToken(roomID, user, 4*time.Hour)
|
|
}
|