all repos — honk @ 7e0a6237c0185df5b2bf72b0b9eda51ee74d25ca

my fork of honk

allow replying to private messages with private replies
Ted Unangst tedu@tedunangst.com
Tue, 28 May 2019 02:36:47 -0400
commit

7e0a6237c0185df5b2bf72b0b9eda51ee74d25ca

parent

25e4eafabd12a1f5db9976d1677f65c4aa7c468c

6 files changed, 62 insertions(+), 40 deletions(-)

jump to
M activity.goactivity.go

@@ -809,19 +809,25 @@ rcpts := make(map[string]bool)

for _, a := range honk.Audience { if a != thewholeworld && a != user.URL && !strings.HasSuffix(a, "/followers") { box, _ := getboxes(a) - if box != nil && box.Shared != "" { - rcpts["%"+box.Shared] = true + if box != nil { + if honk.Public && box.Shared != "" { + rcpts["%"+box.Shared] = true + } else { + rcpts["%"+box.In] = true + } } else { rcpts[a] = true } } } - for _, f := range getdubs(user.ID) { - box, _ := getboxes(f.XID) - if box != nil && box.Shared != "" { - rcpts["%"+box.Shared] = true - } else { - rcpts[f.XID] = true + if honk.Public { + for _, f := range getdubs(user.ID) { + box, _ := getboxes(f.XID) + if box != nil && box.Shared != "" { + rcpts["%"+box.Shared] = true + } else { + rcpts[f.XID] = true + } } } for a := range rcpts {
M deliverator.godeliverator.go

@@ -93,9 +93,6 @@ sayitagain(goarounds+1, username, rcpt, msg)

return } inbox = box.In - if box.Shared != "" { - inbox = box.Shared - } } err := PostMsg(keyname, key, inbox, msg) if err != nil {
M docs/manual.txtdocs/manual.txt

@@ -43,6 +43,7 @@

Received messages are only visible when logged in, regardless of addressing. Received messages that are less than public are tagged with a red border. +Replies to private messages will also be private. -- css
M fun.gofun.go

@@ -281,6 +281,15 @@ }

} } +func keepitquiet(aud []string) bool { + for _, a := range aud { + if a == thewholeworld { + return false + } + } + return true +} + func oneofakind(a []string) []string { var x []string for n, s := range a {
M honk.gohonk.go

@@ -63,7 +63,7 @@ Noise string

Precis string Convoy string Audience []string - Privacy string + Public bool Whofore int64 HTML template.HTML Donks []*Donk

@@ -156,7 +156,7 @@ name := mux.Vars(r)["name"]

var honks []*Honk if name != "" { - honks = gethonksbyuser(name) + honks = gethonksbyuser(name, false) } else { honks = getpublichonks() }

@@ -368,7 +368,7 @@ if err != nil {

http.NotFound(w, r) return } - honks := gethonksbyuser(name) + honks := gethonksbyuser(name, false) var jonks []map[string]interface{} for _, h := range honks {

@@ -425,8 +425,8 @@ w.Header().Set("Content-Type", theonetruename)

WriteJunk(w, j) return } - honks := gethonksbyuser(name) u := login.GetUserInfo(r) + honks := gethonksbyuser(name, u != nil && u.Username == name) honkpage(w, r, u, user, honks, "") }

@@ -463,7 +463,7 @@ return

} xid := fmt.Sprintf("https://%s%s", serverName, r.URL.Path) h := getxonk(user.ID, xid) - if h == nil { + if h == nil || !h.Public { http.NotFound(w, r) return }

@@ -477,11 +477,6 @@ WriteJunk(w, j)

return } honks := gethonksbyconvoy(-1, h.Convoy) - for _, hh := range honks { - if hh.XID != h.XID { - hh.Privacy = "limited" - } - } u := login.GetUserInfo(r) honkpage(w, r, u, nil, honks, "one honk maybe more") }

@@ -591,6 +586,7 @@ return nil

} h.Date, _ = time.Parse(dbtimeformat, dt) h.Audience = strings.Split(aud, " ") + h.Public = !keepitquiet(h.Audience) return h }

@@ -599,9 +595,13 @@ dt := time.Now().UTC().Add(-7 * 24 * time.Hour).Format(dbtimeformat)

rows, err := stmtPublicHonks.Query(dt) return getsomehonks(rows, err) } -func gethonksbyuser(name string) []*Honk { +func gethonksbyuser(name string, includeprivate bool) []*Honk { dt := time.Now().UTC().Add(-7 * 24 * time.Hour).Format(dbtimeformat) - rows, err := stmtUserHonks.Query(name, dt) + whofore := 2 + if includeprivate { + whofore = 3 + } + rows, err := stmtUserHonks.Query(whofore, name, dt) return getsomehonks(rows, err) } func gethonksforuser(userid int64) []*Honk {

@@ -650,13 +650,7 @@ return nil

} h.Date, _ = time.Parse(dbtimeformat, dt) h.Audience = strings.Split(aud, " ") - h.Privacy = "limited" - for _, a := range h.Audience { - if a == thewholeworld { - h.Privacy = "" - break - } - } + h.Public = !keepitquiet(h.Audience) honks = append(honks, &h) } rows.Close()

@@ -701,6 +695,9 @@ log.Printf("bonking %s", xid)

xonk := getxonk(userinfo.UserID, xid) if xonk == nil { + return + } + if !xonk.Public { return } donksforhonks([]*Honk{xonk})

@@ -767,7 +764,7 @@ xonk := getxonk(userinfo.UserID, what)

if xonk != nil { stmtZonkDonks.Exec(xonk.ID) stmtZonkIt.Exec(userinfo.UserID, what) - if xonk.Whofore == 2 { + if xonk.Whofore == 2 || xonk.Whofore == 3 { zonk := Honk{ What: "zonk", XID: xonk.XID,

@@ -823,11 +820,6 @@ }

noise = strings.TrimSpace(noise) honk.Precis = strings.TrimSpace(honk.Precis) - if noise != "" && noise[0] == '@' { - honk.Audience = append(grapevine(noise), thewholeworld) - } else { - honk.Audience = prepend(thewholeworld, grapevine(noise)) - } var convoy string if rid != "" { xonk := getxonk(userinfo.UserID, rid)

@@ -839,13 +831,27 @@ xonkaud, c := whosthere(rid)

honk.Audience = append(honk.Audience, xonkaud...) convoy = c } + for i, a := range honk.Audience { + if a == thewholeworld { + honk.Audience[0], honk.Audience[i] = honk.Audience[i], honk.Audience[0] + break + } + } honk.RID = rid + } else { + honk.Audience = []string{thewholeworld} + } + if noise != "" && noise[0] == '@' { + honk.Audience = append(grapevine(noise), honk.Audience...) + } else { + honk.Audience = append(honk.Audience, grapevine(noise)...) } if convoy == "" { convoy = "data:,electrichonkytonk-" + xfiltrate() } butnottooloud(honk.Audience) honk.Audience = oneofakind(honk.Audience) + honk.Public = !keepitquiet(honk.Audience) noise = obfusbreak(noise) honk.Noise = noise honk.Convoy = convoy

@@ -914,6 +920,9 @@ }

aud := strings.Join(honk.Audience, " ") whofore := 2 + if !honk.Public { + whofore = 3 + } res, err := stmtSaveHonk.Exec(userinfo.UserID, what, honk.Honker, xid, rid, dt.Format(dbtimeformat), "", aud, noise, convoy, whofore, "html", honk.Precis, honk.Oonker) if err != nil {

@@ -1350,7 +1359,7 @@ limit := " order by 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 = ?") stmtPublicHonks = preparetodie(db, selecthonks+"where whofore = 2 and dt > ?"+limit) - stmtUserHonks = preparetodie(db, selecthonks+"where whofore = 2 and username = ? and dt > ?"+limit) + stmtUserHonks = preparetodie(db, selecthonks+"where (whofore = 2 or whofore = ?) and username = ? and dt > ?"+limit) stmtHonksForUser = preparetodie(db, selecthonks+"where honks.userid = ? and dt > ? and honker in (select xid from honkers where userid = ? and flavor = 'sub' and combos not like '% - %')"+butnotthose+limit) stmtHonksForMe = preparetodie(db, selecthonks+"where honks.userid = ? and dt > ? and whofore = 1"+butnotthose+limit) stmtHonksByHonker = preparetodie(db, selecthonks+"join honkers on honkers.xid = honks.honker where honks.userid = ? and honkers.name = ?"+butnotthose+limit)
M views/honk.htmlviews/honk.html

@@ -1,4 +1,4 @@

-<article class="honk {{ .Honk.What }} {{ .Honk.Privacy }}"> +<article class="honk {{ .Honk.What }} {{ and (not .Honk.Public) "limited" }}"> {{ with .Honk }} <header> <img alt="avatar" src="/a?a={{ .Honker}}">

@@ -39,10 +39,10 @@ {{ end }}

{{ if .BonkCSRF }} <p> <div> -{{ if not .Honk.Privacy }} +{{ if .Honk.Public }} <button onclick="bonk(this, '{{ .Honk.XID }}'); return false;"><a href="/bonk">bonk</a></button> -<button onclick="showhonkform('{{ .Honk.XID }}', '{{ .Honk.Username }}'); return false;"><a href="/newhonk">tonk</a></button> {{ end }} +<button onclick="showhonkform('{{ .Honk.XID }}', '{{ .Honk.Username }}'); return false;"><a href="/newhonk">tonk</a></button> <form class="inlineform" action="/zonkit" method="POST"> <input type="hidden" name="CSRF" value="{{ .BonkCSRF }}"> <input type="hidden" name="honk" value="{{ .Honk.XID }}">