Skip to content

Commit

Permalink
adding an explanation wny store-assigned messsage ID is not used
Browse files Browse the repository at this point in the history
  • Loading branch information
or-else committed Nov 16, 2019
1 parent 0192c40 commit 31c79c8
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions server/db/mysql/adapter.go
Original file line number Diff line number Diff line change
Expand Up @@ -1864,12 +1864,15 @@ func (a *adapter) FindTopics(req, opt []string) ([]t.Subscription, error) {

// Messages
func (a *adapter) MessageSave(msg *t.Message) error {
// store assignes message ID, but we don't use it. Message IDs are not used anywhere.
// Using a sequential ID provided by the database.
res, err := a.db.Exec(
"INSERT INTO messages(createdAt,updatedAt,seqid,topic,`from`,head,content) VALUES(?,?,?,?,?,?,?)",
msg.CreatedAt, msg.UpdatedAt, msg.SeqId, msg.Topic,
store.DecodeUid(t.ParseUid(msg.From)), msg.Head, toJSON(msg.Content))
if err == nil {
id, _ := res.LastInsertId()
// Replacing ID given by store by ID given by the DB.
msg.SetUid(t.Uid(id))
}
return err
Expand Down

0 comments on commit 31c79c8

Please sign in to comment.