Skip to content

Commit

Permalink
fix: inability to start new p2p topics with mysql
Browse files Browse the repository at this point in the history
  • Loading branch information
or-else committed Apr 11, 2018
1 parent 3463b27 commit a6d578c
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
15 changes: 14 additions & 1 deletion server/db/mysql/adapter.go
Original file line number Diff line number Diff line change
Expand Up @@ -494,7 +494,7 @@ func (a *adapter) UserGet(uid t.Uid) (*t.User, error) {

if err == sql.ErrNoRows {
// Clear the error if user does not exist
err = nil
return nil, nil
}

// If user does not exist, it returns nil, nil
Expand Down Expand Up @@ -640,6 +640,10 @@ func (a *adapter) TopicGet(topic string) (*t.Topic, error) {
topic)

if err != nil {
if err == sql.ErrNoRows {
// Nothing found - clear the error
err = nil
}
return nil, err
}

Expand Down Expand Up @@ -857,6 +861,10 @@ func (a *adapter) SubscriptionGet(topic string, user t.Uid) (*t.Subscription, er
var sub t.Subscription
err := a.db.Get(&sub, "SELECT * FROM subscriptions WHERE topic=? AND userid=", topic, store.DecodeUid(user))
if err != nil {
if err == sql.ErrNoRows {
// Nothing found - clear the error
err = nil
}
return nil, err
}

Expand Down Expand Up @@ -1429,6 +1437,11 @@ func (a *adapter) CredIsConfirmed(uid t.Uid, method string) (bool, error) {
var done int
err := a.db.Get(&done, "SELECT done FROM credentials WHERE userid=? AND method=?",
store.DecodeUid(uid), method)
if err == sql.ErrNoRows {
// Nothing found, clear the error, otherwise it will be reported as internal error.
err = nil
}

return done > 0, err
}

Expand Down
2 changes: 1 addition & 1 deletion tinode-db/tinode.conf
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"store_config": {
"uid_key": "la6YsO+bNX/+XIkOqc5Svw==",
"use_adapter": "rethinkdb",
"use_adapter": "mysql",
"adapters": {
"mysql": {
"database": "tinode",
Expand Down

0 comments on commit a6d578c

Please sign in to comment.