Skip to content

Commit

Permalink
fix(update): few clean ups
Browse files Browse the repository at this point in the history
  • Loading branch information
jibon57 committed Dec 14, 2024
1 parent 8a27d92 commit 3d632ec
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 43 deletions.
13 changes: 4 additions & 9 deletions pkg/controllers/analytics.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,12 @@ import (
"google.golang.org/protobuf/encoding/protojson"
)

var op = protojson.UnmarshalOptions{
DiscardUnknown: true,
}

func HandleFetchAnalytics(c *fiber.Ctx) error {
req := new(plugnmeet.FetchAnalyticsReq)
op := protojson.UnmarshalOptions{
DiscardUnknown: true,
}
err := op.Unmarshal(c.Body(), req)
if err != nil {
return utils.SendCommonProtoJsonResponse(c, false, err.Error())
Expand Down Expand Up @@ -48,9 +49,6 @@ func HandleFetchAnalytics(c *fiber.Ctx) error {

func HandleDeleteAnalytics(c *fiber.Ctx) error {
req := new(plugnmeet.DeleteAnalyticsReq)
op := protojson.UnmarshalOptions{
DiscardUnknown: true,
}
err := op.Unmarshal(c.Body(), req)
if err != nil {
return utils.SendCommonProtoJsonResponse(c, false, err.Error())
Expand All @@ -75,9 +73,6 @@ func HandleDeleteAnalytics(c *fiber.Ctx) error {

func HandleGetAnalyticsDownloadToken(c *fiber.Ctx) error {
req := new(plugnmeet.GetAnalyticsDownloadTokenReq)
op := protojson.UnmarshalOptions{
DiscardUnknown: true,
}
err := op.Unmarshal(c.Body(), req)
if err != nil {
return utils.SendCommonProtoJsonResponse(c, false, err.Error())
Expand Down
13 changes: 0 additions & 13 deletions pkg/controllers/recording.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,10 @@ import (
"github.com/mynaparrot/plugnmeet-protocol/plugnmeet"
"github.com/mynaparrot/plugnmeet-protocol/utils"
"github.com/mynaparrot/plugnmeet-server/pkg/models"
"google.golang.org/protobuf/encoding/protojson"
)

func HandleFetchRecordings(c *fiber.Ctx) error {
req := new(plugnmeet.FetchRecordingsReq)
op := protojson.UnmarshalOptions{
DiscardUnknown: true,
}
err := op.Unmarshal(c.Body(), req)
if err != nil {
return utils.SendCommonProtoJsonResponse(c, false, err.Error())
Expand Down Expand Up @@ -47,9 +43,6 @@ func HandleFetchRecordings(c *fiber.Ctx) error {

func HandleRecordingInfo(c *fiber.Ctx) error {
req := new(plugnmeet.RecordingInfoReq)
op := protojson.UnmarshalOptions{
DiscardUnknown: true,
}
err := op.Unmarshal(c.Body(), req)
if err != nil {
return utils.SendCommonProtoJsonResponse(c, false, err.Error())
Expand All @@ -75,9 +68,6 @@ func HandleRecordingInfo(c *fiber.Ctx) error {

func HandleDeleteRecording(c *fiber.Ctx) error {
req := new(plugnmeet.DeleteRecordingReq)
op := protojson.UnmarshalOptions{
DiscardUnknown: true,
}
err := op.Unmarshal(c.Body(), req)
if err != nil {
return utils.SendCommonProtoJsonResponse(c, false, err.Error())
Expand All @@ -102,9 +92,6 @@ func HandleDeleteRecording(c *fiber.Ctx) error {

func HandleGetDownloadToken(c *fiber.Ctx) error {
req := new(plugnmeet.GetDownloadTokenReq)
op := protojson.UnmarshalOptions{
DiscardUnknown: true,
}
err := op.Unmarshal(c.Body(), req)
if err != nil {
return utils.SendCommonProtoJsonResponse(c, false, err.Error())
Expand Down
16 changes: 0 additions & 16 deletions pkg/controllers/room.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,10 @@ import (
"github.com/mynaparrot/plugnmeet-protocol/plugnmeet"
"github.com/mynaparrot/plugnmeet-protocol/utils"
"github.com/mynaparrot/plugnmeet-server/pkg/models"
"google.golang.org/protobuf/encoding/protojson"
"google.golang.org/protobuf/proto"
)

func HandleRoomCreate(c *fiber.Ctx) error {
op := protojson.UnmarshalOptions{
DiscardUnknown: true,
}
req := new(plugnmeet.CreateRoomReq)
err := op.Unmarshal(c.Body(), req)
if err != nil {
Expand Down Expand Up @@ -46,9 +42,6 @@ func HandleRoomCreate(c *fiber.Ctx) error {

func HandleIsRoomActive(c *fiber.Ctx) error {
req := new(plugnmeet.IsRoomActiveReq)
op := protojson.UnmarshalOptions{
DiscardUnknown: true,
}
err := op.Unmarshal(c.Body(), req)
if err != nil {
return utils.SendCommonProtoJsonResponse(c, false, err.Error())
Expand All @@ -70,9 +63,6 @@ func HandleIsRoomActive(c *fiber.Ctx) error {

func HandleGetActiveRoomInfo(c *fiber.Ctx) error {
req := new(plugnmeet.GetActiveRoomInfoReq)
op := protojson.UnmarshalOptions{
DiscardUnknown: true,
}
err := op.Unmarshal(c.Body(), req)
if err != nil {
return c.JSON(fiber.Map{
Expand Down Expand Up @@ -115,9 +105,6 @@ func HandleGetActiveRoomsInfo(c *fiber.Ctx) error {

func HandleEndRoom(c *fiber.Ctx) error {
req := new(plugnmeet.RoomEndReq)
op := protojson.UnmarshalOptions{
DiscardUnknown: true,
}
err := op.Unmarshal(c.Body(), req)
if err != nil {
return utils.SendCommonProtoJsonResponse(c, false, err.Error())
Expand All @@ -139,9 +126,6 @@ func HandleEndRoom(c *fiber.Ctx) error {

func HandleFetchPastRooms(c *fiber.Ctx) error {
req := new(plugnmeet.FetchPastRoomsReq)
op := protojson.UnmarshalOptions{
DiscardUnknown: true,
}
err := op.Unmarshal(c.Body(), req)
if err != nil {
return utils.SendCommonProtoJsonResponse(c, false, err.Error())
Expand Down
6 changes: 1 addition & 5 deletions pkg/controllers/webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"github.com/gofiber/fiber/v2"
"github.com/livekit/protocol/livekit"
"github.com/mynaparrot/plugnmeet-server/pkg/models"
"google.golang.org/protobuf/encoding/protojson"
)

func HandleWebhook(c *fiber.Ctx) error {
Expand All @@ -23,12 +22,9 @@ func HandleWebhook(c *fiber.Ctx) error {
return c.SendStatus(fiber.StatusForbidden)
}

op := protojson.UnmarshalOptions{
DiscardUnknown: true,
}
event := new(livekit.WebhookEvent)
if err = op.Unmarshal(data, event); err != nil {
return c.SendStatus(fiber.StatusForbidden)
return c.SendStatus(fiber.StatusUnprocessableEntity)
}

mm := models.NewWebhookModel(nil, nil, nil)
Expand Down

0 comments on commit 3d632ec

Please sign in to comment.