Skip to content

Commit

Permalink
fix: missing EmptyTimeout & MaxParticipants in webhook
Browse files Browse the repository at this point in the history
  • Loading branch information
jibon57 committed Oct 21, 2024
1 parent 701b06c commit 879d5b1
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 15 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ require (
github.com/jordic/lti v0.0.0-20160211051708-2c756eacbab9
github.com/livekit/protocol v1.24.0
github.com/livekit/server-sdk-go/v2 v2.2.1
github.com/mynaparrot/plugnmeet-protocol v0.0.0-20241010090419-15d9b4302c20
github.com/mynaparrot/plugnmeet-protocol v0.0.0-20241021133642-dcc51f1d220c
github.com/nats-io/jwt/v2 v2.7.2
github.com/nats-io/nats.go v1.37.0
github.com/nats-io/nkeys v0.4.7
Expand Down
10 changes: 2 additions & 8 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,6 @@ github.com/frostbyte73/core v0.0.13 h1:W/NFPNiCkGTRzMWnCVptn6vX6Tr4a7LvN0RFc0xsC
github.com/frostbyte73/core v0.0.13/go.mod h1:XsOGqrqe/VEV7+8vJ+3a8qnCIXNbKsoEiu/czs7nrcU=
github.com/fsnotify/fsnotify v1.7.0 h1:8JEhPFa5W2WU7YfeZzPNqzMP6Lwt7L2715Ggo0nosvA=
github.com/fsnotify/fsnotify v1.7.0/go.mod h1:40Bi/Hjc2AVfZrqy+aj+yEI+/bRxZnMJyTJwOpGvigM=
github.com/gabriel-vasile/mimetype v1.4.5 h1:J7wGKdGu33ocBOhGy0z653k/lFKLFDPJMG8Gql0kxn4=
github.com/gabriel-vasile/mimetype v1.4.5/go.mod h1:ibHel+/kbxn9x2407k1izTA1S81ku1z/DlgOW2QE0M4=
github.com/gabriel-vasile/mimetype v1.4.6 h1:3+PzJTKLkvgjeTbts6msPJt4DixhT4YtFNf1gtGe3zc=
github.com/gabriel-vasile/mimetype v1.4.6/go.mod h1:JX1qVKqZd40hUPpAfiNTe0Sne7hdfKSbOqqmkq8GCXc=
github.com/gammazero/deque v0.2.1 h1:qSdsbG6pgp6nL7A0+K/B7s12mcCY/5l5SIUpMOl+dC0=
Expand Down Expand Up @@ -130,8 +128,8 @@ github.com/mattn/go-runewidth v0.0.16 h1:E5ScNMtiwvlvB5paMFdw9p4kSQzbXFikJ5SQO6T
github.com/mattn/go-runewidth v0.0.16/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w=
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 h1:C3w9PqII01/Oq1c1nUAm88MOHcQC9l5mIlSMApZMrHA=
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ=
github.com/mynaparrot/plugnmeet-protocol v0.0.0-20241010090419-15d9b4302c20 h1:0vkjpS6MmFwV4esALnbSgXieAkUtKhIcKvwYo7u8FHM=
github.com/mynaparrot/plugnmeet-protocol v0.0.0-20241010090419-15d9b4302c20/go.mod h1:eU5cr6DucIgiTtWnH4dsxVCdESwXnUOrcda71gyHnvI=
github.com/mynaparrot/plugnmeet-protocol v0.0.0-20241021133642-dcc51f1d220c h1:FyktHLFNkWngoBT2/mz+HfPosTD++6Ja1QUNqaddd+s=
github.com/mynaparrot/plugnmeet-protocol v0.0.0-20241021133642-dcc51f1d220c/go.mod h1:eU5cr6DucIgiTtWnH4dsxVCdESwXnUOrcda71gyHnvI=
github.com/nats-io/jwt/v2 v2.7.2 h1:SCRjfDLJ2q8naXp8YlGJJS5/yj3wGSODFYVi4nnwVMw=
github.com/nats-io/jwt/v2 v2.7.2/go.mod h1:kB6QUmqHG6Wdrzj0KP2L+OX4xiTPBeV+NHVstFaATXU=
github.com/nats-io/nats.go v1.37.0 h1:07rauXbVnnJvv1gfIyghFEo6lUcYRY0WXc3x7x0vUxE=
Expand Down Expand Up @@ -198,8 +196,6 @@ github.com/prometheus/procfs v0.15.1 h1:YagwOFzUgYfKKHX6Dr+sHT7km/hxC76UB0leargg
github.com/prometheus/procfs v0.15.1/go.mod h1:fB45yRUv8NstnjriLhBQLuOUt+WW4BsoGhij/e3PBqk=
github.com/puzpuzpuz/xsync/v3 v3.4.0 h1:DuVBAdXuGFHv8adVXjWWZ63pJq+NRXOWVXlKDBZ+mJ4=
github.com/puzpuzpuz/xsync/v3 v3.4.0/go.mod h1:VjzYrABPabuM4KyBh1Ftq6u8nhwY5tBPKP9jpmh0nnA=
github.com/redis/go-redis/v9 v9.6.1 h1:HHDteefn6ZkTtY5fGUE8tj8uy85AHk6zP7CpzIAM0y4=
github.com/redis/go-redis/v9 v9.6.1/go.mod h1:0C0c6ycQsdpVNQpxb1njEQIqkx5UcsM8FJCQLgE9+RA=
github.com/redis/go-redis/v9 v9.7.0 h1:HhLSs+B6O021gwzl+locl0zEDnyNkxMtf/Z3NNBMa9E=
github.com/redis/go-redis/v9 v9.7.0/go.mod h1:f6zhXITC7JUJIlPEiBOTXxJgPLdZcA93GewI7inzyWw=
github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
Expand Down Expand Up @@ -229,8 +225,6 @@ github.com/tinylib/msgp v1.1.9 h1:SHf3yoO2sGA0veCJeCBYLHuttAVFHGm2RHgNodW7wQU=
github.com/tinylib/msgp v1.1.9/go.mod h1:BCXGB54lDD8qUEPmiG0cQQUANC4IUQyB2ItS2UDlO/k=
github.com/twitchtv/twirp v8.1.3+incompatible h1:+F4TdErPgSUbMZMwp13Q/KgDVuI7HJXP61mNV3/7iuU=
github.com/twitchtv/twirp v8.1.3+incompatible/go.mod h1:RRJoFSAmTEh2weEqWtpPE3vFK5YBhA6bqp2l1kfCC5A=
github.com/urfave/cli/v2 v2.27.4 h1:o1owoI+02Eb+K107p27wEX9Bb8eqIoZCfLXloLUSWJ8=
github.com/urfave/cli/v2 v2.27.4/go.mod h1:m4QzxcD2qpra4z7WhzEGn74WZLViBnMpb1ToCAKdGRQ=
github.com/urfave/cli/v2 v2.27.5 h1:WoHEJLdsXr6dDWoJgMq/CboDmyY/8HMMH1fTECbih+w=
github.com/urfave/cli/v2 v2.27.5/go.mod h1:3Sevf16NykTbInEnD0yKkjDAeZDS0A6bzhBH5hrMvTQ=
github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6KllzawFIhcdPw=
Expand Down
14 changes: 8 additions & 6 deletions pkg/models/room_create.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ func (m *RoomModel) CreateRoom(r *plugnmeet.CreateRoomReq) (*plugnmeet.ActiveRoo
}

// create and send room_created webhook
go m.sendRoomCreatedWebhook(ari)
go m.sendRoomCreatedWebhook(ari, r.EmptyTimeout, r.MaxParticipants)

return ari, nil
}
Expand Down Expand Up @@ -212,7 +212,7 @@ func (m *RoomModel) prepareWhiteboardPreloadFile(meta *plugnmeet.RoomMetadata, r
log.Infoln(fmt.Sprintf("preloadFile: %s for roomId: %s had been processed successfully", *wbf.PreloadFile, roomId))
}

func (m *RoomModel) sendRoomCreatedWebhook(info *plugnmeet.ActiveRoomInfo) {
func (m *RoomModel) sendRoomCreatedWebhook(info *plugnmeet.ActiveRoomInfo, emptyTimeout, maxParticipants *uint32) {
n := helpers.GetWebhookNotifier(m.app)
if n != nil {
// register for event first
Expand All @@ -224,10 +224,12 @@ func (m *RoomModel) sendRoomCreatedWebhook(info *plugnmeet.ActiveRoomInfo) {
msg := &plugnmeet.CommonNotifyEvent{
Event: &e,
Room: &plugnmeet.NotifyEventRoom{
RoomId: &info.RoomId,
Sid: &info.Sid,
CreationTime: &cr,
Metadata: &info.Metadata,
RoomId: &info.RoomId,
Sid: &info.Sid,
CreationTime: &cr,
Metadata: &info.Metadata,
EmptyTimeout: emptyTimeout,
MaxParticipants: maxParticipants,
},
}

Expand Down
4 changes: 4 additions & 0 deletions pkg/models/webhook_room.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ func (m *WebhookModel) roomStarted(event *livekit.WebhookEvent) {
// otherwise some services may not be ready
event.Room.Metadata = rInfo.Metadata
event.Room.Sid = rInfo.RoomSid
event.Room.MaxParticipants = uint32(rInfo.MaxParticipants)
event.Room.EmptyTimeout = uint32(rInfo.EmptyTimeout)

// webhook notification
m.sendToWebhookNotifier(event)
Expand All @@ -90,6 +92,8 @@ func (m *WebhookModel) roomFinished(event *livekit.WebhookEvent) {

event.Room.Metadata = rInfo.Metadata
event.Room.Sid = rInfo.RoomSid
event.Room.MaxParticipants = uint32(rInfo.MaxParticipants)
event.Room.EmptyTimeout = uint32(rInfo.EmptyTimeout)

// we are introducing a new event name here
// because for our case we still have remaining tasks
Expand Down
4 changes: 4 additions & 0 deletions pkg/models/webhook_track.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ func (m *WebhookModel) trackPublished(event *livekit.WebhookEvent) {

event.Room.Sid = rInfo.RoomSid
event.Room.Metadata = rInfo.Metadata
event.Room.MaxParticipants = uint32(rInfo.MaxParticipants)
event.Room.EmptyTimeout = uint32(rInfo.EmptyTimeout)

// webhook notification
go m.sendToWebhookNotifier(event)
Expand Down Expand Up @@ -66,6 +68,8 @@ func (m *WebhookModel) trackUnpublished(event *livekit.WebhookEvent) {

event.Room.Sid = rInfo.RoomSid
event.Room.Metadata = rInfo.Metadata
event.Room.MaxParticipants = uint32(rInfo.MaxParticipants)
event.Room.EmptyTimeout = uint32(rInfo.EmptyTimeout)

// webhook notification
go m.sendToWebhookNotifier(event)
Expand Down
4 changes: 4 additions & 0 deletions pkg/models/webhook_user.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ func (m *WebhookModel) participantJoined(event *livekit.WebhookEvent) {

event.Room.Sid = rInfo.RoomSid
event.Room.Metadata = rInfo.Metadata
event.Room.MaxParticipants = uint32(rInfo.MaxParticipants)
event.Room.EmptyTimeout = uint32(rInfo.EmptyTimeout)

_, err = m.ds.IncrementOrDecrementNumParticipants(rInfo.RoomSid, "+")
if err != nil {
Expand All @@ -43,6 +45,8 @@ func (m *WebhookModel) participantLeft(event *livekit.WebhookEvent) {

event.Room.Sid = rInfo.RoomSid
event.Room.Metadata = rInfo.Metadata
event.Room.MaxParticipants = uint32(rInfo.MaxParticipants)
event.Room.EmptyTimeout = uint32(rInfo.EmptyTimeout)

_, err = m.ds.IncrementOrDecrementNumParticipants(rInfo.RoomSid, "-")
if err != nil {
Expand Down

0 comments on commit 879d5b1

Please sign in to comment.