openidec

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

commit 164ffcf494bf76b8d9148e7d8eb7a1ddc8afe15a
parent 7d6cbb769694439504a4ab5dfb34989048c326ec
Author: Peter Kosyh <p.kosyh@gmail.com>
Date:   Sat,  5 Sep 2020 11:28:25 +0300

fix with empty subjects

Diffstat:
Mii-node/tpl/topic.tpl | 2+-
Mii-node/tpl/topics.tpl | 2+-
Mii/msg.go | 6+++++-
3 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/ii-node/tpl/topic.tpl b/ii-node/tpl/topic.tpl @@ -8,7 +8,7 @@ {{else}} <div class="msg"> {{end}} -<a class="msgid" href="/{{.MsgId}}#{{.MsgId}}">#</a><span class="subj"> <a href="/{{. | repto}}#{{. | repto}}">{{.Subj}}</a></span><br> +<a class="msgid" href="/{{.MsgId}}#{{.MsgId}}">#</a><span class="subj"> <a href="/{{. | repto}}#{{. | repto}}">{{with .Subj}}{{.}}{{else}}No subject{{end}}</a></span><br> <span class="info">{{.From}}({{.Addr}}) &mdash; {{.To}}<br>{{.Date | fdate}}</span><br> <div class="text"> <br> diff --git a/ii-node/tpl/topics.tpl b/ii-node/tpl/topics.tpl @@ -13,7 +13,7 @@ {{ else }} <tr class="even"> {{ end }} -<td class="topic"><a href="/{{.Head.MsgId}}/1">{{.Head.Subj}}</a></td> +<td class="topic"><a href="/{{.Head.MsgId}}/1">{{with .Head.Subj}}{{.}}{{else}}No subject{{end}}</a></td> <td class="posts extra">{{.Count}}</td> <td class="info"><a href="/{{.Tail.MsgId}}#{{.Tail.MsgId}}">{{.Tail.Date | fdate}}</a><br>by {{.Tail.From}}</td> </tr> diff --git a/ii/msg.go b/ii/msg.go @@ -44,6 +44,10 @@ func IsEcho(e string) bool { } func IsSubject(s string) bool { + return true // len(strings.TrimSpace(s)) > 0 +} + +func IsEmptySubject(s string) bool { return len(strings.TrimSpace(s)) > 0 } @@ -76,7 +80,7 @@ func DecodeMsgline(msg string, enc bool) (*Msg, error) { m.To = "All" } m.Subj = strings.TrimSpace(text[2]) - if !IsSubject(m.Subj) { + if !IsEmptySubject(m.Subj) { return nil, errors.New("Wrong subject") } m.Date = time.Now().Unix()