diff --git a/go.mod b/go.mod index 60c2ab94..409d9fd5 100644 --- a/go.mod +++ b/go.mod @@ -17,7 +17,7 @@ require ( github.com/jordic/lti v0.0.0-20160211051708-2c756eacbab9 github.com/livekit/protocol v1.9.4 github.com/livekit/server-sdk-go v1.1.6 - github.com/mynaparrot/plugnmeet-protocol v0.0.0-20240125144752-8aba23d35871 + github.com/mynaparrot/plugnmeet-protocol v0.0.0-20240127150229-a8869f5bcec6 github.com/redis/go-redis/v9 v9.4.0 github.com/sirupsen/logrus v1.9.3 github.com/stretchr/testify v1.8.4 diff --git a/go.sum b/go.sum index c978c519..72b85e66 100644 --- a/go.sum +++ b/go.sum @@ -96,8 +96,6 @@ github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/uuid v1.3.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/google/uuid v1.5.0 h1:1p67kYwdtXjb0gL0BPiP1Av9wiZPo5A8z2cWkTZ+eyU= -github.com/google/uuid v1.5.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/gorilla/websocket v1.5.1 h1:gmztn0JnHVt9JZquRuzLw3g4wouNVzKL15iLr/zn/QY= @@ -151,8 +149,8 @@ github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D github.com/mattn/go-runewidth v0.0.14/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w= github.com/mattn/go-runewidth v0.0.15 h1:UNAjwbU9l54TA3KzvqLGxwWjHmMgBUVhBiTjelZgg3U= github.com/mattn/go-runewidth v0.0.15/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w= -github.com/mynaparrot/plugnmeet-protocol v0.0.0-20240125144752-8aba23d35871 h1:jU7arvZebhFhGi0aVz/Y61KIoaNY8pmLz8WdebzY2pQ= -github.com/mynaparrot/plugnmeet-protocol v0.0.0-20240125144752-8aba23d35871/go.mod h1:oya2zc+VZQr/FfT8K0PmqRO8SsEOr2n0C/SIJL/joSU= +github.com/mynaparrot/plugnmeet-protocol v0.0.0-20240127150229-a8869f5bcec6 h1:b+m1MWRSbl9wH5/xErS4SVuY5HPNlpJeiUIrIAVHOKI= +github.com/mynaparrot/plugnmeet-protocol v0.0.0-20240127150229-a8869f5bcec6/go.mod h1:oya2zc+VZQr/FfT8K0PmqRO8SsEOr2n0C/SIJL/joSU= github.com/nats-io/nats.go v1.32.0 h1:Bx9BZS+aXYlxW08k8Gd3yR2s73pV5XSoAQUyp1Kwvp0= github.com/nats-io/nats.go v1.32.0/go.mod h1:Ubdu4Nh9exXdSz0RVWRFBbRfrbSxOYd26oF0wkWclB8= github.com/nats-io/nkeys v0.4.7 h1:RwNJbbIdYCoClSDNY7QVKZlyb/wfT6ugvFCiKy6vDvI= diff --git a/pkg/controllers/bbb_api_wrapper.go b/pkg/controllers/bbb_api_wrapper.go index 59ec4721..b823dd43 100644 --- a/pkg/controllers/bbb_api_wrapper.go +++ b/pkg/controllers/bbb_api_wrapper.go @@ -11,6 +11,7 @@ import ( "github.com/mynaparrot/plugnmeet-protocol/plugnmeet" "github.com/mynaparrot/plugnmeet-server/pkg/config" "github.com/mynaparrot/plugnmeet-server/pkg/models" + "google.golang.org/protobuf/encoding/protojson" "strings" "time" ) @@ -123,12 +124,15 @@ func HandleBBBCreate(c *fiber.Ctx) error { ReturnCode: "SUCCESS", MessageKey: "success", Message: msg, - MeetingID: room.Name, + MeetingID: q.MeetingID, InternalMeetingID: room.Sid, + ParentMeetingID: "bbb-none", AttendeePW: q.AttendeePW, ModeratorPW: q.ModeratorPW, CreateTime: room.GetCreationTime() * 1000, CreateDate: time.Unix(room.GetCreationTime(), 0).Format(time.RFC1123), + VoiceBridge: q.VoiceBridge, + DialNumber: q.DialNumber, }) } @@ -155,6 +159,27 @@ func HandleBBBJoin(c *fiber.Ctx) error { return c.XML(bbbapiwrapper.CommonResponseMsg("FAILED", "error", "meeting is not active")) } + roomMetadata, err := rs.UnmarshalRoomMetadata(metadata[roomId]) + if err != nil { + return c.XML(bbbapiwrapper.CommonResponseMsg("FAILED", "error", err.Error())) + } + + ex := new(bbbapiwrapper.CreateMeetingDefaultExtraData) + customDesign := new(plugnmeet.CustomDesignParams) + if roomMetadata.ExtraData != nil { + err = json.Unmarshal([]byte(*roomMetadata.ExtraData), ex) + if err != nil { + return c.XML(bbbapiwrapper.CommonResponseMsg("FAILED", "error", err.Error())) + } + if ex.Logo != "" { + customDesign.CustomLogo = &ex.Logo + } + styleUrl := c.Query("userdata-bbb_custom_style_url") + if styleUrl != "" { + customDesign.CustomCssUrl = &styleUrl + } + } + isAdmin := false if q.Role != "" { if strings.ToUpper(q.Role) == "MODERATOR" { @@ -164,22 +189,9 @@ func HandleBBBJoin(c *fiber.Ctx) error { if q.Password == "" { return c.XML(bbbapiwrapper.CommonResponseMsg("FAILED", "error", "password missing")) } - - roomMetadata, err := rs.UnmarshalRoomMetadata(metadata[roomId]) - if err != nil { - return c.XML(bbbapiwrapper.CommonResponseMsg("FAILED", "error", err.Error())) - } - if roomMetadata.ExtraData == nil { return c.XML(bbbapiwrapper.CommonResponseMsg("FAILED", "error", "did not found extra data")) } - - ex := new(bbbapiwrapper.CreateMeetingDefaultExtraData) - err = json.Unmarshal([]byte(*roomMetadata.ExtraData), ex) - if err != nil { - return c.XML(bbbapiwrapper.CommonResponseMsg("FAILED", "error", err.Error())) - } - if subtle.ConstantTimeCompare([]byte(q.Password), []byte(ex.ModeratorPW)) == 1 { isAdmin = true } @@ -206,19 +218,31 @@ func HandleBBBJoin(c *fiber.Ctx) error { return c.XML(bbbapiwrapper.CommonResponseMsg("FAILED", "error", err.Error())) } + url := fmt.Sprintf("%s://%s/?access_token=%s", c.Protocol(), c.Hostname(), token) + if customDesign != nil && customDesign.String() != "" { + op := protojson.MarshalOptions{ + EmitUnpopulated: false, + UseProtoNames: true, + } + cd, err := op.Marshal(customDesign) + if err != nil { + return err + } + url = fmt.Sprintf("%s&custom_design=%s", url, string(cd)) + } + if strings.ToLower(q.Redirect) == "false" { - host := fmt.Sprintf("%s://%s", c.Protocol(), c.Hostname()) return c.XML(bbbapiwrapper.JoinMeetingRes{ ReturnCode: "SUCCESS", MessageKey: "success", Message: "You have joined successfully", MeetingID: q.MeetingID, SessionToken: token, - Url: fmt.Sprintf("%s/?access_token=%s", host, token), + Url: url, }) } - return c.Redirect(fmt.Sprintf("/?access_token=%s", token)) + return c.Redirect(url) } func HandleBBBIsMeetingRunning(c *fiber.Ctx) error {