commit f3160547e8a3571403b56ba7ed841a8b4fca4bbb
parent 90a4006b917a737071fdf3639842d098eaec459a
Author: Peter Kosyh <p.kosyh@gmail.com>
Date: Thu, 3 Sep 2020 08:57:01 +0300
some cleanups
Diffstat:
2 files changed, 10 insertions(+), 9 deletions(-)
diff --git a/ii-node/web.go b/ii-node/web.go
@@ -44,6 +44,9 @@ func getTopics(db *ii.DB, mi []*ii.MsgInfo) map[string][]string {
for p := m; p != nil; p = getParent(db, p) {
l = append(l, p.Id)
}
+ if len(l) == 0 {
+ continue
+ }
t := l[len(l) - 1]
for _, id := range l {
topics[t] = append(topics[t], id)
@@ -70,19 +73,20 @@ func www_topics(www WWW, w http.ResponseWriter, r *http.Request, echo string) er
topics := getTopics(db, mis)
ii.Trace.Printf("Start to generate topics")
for _, t := range topics {
- // if mi.Repto != "" || db.Exists(mi.Repto) != nil {
- // continue
- //}
topic := Topic{}
topic.Ids = t
- m := db.Get(topic.Ids[0])
+ m := db.Get(t[0])
if m == nil {
- ii.Error.Printf("Skip wrong message: %s\n", topic.Ids[0])
+ ii.Error.Printf("Skip wrong message: %s\n", t[0])
continue
}
topic.Count = len(topic.Ids) - 1
topic.Head = m
topic.Last = db.Get(topic.Ids[topic.Count])
+ if topic.Last == nil {
+ ii.Error.Printf("Skip wrong message: %s\n", t[0])
+ continue
+ }
topic.Date = time.Unix(topic.Last.Date, 0).Format("2006-01-02 15:04:05")
ctx.Topics = append(ctx.Topics, topic)
}
diff --git a/ii/msg.go b/ii/msg.go
@@ -48,9 +48,6 @@ func DecodeMsgline(msg string, enc bool) (*Msg, error) {
var data []byte
var err error
if enc {
- // if msg, err = url.QueryUnescape(msg); err != nil {
- // return nil, err
- // }
if data, err = base64.StdEncoding.DecodeString(msg); err != nil {
if data, err = base64.URLEncoding.DecodeString(msg); err != nil {
return nil, err
@@ -77,7 +74,7 @@ func DecodeMsgline(msg string, enc bool) (*Msg, error) {
repto := text[4]
m.Tags, _ = MakeTags("ii/ok")
- if strings.HasPrefix(repto, "@Repto:") || strings.HasPrefix(repto, "@repto:") {
+ if strings.HasPrefix(repto, "@repto:") {
start += 1
m.Tags.Add("repto/" + strings.Trim(strings.Split(repto, ":")[1], " "))
}