60ac4aad65e8 — Ted Unangst 10 days ago
add triggers
6 files changed, 35 insertions(+), 6 deletions(-)

M activity.go
M docs/changelog.txt
M docs/honk.1
M honk.go
M views/account.html
M web.go
M activity.go +15 -0
@@ 1780,7 1780,22 @@ func sendchonk(user *WhatAbout, ch *Chon
 	}
 }
 
+func trigger(user *WhatAbout, honk *Honk) {
+	j := junk.New()
+	j["honk"] = honk
+	ki := ziggy(user.ID)
+	if ki == nil {
+		return
+	}
+	err := PostJunk(ki.keyname, ki.seckey, user.Options.Trigger, j)
+	if err != nil {
+		ilog.Printf("error triggering: %s", err)
+	}
+}
 func honkworldwide(user *WhatAbout, honk *Honk) {
+	if user.Options.Trigger != "" {
+		trigger(user, honk)
+	}
 	jonk, _ := jonkjonk(user, honk)
 	jonk["@context"] = itiswhatitis
 	msg := jonk.ToBytes()

          
M docs/changelog.txt +2 -0
@@ 2,6 2,8 @@ changelog
 
 ### next
 
++ Triggers.
+
 + AVIF image support. Optional with config option convertavif.
 
 - Remove the qotd server.

          
M docs/honk.1 +4 -3
@@ 214,12 214,13 @@ See
 .Xr honk 8
 for more about the funzone.
 .Pp
+A web trigger may be set which will receive POSTs when new honks are posted.
+.Dq http://spybridge.honk.example/trigger
+.Pp
 Some options to customize the site appearance:
-.Bl -tag -width skinny
+.Bl -tag -width reaction
 .It skinny
 Use a narrower column for the main display.
-.It omit images
-Omit img tags, to lighten page loads on slow connections.
 .It apple
 Prefer Apple links for maps.
 The default is OpenStreetMap.

          
M honk.go +1 -0
@@ 53,6 53,7 @@ type UserOptions struct {
 	ChatPubKey   string
 	ChatSecKey   string
 	TOTP         string `json:",omitempty"`
+	Trigger      string `json:",omitempty"`
 }
 
 type KeyInfo struct {

          
M views/account.html +12 -3
@@ 7,17 7,26 @@ 
 <form id="aboutform" action="/saveuser" method="POST">
 <input type="hidden" name="CSRF" value="{{ .UserCSRF }}">
 <p>about me:
-<p><textarea name="whatabout">{{ .WhatAbout }}</textarea>
+<br><textarea tabindex=1 name="whatabout">{{ .WhatAbout }}</textarea>
+
+<p>trigger:
+<br><input tabindex=1 name="trigger" value="{{ .User.Options.Trigger }}">
+
 <p><label class="button" for="skinny">skinny layout:</label>
 <input tabindex=1 type="checkbox" id="skinny" name="skinny" value="skinny" {{ if .User.Options.SkinnyCSS }}checked{{ end }}><span></span>
+
 <p><label class="button" for="mentionall">mention all:</label>
 <input tabindex=1 type="checkbox" id="mentionall" name="mentionall" value="mentionall" {{ if .User.Options.MentionAll }}checked{{ end }}><span></span>
+
 <p><label class="button" for="inlineqts">inline quotes:</label>
 <input tabindex=1 type="checkbox" id="inlineqts" name="inlineqts" value="inlineqts" {{ if .User.Options.InlineQuotes }}checked{{ end }}><span></span>
+
 <p><label class="button" for="maps">apple map links:</label>
 <input tabindex=1 type="checkbox" id="maps" name="maps" value="apple" {{ if eq "apple" .User.Options.MapLink }}checked{{ end }}><span></span>
+
 <p><label class="button" for="enabletotp">make logins hard:</label>
 <input tabindex=1 type="checkbox" id="enabletotp" name="enabletotp" value="enabletotp" {{ if .User.Options.TOTP }}checked{{ end }}><span></span>
+
 <p><label class="button" for="reaction">reaction:</label>
 <select tabindex=1 name="reaction">
 <option {{ and (eq .User.Options.Reaction "none") "selected" }}>none</option>

          
@@ 30,7 39,7 @@ 
 <option {{ and (eq .User.Options.Reaction "\U0001FA93") "selected" }}>{{ "\U0001FA93" }}</option>
 <option {{ and (eq .User.Options.Reaction "\U0001F9EF") "selected" }}>{{ "\U0001F9EF" }}</option>
 </select>
-<p><button>update settings</button>
+<p><button tabindex=1>update settings</button>
 </form>
 </div>
 <hr>

          
@@ 40,7 49,7 @@ 
 <p>change password
 <p><input tabindex=1 type="password" name="oldpass"> - oldpass
 <p><input tabindex=1 type="password" name="newpass"> - newpass
-<p><button>change</button>
+<p><button tabindex=1>change</button>
 </form>
 </div>
 {{ if .User.Options.TOTP }}

          
M web.go +1 -0
@@ 1584,6 1584,7 @@ func saveuser(w http.ResponseWriter, r *
 	db := opendatabase()
 
 	options := user.Options
+	options.Trigger = r.FormValue("trigger")
 	options.SkinnyCSS = r.FormValue("skinny") == "skinny"
 	options.MentionAll = r.FormValue("mentionall") == "mentionall"
 	options.InlineQuotes = r.FormValue("inlineqts") == "inlineqts"