diff --git a/database.go b/database.go index 4851b6d..c43d704 100644 --- a/database.go +++ b/database.go @@ -101,13 +101,16 @@ func gethonkers(userid int64) []*Honker { var honkers []*Honker for rows.Next() { h := new(Honker) - var combos string - err = rows.Scan(&h.ID, &h.UserID, &h.Name, &h.XID, &h.Flavor, &combos) - h.Combos = strings.Split(strings.TrimSpace(combos), " ") + var combos, meta string + err = rows.Scan(&h.ID, &h.UserID, &h.Name, &h.XID, &h.Flavor, &combos, &meta) + if err == nil { + err = unjsonify(meta, &h.Meta) + } if err != nil { log.Printf("error scanning honker: %s", err) - return nil + continue } + h.Combos = strings.Split(strings.TrimSpace(combos), " ") honkers = append(honkers, h) } return honkers @@ -738,10 +741,10 @@ func preparetodie(db *sql.DB, s string) *sql.Stmt { } func prepareStatements(db *sql.DB) { - stmtHonkers = preparetodie(db, "select honkerid, userid, name, xid, flavor, combos from honkers where userid = ? and (flavor = 'presub' or flavor = 'sub' or flavor = 'peep' or flavor = 'unsub') order by name") - stmtSaveHonker = preparetodie(db, "insert into honkers (userid, name, xid, flavor, combos, owner) values (?, ?, ?, ?, ?, ?)") + stmtHonkers = preparetodie(db, "select honkerid, userid, name, xid, flavor, combos, meta from honkers where userid = ? and (flavor = 'presub' or flavor = 'sub' or flavor = 'peep' or flavor = 'unsub') order by name") + stmtSaveHonker = preparetodie(db, "insert into honkers (userid, name, xid, flavor, combos, owner, meta) values (?, ?, ?, ?, ?, ?, ?)") stmtUpdateFlavor = preparetodie(db, "update honkers set flavor = ? where userid = ? and xid = ? and name = ? and flavor = ?") - stmtUpdateHonker = preparetodie(db, "update honkers set name = ?, combos = ? where honkerid = ? and userid = ?") + stmtUpdateHonker = preparetodie(db, "update honkers set name = ?, combos = ?, meta = ? where honkerid = ? and userid = ?") stmtOneHonker = preparetodie(db, "select xid from honkers where name = ? and userid = ?") stmtDubbers = preparetodie(db, "select honkerid, userid, name, xid, flavor from honkers where userid = ? and flavor = 'dub'") stmtNamedDubbers = preparetodie(db, "select honkerid, userid, name, xid, flavor from honkers where userid = ? and name = ? and flavor = 'dub'") diff --git a/docs/changelog.txt b/docs/changelog.txt index 47a9081..bb87bf0 100644 --- a/docs/changelog.txt +++ b/docs/changelog.txt @@ -2,6 +2,8 @@ changelog -- next ++ Add notes field to honkers to document their downfall. + + Add notes field to filters for record keeping. + Negated search -terms. diff --git a/docs/hfcs.1 b/docs/hfcs.1 index 80500a5..74a94df 100644 --- a/docs/hfcs.1 +++ b/docs/hfcs.1 @@ -28,6 +28,12 @@ It is accessed via the .Pa filters menu item. .Pp +Each filter has an optional +.Ar name +and +.Ar notes +for user defined purposes. +.Pp The following match types are possible. All nonempty criteria must match. .Bl -tag -width include-audience diff --git a/docs/honk.1 b/docs/honk.1 index 267e785..5c2115c 100644 --- a/docs/honk.1 +++ b/docs/honk.1 @@ -43,15 +43,18 @@ The field is required. Either of two forms are accepted, the user's handle (or webfinger) or their ActivityPub actor URL. -The -.Ar name -field is optional and will be automatically inferred. -Examples: +.Pp .Dl @user@example.social .Dl https://example.social/users/user .Pp +The +.Ar name +field is optional and will be automatically inferred. +The +.Ar notes +field is reserved for user remarks. Fellow honkers may be added to one or more -.Ic combos +.Ar combos to suit one's organizational preferences. These are accessed via the .Pa combos diff --git a/honk.go b/honk.go index 33c852e..d88bdf7 100644 --- a/honk.go +++ b/honk.go @@ -179,6 +179,11 @@ type Honker struct { Handle string Flavor string Combos []string + Meta HonkerMeta +} + +type HonkerMeta struct { + Notes string } type SomeThing struct { diff --git a/schema.go b/schema.go index 82464e7..1d430bd 100644 --- a/schema.go +++ b/schema.go @@ -5,7 +5,7 @@ var sqlSchema = ` create table honks (honkid integer primary key, userid integer, what text, honker text, xid text, rid text, dt text, url text, audience text, noise text, convoy text, whofore integer, format text, precis text, oonker text, flags integer); create table donks (honkid integer, fileid integer); create table filemeta (fileid integer primary key, xid text, name text, description text, url text, media text, local integer); -create table honkers (honkerid integer primary key, userid integer, name text, xid text, flavor text, combos text, owner text); +create table honkers (honkerid integer primary key, userid integer, name text, xid text, flavor text, combos text, owner text, meta text); create table xonkers (xonkerid integer primary key, name text, info text, flavor text, dt text); create table zonkers (zonkerid integer primary key, userid integer, name text, wherefore text); create table doovers(dooverid integer primary key, dt text, tries integer, userid integer, rcpt text, msg blob); diff --git a/schema.sql b/schema.sql index db02483..8f501fd 100644 --- a/schema.sql +++ b/schema.sql @@ -2,7 +2,7 @@ create table honks (honkid integer primary key, userid integer, what text, honker text, xid text, rid text, dt text, url text, audience text, noise text, convoy text, whofore integer, format text, precis text, oonker text, flags integer); create table donks (honkid integer, fileid integer); create table filemeta (fileid integer primary key, xid text, name text, description text, url text, media text, local integer); -create table honkers (honkerid integer primary key, userid integer, name text, xid text, flavor text, combos text, owner text); +create table honkers (honkerid integer primary key, userid integer, name text, xid text, flavor text, combos text, owner text, meta text); create table xonkers (xonkerid integer primary key, name text, info text, flavor text, dt text); create table zonkers (zonkerid integer primary key, userid integer, name text, wherefore text); create table doovers(dooverid integer primary key, dt text, tries integer, userid integer, rcpt text, msg blob); diff --git a/upgradedb.go b/upgradedb.go index 3c968b9..7026d0b 100644 --- a/upgradedb.go +++ b/upgradedb.go @@ -24,7 +24,7 @@ import ( "time" ) -var myVersion = 33 +var myVersion = 34 func doordie(db *sql.DB, s string, args ...interface{}) { _, err := db.Exec(s, args...) @@ -361,6 +361,11 @@ func upgradedb() { doordie(db, "update config set value = 33 where key = 'dbversion'") fallthrough case 33: + doordie(db, "alter table honkers add column meta text") + doordie(db, "update honkers set meta = '{}'") + doordie(db, "update config set value = 34 where key = 'dbversion'") + fallthrough + case 34: default: log.Fatalf("can't upgrade unknown version %d", dbversion) diff --git a/views/honkers.html b/views/honkers.html index 00c643d..295e406 100644 --- a/views/honkers.html +++ b/views/honkers.html @@ -13,6 +13,9 @@
+
+
@@ -42,6 +45,8 @@ function expandstuff() {
name: +
+
combos: {{ if eq .Flavor "sub" }}
unsub: diff --git a/web.go b/web.go index 413df2c..6220800 100644 --- a/web.go +++ b/web.go @@ -1715,6 +1715,10 @@ func submithonker(w http.ResponseWriter, r *http.Request) { combos = " " + combos + " " honkerid, _ := strconv.ParseInt(r.FormValue("honkerid"), 10, 0) + var meta HonkerMeta + meta.Notes = strings.TrimSpace(r.FormValue("notes")) + mj, _ := jsonify(&meta) + defer honkerinvalidator.Clear(u.UserID) if honkerid > 0 { @@ -1765,7 +1769,7 @@ func submithonker(w http.ResponseWriter, r *http.Request) { http.Redirect(w, r, "/honkers", http.StatusSeeOther) return } - _, err := stmtUpdateHonker.Exec(name, combos, honkerid, u.UserID) + _, err := stmtUpdateHonker.Exec(name, combos, mj, honkerid, u.UserID) if err != nil { log.Printf("update honker err: %s", err) return @@ -1789,7 +1793,7 @@ func submithonker(w http.ResponseWriter, r *http.Request) { if name == "" { name = url } - _, err := stmtSaveHonker.Exec(u.UserID, name, url, flavor, combos, url) + _, err := stmtSaveHonker.Exec(u.UserID, name, url, flavor, combos, url, mj) if err != nil { log.Print(err) return @@ -1821,7 +1825,7 @@ func submithonker(w http.ResponseWriter, r *http.Request) { if name == "" { name = info.Name } - _, err = stmtSaveHonker.Exec(u.UserID, name, url, flavor, combos, info.Owner) + _, err = stmtSaveHonker.Exec(u.UserID, name, url, flavor, combos, info.Owner, mj) if err != nil { log.Print(err) return