rework all the follow stuff a bit
This commit is contained in:
parent
261ff367cf
commit
d76dc7bf98
46
activity.go
46
activity.go
|
@ -648,32 +648,24 @@ func xonkxonk(user *WhatAbout, item interface{}, origin string) *Honk {
|
||||||
|
|
||||||
func rubadubdub(user *WhatAbout, req map[string]interface{}) {
|
func rubadubdub(user *WhatAbout, req map[string]interface{}) {
|
||||||
xid, _ := jsongetstring(req, "id")
|
xid, _ := jsongetstring(req, "id")
|
||||||
reqactor, _ := jsongetstring(req, "actor")
|
actor, _ := jsongetstring(req, "actor")
|
||||||
j := NewJunk()
|
j := NewJunk()
|
||||||
j["@context"] = itiswhatitis
|
j["@context"] = itiswhatitis
|
||||||
j["id"] = user.URL + "/dub/" + xid
|
j["id"] = user.URL + "/dub/" + xid
|
||||||
j["type"] = "Accept"
|
j["type"] = "Accept"
|
||||||
j["actor"] = user.URL
|
j["actor"] = user.URL
|
||||||
j["to"] = reqactor
|
j["to"] = actor
|
||||||
j["published"] = time.Now().UTC().Format(time.RFC3339)
|
j["published"] = time.Now().UTC().Format(time.RFC3339)
|
||||||
j["object"] = req
|
j["object"] = req
|
||||||
|
|
||||||
actor, _ := jsongetstring(req, "actor")
|
var buf bytes.Buffer
|
||||||
box, err := getboxes(actor)
|
WriteJunk(&buf, j)
|
||||||
if err != nil {
|
msg := buf.Bytes()
|
||||||
log.Printf("can't get dub box: %s", err)
|
|
||||||
return
|
deliverate(0, user.Name, actor, msg)
|
||||||
}
|
|
||||||
keyname, key := ziggy(user.Name)
|
|
||||||
err = PostJunk(keyname, key, box.In, j)
|
|
||||||
if err != nil {
|
|
||||||
log.Printf("can't rub a dub: %s", err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
stmtSaveDub.Exec(user.ID, actor, actor, "dub")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func itakeitallback(user *WhatAbout, xid string) error {
|
func itakeitallback(user *WhatAbout, xid string) {
|
||||||
j := NewJunk()
|
j := NewJunk()
|
||||||
j["@context"] = itiswhatitis
|
j["@context"] = itiswhatitis
|
||||||
j["id"] = user.URL + "/unsub/" + xid
|
j["id"] = user.URL + "/unsub/" + xid
|
||||||
|
@ -688,16 +680,11 @@ func itakeitallback(user *WhatAbout, xid string) error {
|
||||||
j["object"] = f
|
j["object"] = f
|
||||||
j["published"] = time.Now().UTC().Format(time.RFC3339)
|
j["published"] = time.Now().UTC().Format(time.RFC3339)
|
||||||
|
|
||||||
box, err := getboxes(xid)
|
var buf bytes.Buffer
|
||||||
if err != nil {
|
WriteJunk(&buf, j)
|
||||||
return err
|
msg := buf.Bytes()
|
||||||
}
|
|
||||||
keyname, key := ziggy(user.Name)
|
deliverate(0, user.Name, xid, msg)
|
||||||
err = PostJunk(keyname, key, box.In, j)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func subsub(user *WhatAbout, xid string) {
|
func subsub(user *WhatAbout, xid string) {
|
||||||
|
@ -710,16 +697,11 @@ func subsub(user *WhatAbout, xid string) {
|
||||||
j["object"] = xid
|
j["object"] = xid
|
||||||
j["published"] = time.Now().UTC().Format(time.RFC3339)
|
j["published"] = time.Now().UTC().Format(time.RFC3339)
|
||||||
|
|
||||||
a := xid
|
|
||||||
box, _ := getboxes(xid)
|
|
||||||
if box != nil {
|
|
||||||
a = "%" + box.In
|
|
||||||
}
|
|
||||||
var buf bytes.Buffer
|
var buf bytes.Buffer
|
||||||
WriteJunk(&buf, j)
|
WriteJunk(&buf, j)
|
||||||
msg := buf.Bytes()
|
msg := buf.Bytes()
|
||||||
|
|
||||||
deliverate(0, user.Name, a, msg)
|
deliverate(0, user.Name, xid, msg)
|
||||||
}
|
}
|
||||||
|
|
||||||
func jonkjonk(user *WhatAbout, h *Honk) (map[string]interface{}, map[string]interface{}) {
|
func jonkjonk(user *WhatAbout, h *Honk) (map[string]interface{}, map[string]interface{}) {
|
||||||
|
|
9
honk.go
9
honk.go
|
@ -328,7 +328,8 @@ func inbox(w http.ResponseWriter, r *http.Request) {
|
||||||
obj, _ := jsongetstring(j, "object")
|
obj, _ := jsongetstring(j, "object")
|
||||||
if obj == user.URL {
|
if obj == user.URL {
|
||||||
log.Printf("updating honker follow: %s", who)
|
log.Printf("updating honker follow: %s", who)
|
||||||
rubadubdub(user, j)
|
stmtSaveDub.Exec(user.ID, who, who, "dub")
|
||||||
|
go rubadubdub(user, j)
|
||||||
} else {
|
} else {
|
||||||
log.Printf("can't follow %s", obj)
|
log.Printf("can't follow %s", obj)
|
||||||
}
|
}
|
||||||
|
@ -1052,16 +1053,12 @@ func savehonker(w http.ResponseWriter, r *http.Request) {
|
||||||
}
|
}
|
||||||
log.Printf("unsubscribing from %s", xid)
|
log.Printf("unsubscribing from %s", xid)
|
||||||
user, _ := butwhatabout(u.Username)
|
user, _ := butwhatabout(u.Username)
|
||||||
err = itakeitallback(user, xid)
|
go itakeitallback(user, xid)
|
||||||
if err != nil {
|
|
||||||
log.Printf("can't take it back: %s", err)
|
|
||||||
} else {
|
|
||||||
_, err = stmtUpdateFlavor.Exec("unsub", u.UserID, xid, "sub")
|
_, err = stmtUpdateFlavor.Exec("unsub", u.UserID, xid, "sub")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf("error updating honker: %s", err)
|
log.Printf("error updating honker: %s", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
http.Redirect(w, r, "/honkers", http.StatusSeeOther)
|
http.Redirect(w, r, "/honkers", http.StatusSeeOther)
|
||||||
return
|
return
|
||||||
|
|
Loading…
Reference in New Issue