Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix compatible issues #410

Merged
merged 5 commits into from
Jan 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions pkg/controllers/bbb_api_wrapper.go
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ func HandleBBBGetMeetingInfo(c *fiber.Ctx) error {

m := models.NewRoomAuthModel()
status, msg, res := m.GetActiveRoomInfo(&plugnmeet.GetActiveRoomInfoReq{
RoomId: q.MeetingID,
RoomId: bbbapiwrapper.CheckMeetingIdToMatchFormat(q.MeetingID),
})

if !status {
Expand All @@ -220,10 +220,10 @@ func HandleBBBGetMeetingInfo(c *fiber.Ctx) error {

func HandleBBBGetMeetings(c *fiber.Ctx) error {
m := models.NewRoomAuthModel()
status, msg, rooms := m.GetActiveRoomsInfo()
_, _, rooms := m.GetActiveRoomsInfo()

if !status {
return c.XML(bbbapiwrapper.CommonResponseMsg("FAILED", "noMeetings", msg))
if rooms == nil {
return c.XML(bbbapiwrapper.CommonResponseMsg("SUCCESS", "noMeetings", "no meetings were found on this server"))
}

var meetings []*bbbapiwrapper.MeetingInfo
Expand All @@ -248,7 +248,7 @@ func HandleBBBEndMeetings(c *fiber.Ctx) error {

m := models.NewRoomAuthModel()
status, msg := m.EndRoom(&plugnmeet.RoomEndReq{
RoomId: q.MeetingID,
RoomId: bbbapiwrapper.CheckMeetingIdToMatchFormat(q.MeetingID),
})

if !status {
Expand Down
31 changes: 20 additions & 11 deletions pkg/models/bbb_api_wrapper.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,31 +36,34 @@ func (m *BBBApiWrapperModel) GetRecordings(host string, r *bbbapiwrapper.GetReco

var query []string
var args []interface{}
oriIds := make(map[string]string)
if r.Limit == 0 {
// let's make it 50 for BBB as not all plugin still support pagination
r.Limit = 50
}

query = append(query, "SELECT a.record_id, a.room_id, a.room_sid, a.file_path, a.size, a.published, b.room_title, b.joined_participants, b.created, b.ended")

if r.MeetingID != "" {
mIds := strings.Split(r.MeetingID, ",")
q := "FROM " + m.app.FormatDBTable("recordings") + " AS a LEFT JOIN " + m.app.FormatDBTable("room_info") + " AS b ON a.room_sid = b.sid WHERE room_id IN (?" + strings.Repeat(",?", len(mIds)-1) + ")"
if r.RecordID != "" {
rIds := strings.Split(r.RecordID, ",")
q := "FROM " + m.app.FormatDBTable("recordings") + " AS a LEFT JOIN " + m.app.FormatDBTable("room_info") + " AS b ON a.room_sid = b.sid WHERE record_id IN (?" + strings.Repeat(",?", len(rIds)-1) + ")"

query = append(query, q, "ORDER BY a.id DESC LIMIT ?,?")
for _, rd := range mIds {
for _, rd := range rIds {
args = append(args, rd)
}
args = append(args, r.Offset)
args = append(args, r.Limit)

} else if r.RecordID != "" {
rIds := strings.Split(r.RecordID, ",")
q := "FROM " + m.app.FormatDBTable("recordings") + " AS a LEFT JOIN " + m.app.FormatDBTable("room_info") + " AS b ON a.room_sid = b.sid WHERE room_id IN (?" + strings.Repeat(",?", len(rIds)-1) + ")"
} else if r.MeetingID != "" {
mIds := strings.Split(r.MeetingID, ",")
q := "FROM " + m.app.FormatDBTable("recordings") + " AS a LEFT JOIN " + m.app.FormatDBTable("room_info") + " AS b ON a.room_sid = b.sid WHERE room_id IN (?" + strings.Repeat(",?", len(mIds)-1) + ")"

query = append(query, q, "ORDER BY a.id DESC LIMIT ?,?")
for _, rd := range rIds {
args = append(args, rd)
for _, rd := range mIds {
fId := bbbapiwrapper.CheckMeetingIdToMatchFormat(rd)
oriIds[fId] = rd
args = append(args, fId)
}
args = append(args, r.Offset)
args = append(args, r.Limit)
Expand All @@ -83,15 +86,21 @@ func (m *BBBApiWrapperModel) GetRecordings(host string, r *bbbapiwrapper.GetReco
for rows.Next() {
var recording bbbapiwrapper.RecordingInfo
var rSid sql.NullString
var path, created, ended string
var meetingId, path, created, ended string
var size float64
var participants int64

err = rows.Scan(&recording.RecordID, &recording.MeetingID, &rSid, &path, &size, &recording.Published, &recording.Name, &participants, &created, &ended)
err = rows.Scan(&recording.RecordID, &meetingId, &rSid, &path, &size, &recording.Published, &recording.Name, &participants, &created, &ended)
if err != nil {
log.Errorln(err)
continue
}

if oriIds[meetingId] != "" {
recording.MeetingID = oriIds[meetingId]
} else {
recording.MeetingID = meetingId
}
recording.InternalMeetingID = rSid.String

// for path, let's create a download link directly
Expand Down