@@ -2,11 +2,14 @@ package controllers
22
33import (
44 "fmt"
5+ "net/url"
6+ "strings"
57
68 "github.com/goccy/go-json"
79 "github.com/gofiber/fiber/v2"
810 "github.com/mynaparrot/plugnmeet-protocol/plugnmeet"
911 "github.com/mynaparrot/plugnmeet-protocol/utils"
12+ "github.com/mynaparrot/plugnmeet-server/pkg/config"
1013 "github.com/mynaparrot/plugnmeet-server/pkg/models"
1114)
1215
@@ -29,14 +32,16 @@ const (
2932
3033// LtiV1Controller holds dependencies for LTI v1 related handlers.
3134type LtiV1Controller struct {
35+ app * config.AppConfig
3236 LtiV1Model * models.LtiV1Model
3337 RoomModel * models.RoomModel
3438 RecordingModel * models.RecordingModel
3539}
3640
3741// NewLtiV1Controller creates a new LtiV1Controller.
38- func NewLtiV1Controller (lm * models.LtiV1Model , rm * models.RoomModel , recm * models.RecordingModel ) * LtiV1Controller {
42+ func NewLtiV1Controller (app * config. AppConfig , lm * models.LtiV1Model , rm * models.RoomModel , recm * models.RecordingModel ) * LtiV1Controller {
3943 return & LtiV1Controller {
44+ app : app ,
4045 LtiV1Model : lm ,
4146 RoomModel : rm ,
4247 RecordingModel : recm ,
@@ -50,11 +55,28 @@ func (lc *LtiV1Controller) HandleLTIV1Landing(c *fiber.Ctx) error {
5055 return c .Status (fiber .StatusUnauthorized ).SendString ("empty body" )
5156 }
5257
58+ hostName := c .Hostname ()
5359 proto := "https"
5460 if c .Protocol () == "http" {
5561 proto = "http"
5662 }
57- signingURL := fmt .Sprintf ("%s://%s%s" , proto , c .Hostname (), c .Path ())
63+ // fiber format: [host]:[port]
64+ parts := strings .Split (hostName , ":" )
65+
66+ // we can use BBBJoinHost to build correct info
67+ if lc .app .Client .BBBJoinHost != nil && * lc .app .Client .BBBJoinHost != "" {
68+ if u , err := url .Parse (* lc .app .Client .BBBJoinHost ); err == nil {
69+ hostName = u .Hostname ()
70+ proto = u .Scheme
71+
72+ if len (parts ) == 2 {
73+ // we'll use port from the request
74+ hostName = fmt .Sprintf ("%s:%s" , hostName , parts [1 ])
75+ }
76+ }
77+ }
78+
79+ signingURL := fmt .Sprintf ("%s://%s%s" , proto , hostName , c .Path ())
5880
5981 return lc .LtiV1Model .LTIV1Landing (c , string (b ), signingURL )
6082}
0 commit comments