Add a check on type

This commit is contained in:
Brendan Abolivier 2017-08-16 14:12:37 +01:00
parent 10c2bb3743
commit 6ecefebcd1
No known key found for this signature in database
GPG key ID: 8EF1500759F70623

View file

@ -226,10 +226,12 @@ func (s *publicRoomsStatements) updateRoomAttribute(attrName string, attrValue a
var value interface{} var value interface{}
if attrName == "aliases" { if attrName == "aliases" {
// Aliases need a special conversion // Aliases need a special conversion
if value, err = pq.StringArray(attrValue.([]string)); err != nil { valueAsSlice, isSlice := attrValue.([]string)
if !isSlice {
// attrValue isn't a slice of strings // attrValue isn't a slice of strings
return err return errors.New("New list of aliases is of the wrong type")
} }
value = pq.StringArray(valueAsSlice)
} else { } else {
value = attrValue value = attrValue
} }