Skip to content

Commit

Permalink
fix for npe on noop add source/tag/person to content_unit
Browse files Browse the repository at this point in the history
  • Loading branch information
edoshor committed Feb 14, 2019
1 parent 2d461ff commit bac0c28
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions api/rest.go
Original file line number Diff line number Diff line change
Expand Up @@ -483,7 +483,7 @@ func ContentUnitSourcesHandler(c *gin.Context) {
resp, err = handleContentUnitAddSource(c, tx, id, sourceID)
mustConcludeTx(tx, err)

if respCU, ok := resp.(*models.ContentUnit); ok && err == nil {
if respCU, ok := resp.(*models.ContentUnit); ok && err == nil && resp != nil {
emitEvents(c, events.ContentUnitSourcesChangeEvent(respCU))
}
case http.MethodDelete:
Expand Down Expand Up @@ -534,7 +534,7 @@ func ContentUnitTagsHandler(c *gin.Context) {
resp, err = handleContentUnitAddTag(c, tx, id, tagID)
mustConcludeTx(tx, err)

if respCU, ok := resp.(*models.ContentUnit); ok && err == nil {
if respCU, ok := resp.(*models.ContentUnit); ok && err == nil && resp != nil {
emitEvents(c, events.ContentUnitTagsChangeEvent(respCU))
}
case http.MethodDelete:
Expand Down Expand Up @@ -579,8 +579,8 @@ func ContentUnitPersonsHandler(c *gin.Context) {
resp, err = handleContentUnitAddPerson(c, tx, id, cup)
mustConcludeTx(tx, err)

if err == nil {
emitEvents(c, events.ContentUnitPersonsChangeEvent(resp.(*models.ContentUnit)))
if respCU, ok := resp.(*models.ContentUnit); ok && err == nil && resp != nil {
emitEvents(c, events.ContentUnitPersonsChangeEvent(respCU))
}
case http.MethodDelete:
personID, e := strconv.ParseInt(c.Param("personID"), 10, 0)
Expand Down

0 comments on commit bac0c28

Please sign in to comment.