diff --git a/activity.go b/activity.go index 81d09d6..e57042d 100644 --- a/activity.go +++ b/activity.go @@ -843,6 +843,7 @@ func jonkjonk(user *WhatAbout, h *Honk) (junk.Junk, junk.Junk) { if !h.Public { jo["directMessage"] = true } + translate(h) jo["summary"] = h.Precis jo["content"] = ontologize(mentionize(h.Noise)) if strings.HasPrefix(h.Precis, "DZ:") { diff --git a/database.go b/database.go index 5952d13..2f3de19 100644 --- a/database.go +++ b/database.go @@ -183,7 +183,7 @@ func scanhonk(row RowLike) *Honk { h := new(Honk) var dt, aud, onts string err := row.Scan(&h.ID, &h.UserID, &h.Username, &h.What, &h.Honker, &h.Oonker, &h.XID, &h.RID, - &dt, &h.URL, &aud, &h.Noise, &h.Precis, &h.Convoy, &h.Whofore, &h.Flags, &onts) + &dt, &h.URL, &aud, &h.Noise, &h.Precis, &h.Format, &h.Convoy, &h.Whofore, &h.Flags, &onts) if err != nil { if err != sql.ErrNoRows { log.Printf("error scanning honk: %s", err) @@ -290,7 +290,7 @@ func updatehonk(h *Honk) { deleteextras(h.ID) dt := h.Date.UTC().Format(dbtimeformat) - stmtUpdateHonk.Exec(h.Precis, h.Noise, dt, h.ID) + stmtUpdateHonk.Exec(h.Precis, h.Noise, h.Format, dt, h.ID) saveextras(h) } @@ -341,7 +341,7 @@ func prepareStatements(db *sql.DB) { stmtOneHonker = preparetodie(db, "select xid from honkers where name = ? and userid = ?") stmtDubbers = preparetodie(db, "select honkerid, userid, name, xid, flavor from honkers where userid = ? and flavor = 'dub'") - selecthonks := "select honks.honkid, honks.userid, username, what, honker, oonker, honks.xid, rid, dt, url, audience, noise, precis, convoy, whofore, flags, onts from honks join users on honks.userid = users.userid " + selecthonks := "select honks.honkid, honks.userid, username, what, honker, oonker, honks.xid, rid, dt, url, audience, noise, precis, format, convoy, whofore, flags, onts from honks join users on honks.userid = users.userid " limit := " order by honks.honkid desc limit 250" butnotthose := " and convoy not in (select name from zonkers where userid = ? and wherefore = 'zonvoy' order by zonkerid desc limit 100)" stmtOneXonk = preparetodie(db, selecthonks+"where honks.userid = ? and xid = ?") @@ -360,7 +360,7 @@ func prepareStatements(db *sql.DB) { stmtSaveOld = preparetodie(db, "insert into forsaken (honkid, precis, noise) values (?, ?, ?)") stmtSaveHonk = preparetodie(db, "insert into honks (userid, what, honker, xid, rid, dt, url, audience, noise, convoy, whofore, format, precis, oonker, flags, onts) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)") stmtDeleteHonk = preparetodie(db, "delete from honks where honkid = ?") - stmtUpdateHonk = preparetodie(db, "update honks set precis = ?, noise = ?, dt = ? where honkid = ?") + stmtUpdateHonk = preparetodie(db, "update honks set precis = ?, noise = ?, format = ?, dt = ? where honkid = ?") stmtSaveOnt = preparetodie(db, "insert into onts (ontology, honkid) values (?, ?)") stmtDeleteOnts = preparetodie(db, "delete from onts where honkid = ?") stmtSaveDonk = preparetodie(db, "insert into donks (honkid, fileid) values (?, ?)") diff --git a/fun.go b/fun.go index 789ce7d..7db5945 100644 --- a/fun.go +++ b/fun.go @@ -44,6 +44,7 @@ func reverbolate(userid int64, honks []*Honk) { if !h.Public { h.Style += " limited" } + translate(h) if h.Whofore == 2 || h.Whofore == 3 { h.URL = h.XID if h.What != "bonked" { @@ -100,6 +101,32 @@ func reverbolate(userid int64, honks []*Honk) { } } +func translate(honk *Honk) { + if honk.Format == "html" { + return + } + noise := honk.Noise + if strings.HasPrefix(noise, "DZ:") { + idx := strings.Index(noise, "\n") + if idx == -1 { + honk.Precis = noise + noise = "" + } else { + honk.Precis = noise[:idx] + noise = noise[idx+1:] + } + } + honk.Precis = strings.TrimSpace(honk.Precis) + + noise = strings.TrimSpace(noise) + noise = quickrename(noise, honk.UserID) + noise = obfusbreak(noise) + noise = re_memes.ReplaceAllString(noise, "") + + honk.Noise = noise + honk.Onts = oneofakind(ontologies(honk.Noise)) +} + func unsee(zilences []*regexp.Regexp, precis string, noise string) string { for _, z := range zilences { if z.MatchString(precis) || z.MatchString(noise) { diff --git a/web.go b/web.go index 83d2aa3..ff64ba4 100644 --- a/web.go +++ b/web.go @@ -883,6 +883,7 @@ func submithonk(w http.ResponseWriter, r *http.Request) { } honk.Date = dt honk.What = "update" + honk.Format = "markdown" } else { xid := fmt.Sprintf("%s/%s/%s", user.URL, honkSep, xfiltrate()) what := "honk" @@ -896,22 +897,13 @@ func submithonk(w http.ResponseWriter, r *http.Request) { Honker: user.URL, XID: xid, Date: dt, + Format: "markdown", } } - if strings.HasPrefix(noise, "DZ:") { - idx := strings.Index(noise, "\n") - if idx == -1 { - honk.Precis = noise - noise = "" - } else { - honk.Precis = noise[:idx] - noise = noise[idx+1:] - } - } - noise = quickrename(noise, userinfo.UserID) + noise = hooterize(noise) - noise = strings.TrimSpace(noise) - honk.Precis = strings.TrimSpace(honk.Precis) + honk.Noise = noise + translate(honk) var convoy string if rid != "" { @@ -936,11 +928,12 @@ func submithonk(w http.ResponseWriter, r *http.Request) { } else { honk.Audience = []string{thewholeworld} } - if noise != "" && noise[0] == '@' { - honk.Audience = append(grapevine(noise), honk.Audience...) + if honk.Noise != "" && honk.Noise[0] == '@' { + honk.Audience = append(grapevine(honk.Noise), honk.Audience...) } else { - honk.Audience = append(honk.Audience, grapevine(noise)...) + honk.Audience = append(honk.Audience, grapevine(honk.Noise)...) } + if convoy == "" { convoy = "data:,electrichonkytonk-" + xfiltrate() } @@ -952,8 +945,6 @@ func submithonk(w http.ResponseWriter, r *http.Request) { return } honk.Public = !keepitquiet(honk.Audience) - noise = obfusbreak(noise) - honk.Noise = noise honk.Convoy = convoy donkxid := r.FormValue("donkxid") @@ -1055,12 +1046,13 @@ func submithonk(w http.ResponseWriter, r *http.Request) { } return } - honk.Onts = oneofakind(ontologies(honk.Noise)) honk.UserID = userinfo.UserID honk.RID = rid honk.Date = dt honk.Convoy = convoy - honk.Format = "html" + + // back to markdown + honk.Noise = noise if updatexid != "" { updatehonk(honk)