allow replying to private messages with private replies
This commit is contained in:
parent
33b57b6874
commit
0faf2b0556
22
activity.go
22
activity.go
|
@ -809,19 +809,25 @@ func honkworldwide(user *WhatAbout, honk *Honk) {
|
|||
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 {
|
||||
|
|
|
@ -93,9 +93,6 @@ func deliverate(goarounds int, username string, rcpt string, msg []byte) {
|
|||
return
|
||||
}
|
||||
inbox = box.In
|
||||
if box.Shared != "" {
|
||||
inbox = box.Shared
|
||||
}
|
||||
}
|
||||
err := PostMsg(keyname, key, inbox, msg)
|
||||
if err != nil {
|
||||
|
|
|
@ -43,6 +43,7 @@ Honks are public. Welcome to the internet.
|
|||
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
|
||||
|
||||
|
|
9
fun.go
9
fun.go
|
@ -281,6 +281,15 @@ func butnottooloud(aud []string) {
|
|||
}
|
||||
}
|
||||
|
||||
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 {
|
||||
|
|
61
honk.go
61
honk.go
|
@ -63,7 +63,7 @@ type Honk struct {
|
|||
Precis string
|
||||
Convoy string
|
||||
Audience []string
|
||||
Privacy string
|
||||
Public bool
|
||||
Whofore int64
|
||||
HTML template.HTML
|
||||
Donks []*Donk
|
||||
|
@ -156,7 +156,7 @@ func showrss(w http.ResponseWriter, r *http.Request) {
|
|||
|
||||
var honks []*Honk
|
||||
if name != "" {
|
||||
honks = gethonksbyuser(name)
|
||||
honks = gethonksbyuser(name, false)
|
||||
} else {
|
||||
honks = getpublichonks()
|
||||
}
|
||||
|
@ -368,7 +368,7 @@ func outbox(w http.ResponseWriter, r *http.Request) {
|
|||
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 @@ func showuser(w http.ResponseWriter, r *http.Request) {
|
|||
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 @@ func showhonk(w http.ResponseWriter, r *http.Request) {
|
|||
}
|
||||
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 @@ func showhonk(w http.ResponseWriter, r *http.Request) {
|
|||
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 @@ func getxonk(userid int64, xid string) *Honk {
|
|||
}
|
||||
h.Date, _ = time.Parse(dbtimeformat, dt)
|
||||
h.Audience = strings.Split(aud, " ")
|
||||
h.Public = !keepitquiet(h.Audience)
|
||||
return h
|
||||
}
|
||||
|
||||
|
@ -599,9 +595,13 @@ func getpublichonks() []*Honk {
|
|||
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 @@ func getsomehonks(rows *sql.Rows, err error) []*Honk {
|
|||
}
|
||||
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()
|
||||
|
@ -703,6 +697,9 @@ func savebonk(w http.ResponseWriter, r *http.Request) {
|
|||
if xonk == nil {
|
||||
return
|
||||
}
|
||||
if !xonk.Public {
|
||||
return
|
||||
}
|
||||
donksforhonks([]*Honk{xonk})
|
||||
|
||||
dt := time.Now().UTC()
|
||||
|
@ -767,7 +764,7 @@ func zonkit(w http.ResponseWriter, r *http.Request) {
|
|||
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 @@ func savehonk(w http.ResponseWriter, r *http.Request) {
|
|||
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 @@ func savehonk(w http.ResponseWriter, r *http.Request) {
|
|||
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 @@ func savehonk(w http.ResponseWriter, r *http.Request) {
|
|||
|
||||
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 @@ func prepareStatements(db *sql.DB) {
|
|||
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)
|
||||
|
|
|
@ -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 @@ convoy: <a href="/t?c={{ .Convoy }}">{{ .Convoy }}</a>
|
|||
{{ 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 }}">
|
||||
|
|
Loading…
Reference in New Issue