further prep for retries
This commit is contained in:
parent
5e921b566f
commit
b24f484a84
19
activity.go
19
activity.go
|
@ -218,7 +218,7 @@ func savedonk(url string, name, media string) *Donk {
|
|||
}
|
||||
|
||||
func needxonk(user *WhatAbout, x *Honk) bool {
|
||||
if strings.HasPrefix(x.XID, user.URL + "/h/") {
|
||||
if strings.HasPrefix(x.XID, user.URL+"/h/") {
|
||||
return false
|
||||
}
|
||||
if x.What == "eradicate" {
|
||||
|
@ -584,19 +584,6 @@ func jonkjonk(user *WhatAbout, h *Honk) (map[string]interface{}, map[string]inte
|
|||
return j, jo
|
||||
}
|
||||
|
||||
func deliverate(username string, rcpt string, msg []byte) {
|
||||
keyname, key := ziggy(username)
|
||||
inbox, _, err := getboxes(rcpt)
|
||||
if err != nil {
|
||||
log.Printf("error getting inbox %s: %s", rcpt, err)
|
||||
return
|
||||
}
|
||||
err = PostMsg(keyname, key, inbox, msg)
|
||||
if err != nil {
|
||||
log.Printf("failed to post json to %s: %s", inbox, err)
|
||||
}
|
||||
}
|
||||
|
||||
func honkworldwide(user *WhatAbout, honk *Honk) {
|
||||
rcpts := make(map[string]bool)
|
||||
for _, a := range honk.Audience {
|
||||
|
@ -610,12 +597,12 @@ func honkworldwide(user *WhatAbout, honk *Honk) {
|
|||
WriteJunk(&buf, jonk)
|
||||
msg := buf.Bytes()
|
||||
for _, f := range getdubs(user.ID) {
|
||||
deliverate(user.Name, f.XID, msg)
|
||||
deliverate(0, user.Name, f.XID, msg)
|
||||
delete(rcpts, f.XID)
|
||||
}
|
||||
for a := range rcpts {
|
||||
if !strings.HasSuffix(a, "/followers") {
|
||||
deliverate(user.Name, a, msg)
|
||||
deliverate(0, user.Name, a, msg)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,57 @@
|
|||
//
|
||||
// Copyright (c) 2019 Ted Unangst <tedu@tedunangst.com>
|
||||
//
|
||||
// Permission to use, copy, modify, and distribute this software for any
|
||||
// purpose with or without fee is hereby granted, provided that the above
|
||||
// copyright notice and this permission notice appear in all copies.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"log"
|
||||
"math/rand"
|
||||
"time"
|
||||
)
|
||||
|
||||
func sayitagain(goarounds int, username string, rcpt string, msg []byte) {
|
||||
var drift time.Duration
|
||||
switch goarounds {
|
||||
case 1:
|
||||
drift = 5 * time.Minute
|
||||
case 2:
|
||||
drift = 1 * time.Hour
|
||||
case 3:
|
||||
drift = 12 * time.Hour
|
||||
case 4:
|
||||
drift = 24 * time.Hour
|
||||
default:
|
||||
log.Printf("he's dead jim: %s", rcpt)
|
||||
return
|
||||
}
|
||||
drift += time.Duration(rand.Int63n(int64(drift / 16)))
|
||||
when := time.Now().UTC().Add(drift)
|
||||
log.Print(when.Format(dbtimeformat), goarounds, username, rcpt, msg)
|
||||
}
|
||||
|
||||
func deliverate(goarounds int, username string, rcpt string, msg []byte) {
|
||||
keyname, key := ziggy(username)
|
||||
inbox, _, err := getboxes(rcpt)
|
||||
if err != nil {
|
||||
log.Printf("error getting inbox %s: %s", rcpt, err)
|
||||
sayitagain(goarounds+1, username, rcpt, msg)
|
||||
return
|
||||
}
|
||||
err = PostMsg(keyname, key, inbox, msg)
|
||||
if err != nil {
|
||||
log.Printf("failed to post json to %s: %s", inbox, err)
|
||||
sayitagain(goarounds+1, username, rcpt, msg)
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue