add approved replies to AP object collection

This commit is contained in:
Ted Unangst 2019-08-18 23:25:11 -04:00
parent 27b5bc5f5f
commit e9c5b28217
2 changed files with 25 additions and 7 deletions

View File

@ -804,6 +804,18 @@ func jonkjonk(user *WhatAbout, h *Honk) (junk.Junk, junk.Junk) {
jo["sensitive"] = true jo["sensitive"] = true
} }
var replies []string
for _, reply := range h.Replies {
replies = append(replies, reply.XID)
}
if len(replies) > 0 {
jr := junk.New()
jr["type"] = "Collection"
jr["totalItems"] = len(replies)
jr["items"] = replies
jo["replies"] = jr
}
var tags []junk.Junk var tags []junk.Junk
g := bunchofgrapes(h.Noise) g := bunchofgrapes(h.Noise)
for _, m := range g { for _, m := range g {

20
honk.go
View File

@ -71,6 +71,7 @@ type Honk struct {
Audience []string Audience []string
Public bool Public bool
Whofore int64 Whofore int64
Replies []*Honk
Flags int64 Flags int64
HTML template.HTML HTML template.HTML
Style string Style string
@ -617,8 +618,8 @@ func showhonk(w http.ResponseWriter, r *http.Request) {
} }
xid := fmt.Sprintf("https://%s%s", serverName, r.URL.Path) xid := fmt.Sprintf("https://%s%s", serverName, r.URL.Path)
h := getxonk(user.ID, xid) honk := getxonk(user.ID, xid)
if h == nil { if honk == nil {
http.NotFound(w, r) http.NotFound(w, r)
return return
} }
@ -626,24 +627,29 @@ func showhonk(w http.ResponseWriter, r *http.Request) {
if u != nil && u.UserID != user.ID { if u != nil && u.UserID != user.ID {
u = nil u = nil
} }
if !h.Public { if !honk.Public {
if u == nil { if u == nil {
http.NotFound(w, r) http.NotFound(w, r)
return return
} }
honkpage(w, r, u, nil, []*Honk{h}, "one honk maybe more") honkpage(w, r, u, nil, []*Honk{honk}, "one honk maybe more")
return return
} }
rawhonks := gethonksbyconvoy(honk.UserID, honk.Convoy)
if friendorfoe(r.Header.Get("Accept")) { if friendorfoe(r.Header.Get("Accept")) {
donksforhonks([]*Honk{h}) for _, h := range rawhonks {
_, j := jonkjonk(user, h) if h.RID == honk.XID && h.Public && (h.Whofore == 2 || honkIsAcked(h.Flags)) {
honk.Replies = append(honk.Replies, h)
}
}
donksforhonks([]*Honk{honk})
_, j := jonkjonk(user, honk)
j["@context"] = itiswhatitis j["@context"] = itiswhatitis
w.Header().Set("Content-Type", theonetruename) w.Header().Set("Content-Type", theonetruename)
j.Write(w) j.Write(w)
return return
} }
rawhonks := gethonksbyconvoy(h.UserID, h.Convoy)
var honks []*Honk var honks []*Honk
for _, h := range rawhonks { for _, h := range rawhonks {
if h.Public && (h.Whofore == 2 || honkIsAcked(h.Flags)) { if h.Public && (h.Whofore == 2 || honkIsAcked(h.Flags)) {