make the ping command easier to use

This commit is contained in:
Ted Unangst 2020-11-11 14:44:51 -05:00
parent 8a2d3348fa
commit 2a6de8f7bc
3 changed files with 16 additions and 1 deletions

View File

@ -1,5 +1,9 @@
changelog changelog
=== next
+ Easier to use ping command.
=== 0.9.3 Notacanthous Nutshell === 0.9.3 Notacanthous Nutshell
++ backup command. ++ backup command.

View File

@ -340,7 +340,7 @@ func main() {
svalbard(name) svalbard(name)
case "ping": case "ping":
if len(args) < 3 { if len(args) < 3 {
fmt.Printf("usage: honk ping from to\n") fmt.Printf("usage: honk ping (from username) (to username or url)\n")
return return
} }
name := args[1] name := args[1]

11
web.go
View File

@ -257,12 +257,23 @@ func crappola(j junk.Junk) bool {
} }
func ping(user *WhatAbout, who string) { func ping(user *WhatAbout, who string) {
if targ := fullname(who, user.ID); targ != "" {
who = targ
}
if !strings.HasPrefix(who, "https:") {
who = gofish(who)
}
if who == "" {
log.Printf("nobody to ping!")
return
}
var box *Box var box *Box
ok := boxofboxes.Get(who, &box) ok := boxofboxes.Get(who, &box)
if !ok { if !ok {
log.Printf("no inbox to ping %s", who) log.Printf("no inbox to ping %s", who)
return return
} }
log.Printf("sending ping to %s", box.In)
j := junk.New() j := junk.New()
j["@context"] = itiswhatitis j["@context"] = itiswhatitis
j["type"] = "Ping" j["type"] = "Ping"