Skip to content

Commit

Permalink
bug fix in mysql adapter when deleting topics with tags
Browse files Browse the repository at this point in the history
  • Loading branch information
or-else committed May 3, 2018
1 parent 625ca80 commit 7fddd1b
Show file tree
Hide file tree
Showing 12 changed files with 33 additions and 9 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,17 +80,17 @@ A text-only [command line client](./tn-cli) implements every possible command.
### Android

<p align="center">
<img src="android-chats.png" alt="android screenshot" width=270 /> <img src="android-messages.png" alt="android screenshot" width=270 />
<img src="docs/android-chats.png" alt="android screenshot" width=270 /> <img src="docs/android-messages.png" alt="android screenshot" width=270 />
</p>

### Desktop Web

<p align="center">
<img src="web-desktop-2.png" alt="Desktop web: full app" width=866 />
<img src="docs/web-desktop-2.png" alt="Desktop web: full app" width=866 />
</p>

### Mobile Web

<p align="center">
<kbd><img src="web-mob-contacts-1.png" alt="Mobile web: contacts" width=323 /></kbd> <kbd><img src="web-mob-chat-1.png" alt="Mobile web: chat" width=323 /></kbd> <kbd><img src="web-mob-info-1.png" alt="Mobile web: topic info" width=323 /></kbd> <kbd><img src="web-mob-new-chat-1.png" alt="Mobile web: start new 1:1 chat" width=323 /></kbd>
<kbd><img src="docs/web-mob-contacts-1.png" alt="Mobile web: contacts" width=323 /></kbd> <kbd><img src="docs/web-mob-chat-1.png" alt="Mobile web: chat" width=323 /></kbd> <kbd><img src="docs/web-mob-info-1.png" alt="Mobile web: topic info" width=323 /></kbd> <kbd><img src="docs/web-mob-new-chat-1.png" alt="Mobile web: start new 1:1 chat" width=323 /></kbd>
</p>
7 changes: 6 additions & 1 deletion API.md → docs/API.md
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,12 @@ sub: {
mode: "JRWS", // string, requested access mode, optional;
// default: server-defined
info: { ... } // application-defined payload to pass to the topic manager
} // object, optional
}, // object, optional

// Optional update to tags (see fnd topic description)
tags: [ // array of strings
"email:alice@example.com", "tel:1234567890"
]
},

get: {
Expand Down
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
23 changes: 22 additions & 1 deletion server/db/mysql/adapter.go
Original file line number Diff line number Diff line change
Expand Up @@ -943,7 +943,28 @@ func (a *adapter) TopicShare(shares []*t.Subscription) (int, error) {
}

func (a *adapter) TopicDelete(topic string) error {
_, err := a.db.Exec("DELETE FROM topics WHERE name=?", topic)
tx, err := a.db.Beginx()
if err != nil {
return err
}

defer func() {
if err != nil {
tx.Rollback()
}
}()

_, err = tx.Exec("DELETE FROM topictags WHERE topic=?", topic)
if err != nil {
return err
}

_, err = tx.Exec("DELETE FROM topics WHERE name=?", topic)
if err != nil {
return err
}
tx.Commit()

return err
}

Expand Down
4 changes: 2 additions & 2 deletions server/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,9 @@ const (
// defaultMaxTagCount is the default maximum number of indexable tags
defaultMaxTagCount = 16

// minTagLength is the shortest acceptable length of a tag. Shorter tags are discarded.
// minTagLength is the shortest acceptable length of a tag in runes. Shorter tags are discarded.
minTagLength = 4
// maxTagLength is the maximum length of a tag. Longer tags are trimmed.
// maxTagLength is the maximum length of a tag in runes. Longer tags are trimmed.
maxTagLength = 96

// Delay before updating a User Agent
Expand Down
2 changes: 0 additions & 2 deletions server/topic.go
Original file line number Diff line number Diff line change
Expand Up @@ -1745,7 +1745,6 @@ func (t *Topic) replySetTags(sess *Session, set *MsgClientSet) error {
} else {
added, removed := stringSliceDelta(t.tags, tags)
if len(added) > 0 || len(removed) > 0 {
log.Println("Updating tags in DB", tags, added, removed)
update := map[string]interface{}{"Tags": types.StringSlice(tags)}

if t.cat == types.TopicCatMe {
Expand Down Expand Up @@ -1774,7 +1773,6 @@ func (t *Topic) replySetTags(sess *Session, set *MsgClientSet) error {
}
}
} else {
log.Println("replySetTags = 4")
resp = InfoNotModified(set.Id, t.original(sess.uid), now)
}

Expand Down

0 comments on commit 7fddd1b

Please sign in to comment.