diff --git a/database.go b/database.go index e71bed4..946d2db 100644 --- a/database.go +++ b/database.go @@ -596,12 +596,53 @@ func savechonk(ch *Chonk) error { } } err = tx.Commit() + chatplusone(ch.UserID) } else { tx.Rollback() } return err } +func chatplusone(userid int64) { + var user *WhatAbout + ok := somenumberedusers.Get(userid, &user) + if !ok { + return + } + options := user.Options + options.Chats += 1 + j, err := jsonify(options) + if err == nil { + db := opendatabase() + _, err = db.Exec("update users set options = ? where username = ?", j, user.Name) + } + if err != nil { + log.Printf("error plussing chat: %s", err) + } + somenamedusers.Clear(user.Name) + somenumberedusers.Clear(user.ID) +} + +func chatnewnone(userid int64) { + var user *WhatAbout + ok := somenumberedusers.Get(userid, &user) + if !ok || user.Options.Chats == 0 { + return + } + options := user.Options + options.Chats = 0 + j, err := jsonify(options) + if err == nil { + db := opendatabase() + _, err = db.Exec("update users set options = ? where username = ?", j, user.Name) + } + if err != nil { + log.Printf("error noneing chat: %s", err) + } + somenamedusers.Clear(user.Name) + somenumberedusers.Clear(user.ID) +} + func loadchatter(userid int64) []*Chatter { duedt := time.Now().Add(-3 * 24 * time.Hour).UTC().Format(dbtimeformat) rows, err := stmtLoadChonks.Query(userid, duedt) diff --git a/docs/changelog.txt b/docs/changelog.txt index 8687195..e17e835 100644 --- a/docs/changelog.txt +++ b/docs/changelog.txt @@ -2,6 +2,8 @@ changelog === next ++ Unread count for chatter. + + More flexible hashtag characters. + Fix the memetizer to work in more environments. diff --git a/honk.go b/honk.go index a2304c8..e5c6cb6 100644 --- a/honk.go +++ b/honk.go @@ -55,6 +55,7 @@ type UserOptions struct { MapLink string `json:",omitempty"` Reaction string `json:",omitempty"` MentionAll bool + Chats int } type KeyInfo struct { diff --git a/views/header.html b/views/header.html index d6e8c18..4a85753 100644 --- a/views/header.html +++ b/views/header.html @@ -17,7 +17,7 @@
{{ if .UserInfo }}
-menu {{ .UserInfo.Username }} +menu {{ .UserInfo.Name }}
-
  • chatter +
  • chatter{{ if .UserInfo.Options.Chats }} ({{ .UserInfo.Options.Chats }}){{ end }}
  • tags
  • events
  • long ago @@ -43,7 +43,7 @@
    more stuff
      -
    • my honks +
    • my honks
    • about
    • front
    • funzone diff --git a/web.go b/web.go index 107f929..72579b1 100644 --- a/web.go +++ b/web.go @@ -75,17 +75,16 @@ func getmaplink(u *login.UserInfo) string { } func getInfo(r *http.Request) map[string]interface{} { - u := login.GetUserInfo(r) templinfo := make(map[string]interface{}) templinfo["StyleParam"] = getassetparam(viewDir + "/views/style.css") templinfo["LocalStyleParam"] = getassetparam(dataDir + "/views/local.css") templinfo["JSParam"] = getassetparam(viewDir + "/views/honkpage.js") - templinfo["UserStyle"] = getuserstyle(u) templinfo["ServerName"] = serverName templinfo["IconName"] = iconName - templinfo["UserInfo"] = u templinfo["UserSep"] = userSep - if u != nil { + if u := login.GetUserInfo(r); u != nil { + templinfo["UserInfo"], _ = butwhatabout(u.Username) + templinfo["UserStyle"] = getuserstyle(u) var combos []string combocache.Get(u.UserID, &combos) templinfo["Combos"] = combos @@ -1763,6 +1762,7 @@ func showhonkers(w http.ResponseWriter, r *http.Request) { func showchatter(w http.ResponseWriter, r *http.Request) { u := login.GetUserInfo(r) + chatnewnone(u.UserID) chatter := loadchatter(u.UserID) for _, chat := range chatter { for _, ch := range chat.Chonks {