Do not allow empty messages
This commit is contained in:
parent
ae97fbe025
commit
8280e5b0ad
2 changed files with 6 additions and 0 deletions
|
@ -68,6 +68,9 @@ func (c *sqliteCache) Messages(topic string, since sinceTime) ([]*message, error
|
||||||
if err := rows.Scan(&id, ×tamp, &msg); err != nil {
|
if err := rows.Scan(&id, ×tamp, &msg); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
if msg == "" {
|
||||||
|
msg = " " // Hack: never return empty messages; this should not happen
|
||||||
|
}
|
||||||
messages = append(messages, &message{
|
messages = append(messages, &message{
|
||||||
ID: id,
|
ID: id,
|
||||||
Time: timestamp,
|
Time: timestamp,
|
||||||
|
|
|
@ -243,6 +243,9 @@ func (s *Server) handlePublish(w http.ResponseWriter, r *http.Request, v *visito
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
m := newDefaultMessage(t.id, string(b))
|
m := newDefaultMessage(t.id, string(b))
|
||||||
|
if m.Message == "" {
|
||||||
|
return errHTTPBadRequest
|
||||||
|
}
|
||||||
if err := t.Publish(m); err != nil {
|
if err := t.Publish(m); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue