Skip to content

Commit

Permalink
option for custom design
Browse files Browse the repository at this point in the history
  • Loading branch information
jibon57 committed Jan 27, 2024
1 parent 4c2059d commit a3002c3
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 20 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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-20240126180030-8a3264fbcf0d
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
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -149,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-20240126180030-8a3264fbcf0d h1:3UaVkB1mvJM+MTOgKyYe1XmmH6DF8Sg21rAlFiu+OMY=
github.com/mynaparrot/plugnmeet-protocol v0.0.0-20240126180030-8a3264fbcf0d/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=
Expand Down
55 changes: 38 additions & 17 deletions pkg/controllers/bbb_api_wrapper.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand Down Expand Up @@ -158,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" {
Expand All @@ -167,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 || *roomMetadata.ExtraData == "" {
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
}
Expand All @@ -209,19 +218,31 @@ func HandleBBBJoin(c *fiber.Ctx) error {
return c.XML(bbbapiwrapper.CommonResponseMsg("FAILED", "error", err.Error()))
}

host := fmt.Sprintf("%s://%s", c.Protocol(), c.Hostname())
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" {
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("%s/?access_token=%s", host, token))
return c.Redirect(url)
}

func HandleBBBIsMeetingRunning(c *fiber.Ctx) error {
Expand Down

0 comments on commit a3002c3

Please sign in to comment.