Skip to content

Commit ae62b1a

Browse files
committed
fix: use brightspace default img path
1 parent 91c4a78 commit ae62b1a

File tree

1 file changed

+8
-27
lines changed

1 file changed

+8
-27
lines changed

Diff for: provider-middleware/brightspace_data.go

+8-27
Original file line numberDiff line numberDiff line change
@@ -70,23 +70,16 @@ func (srv *BrightspaceService) IntoCourse(bsCourse BrightspaceCourse) *models.Co
7070
defer response.Body.Close()
7171
var imgPath string
7272
var imgBytes []byte
73-
switch response.StatusCode {
74-
case http.StatusNotFound:
75-
log.Warnf("status of not found returned, using default Brightspace image, url is %v", courseImageUrl)
76-
imgBytes, err = getDefaultImg()
77-
case http.StatusOK:
73+
if response.StatusCode == http.StatusOK {
7874
imgBytes, err = io.ReadAll(response.Body)
79-
case http.StatusForbidden:
80-
log.Warnf("status of forbidden returned, using default Brightspace image, url is %v", courseImageUrl)
81-
imgBytes, err = getDefaultImg()
82-
}
83-
if err != nil {
84-
imgPath = ""
85-
} else {
86-
imgPath, err = UploadBrightspaceImage(imgBytes, id)
8775
if err != nil {
88-
log.Errorf("error during upload of Brightspace image to UnlockEd, id used was: %v error is %v", id, err)
89-
imgPath = ""
76+
imgPath = "/brightspace.jpg"
77+
} else {
78+
imgPath, err = UploadBrightspaceImage(imgBytes, id)
79+
if err != nil {
80+
log.Errorf("error during upload of Brightspace image to UnlockEd, id used was: %v error is %v", id, err)
81+
imgPath = "/brightspace.png"
82+
}
9083
}
9184
}
9285
course := models.Course{
@@ -152,18 +145,6 @@ func UploadBrightspaceImage(imgBytes []byte, bsCourseId string) (string, error)
152145
return urlRes.Data.Url, nil
153146
}
154147

155-
func getDefaultImg() ([]byte, error) {
156-
defaultImgPath := "default-images/brightspace.jpg"
157-
bsFile, err := os.Open(defaultImgPath)
158-
if err != nil {
159-
log.Errorf("error opening file %v, error is: %v", defaultImgPath, err)
160-
return nil, err
161-
}
162-
defer bsFile.Close()
163-
imgBytes, err := io.ReadAll(bsFile)
164-
return imgBytes, err
165-
}
166-
167148
func (srv *BrightspaceService) getPluginId(pluginName string) (string, error) {
168149
var pluginId string
169150
resp, err := srv.SendRequest(DataSetsEndpoint)

0 commit comments

Comments
 (0)