Skip to content

Commit

Permalink
fixed non-critical meiliStreamFilter bug, not filtering out private s…
Browse files Browse the repository at this point in the history
…treams
  • Loading branch information
karjo24 committed Sep 30, 2024
1 parent 94dae04 commit 8295e42
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion api/search.go
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,19 @@ func meiliSubtitleFilter(user *model.User, courses []model.Course) string {
// Checking eligibility to search for courses and validation of model.Semester format is the caller's responsibility
func meiliStreamFilter(c *gin.Context, user *model.User, semester model.Semester, courses []model.Course) string {
if courses != nil {
return fmt.Sprintf("courseID IN %s", courseSliceToString(courses))
administeredCourses := make([]model.Course, 0)
nonAdministeredCourses := make([]model.Course, 0)
for _, course := range courses {
if user.IsAdminOfCourse(course) {
administeredCourses = append(administeredCourses, course)
} else {
nonAdministeredCourses = append(nonAdministeredCourses, course)
}
}
if user == nil || len(administeredCourses) == 0 {
return fmt.Sprintf("courseID IN %s AND private = 0", courseSliceToString(nonAdministeredCourses))
}
return fmt.Sprintf("(courseID IN %s OR (courseID IN %s AND private = 0))", courseSliceToString(administeredCourses), courseSliceToString(nonAdministeredCourses))
}

semesterFilter := fmt.Sprintf("(year = %d AND semester = \"%s\")", semester.Year, semester.TeachingTerm)
Expand Down

0 comments on commit 8295e42

Please sign in to comment.