Compare commits
10 Commits
b5091cc5e1
...
2dd6b27356
Author | SHA1 | Date |
---|---|---|
Ted Unangst | 2dd6b27356 | |
Ted Unangst | 97b9634a9e | |
Ted Unangst | 54fd484558 | |
Ted Unangst | 211ab9a97a | |
Ted Unangst | 14bc7f5cec | |
Ted Unangst | 51fe6d99b2 | |
Ted Unangst | 43705654d1 | |
Ted Unangst | dea831d23f | |
Ted Unangst | bf09636bc1 | |
Ted Unangst | cdc0ffaeb7 |
2
Makefile
2
Makefile
|
@ -2,7 +2,7 @@
|
|||
all: honk
|
||||
|
||||
honk: .preflightcheck schema.sql *.go go.mod
|
||||
go build -mod=`ls -d vendor 2> /dev/null` -o honk
|
||||
env CGO_ENABLED=1 go build -mod=`ls -d vendor 2> /dev/null` -o honk
|
||||
|
||||
.preflightcheck: preflight.sh
|
||||
@sh ./preflight.sh
|
||||
|
|
|
@ -850,9 +850,6 @@ func xonksaver(user *WhatAbout, item junk.Junk, origin string) *Honk {
|
|||
targ, _ := obj.GetString("target")
|
||||
content += string(templates.Sprintf(`<p>Moved to <a href="%s">%s</a>`, targ, targ))
|
||||
}
|
||||
if what == "honk" && rid != "" {
|
||||
what = "tonk"
|
||||
}
|
||||
if len(content) > 90001 {
|
||||
ilog.Printf("content too long. truncating")
|
||||
content = content[:90001]
|
||||
|
@ -1239,8 +1236,6 @@ func jonkjonk(user *WhatAbout, h *Honk) (junk.Junk, junk.Junk) {
|
|||
switch h.What {
|
||||
case "update":
|
||||
fallthrough
|
||||
case "tonk":
|
||||
fallthrough
|
||||
case "event":
|
||||
fallthrough
|
||||
case "honk":
|
||||
|
|
|
@ -504,8 +504,6 @@ func donksforhonks(honks []*Honk) {
|
|||
elog.Printf("error parsing badonks: %s", err)
|
||||
continue
|
||||
}
|
||||
case "wonkles":
|
||||
case "guesses":
|
||||
case "oldrev":
|
||||
default:
|
||||
elog.Printf("unknown meta genus: %s", genus)
|
||||
|
@ -1151,14 +1149,14 @@ func prepareStatements(db *sql.DB) {
|
|||
smalllimit := " order by honks.honkid desc limit ?"
|
||||
butnotthose := " and convoy not in (select name from zonkers where userid = ? and wherefore = 'zonvoy' order by zonkerid desc limit 100)"
|
||||
stmtOneXonk = preparetodie(db, selecthonks+"where honks.userid = ? and xid = ?")
|
||||
stmtAnyXonk = preparetodie(db, selecthonks+"where xid = ? order by honks.honkid asc")
|
||||
stmtAnyXonk = preparetodie(db, selecthonks+"where xid = ? and what <> 'bonk' order by honks.honkid asc")
|
||||
stmtOneBonk = preparetodie(db, selecthonks+"where honks.userid = ? and xid = ? and what = 'bonk' and whofore = 2")
|
||||
stmtPublicHonks = preparetodie(db, selecthonks+"where whofore = 2 and dt > ?"+smalllimit)
|
||||
stmtEventHonks = preparetodie(db, selecthonks+"where (whofore = 2 or honks.userid = ?) and what = 'event'"+smalllimit)
|
||||
stmtUserHonks = preparetodie(db, selecthonks+"where honks.honkid > ? and (whofore = 2 or whofore = ?) and username = ? and dt > ?"+smalllimit)
|
||||
myhonkers := " and honker in (select xid from honkers where userid = ? and (flavor = 'sub' or flavor = 'peep' or flavor = 'presub') and combos not like '% - %')"
|
||||
stmtHonksForUser = preparetodie(db, selecthonks+"where honks.honkid > ? and honks.userid = ? and dt > ?"+myhonkers+butnotthose+limit)
|
||||
stmtHonksForUserFirstClass = preparetodie(db, selecthonks+"where honks.honkid > ? and honks.userid = ? and dt > ? and (what <> 'tonk')"+myhonkers+butnotthose+limit)
|
||||
stmtHonksForUserFirstClass = preparetodie(db, selecthonks+"where honks.honkid > ? and honks.userid = ? and dt > ? and (rid = '' or what = 'bonk')"+myhonkers+butnotthose+limit)
|
||||
stmtHonksForMe = preparetodie(db, selecthonks+"where honks.honkid > ? and honks.userid = ? and dt > ? and whofore = 1"+butnotthose+limit)
|
||||
stmtHonksFromLongAgo = preparetodie(db, selecthonks+"where honks.honkid > ? and honks.userid = ? and dt > ? and dt < ? and whofore = 2"+butnotthose+limit)
|
||||
stmtHonksISaved = preparetodie(db, selecthonks+"where honks.honkid > ? and honks.userid = ? and flags & 4 order by honks.honkid desc")
|
||||
|
|
12
fun.go
12
fun.go
|
@ -66,7 +66,7 @@ func reverbolate(userid int64, honks []*Honk) {
|
|||
somenumberedusers.Get(userid, &user)
|
||||
for _, h := range honks {
|
||||
h.What += "ed"
|
||||
if h.What == "tonked" {
|
||||
if h.What == "honked" && h.RID != "" {
|
||||
h.What = "honked back"
|
||||
h.Style += " subtle"
|
||||
}
|
||||
|
@ -694,13 +694,9 @@ func savingthrow(keyname string) {
|
|||
}
|
||||
|
||||
func keymatch(keyname string, actor string) string {
|
||||
hash := strings.IndexByte(keyname, '#')
|
||||
if hash == -1 {
|
||||
hash = len(keyname)
|
||||
}
|
||||
owner := keyname[0:hash]
|
||||
if owner == actor {
|
||||
return originate(actor)
|
||||
origin := originate(actor)
|
||||
if origin == originate(keyname) {
|
||||
return origin
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
|
1
honk.go
1
honk.go
|
@ -155,7 +155,6 @@ const (
|
|||
flagIsSaved = 4
|
||||
flagIsUntagged = 8
|
||||
flagIsReacted = 16
|
||||
flagIsWonked = 32
|
||||
)
|
||||
|
||||
func (honk *Honk) IsAcked() bool {
|
||||
|
|
|
@ -148,9 +148,6 @@ func importMastotoots(user *WhatAbout, source string) {
|
|||
Format: "html",
|
||||
Precis: toot.Object.Summary,
|
||||
}
|
||||
if honk.RID != "" {
|
||||
honk.What = "tonk"
|
||||
}
|
||||
if !loudandproud(honk.Audience) {
|
||||
honk.Whofore = 3
|
||||
}
|
||||
|
@ -387,13 +384,11 @@ func importTwitter(username, source string) {
|
|||
noise := ""
|
||||
if parent := tweetmap[t.Tweet.InReplyToStatusID]; parent != nil {
|
||||
t.convoy = parent.convoy
|
||||
what = "tonk"
|
||||
} else {
|
||||
t.convoy = "data:,acoustichonkytonk-" + t.Tweet.IdStr
|
||||
if t.Tweet.InReplyToScreenName != "" {
|
||||
noise = fmt.Sprintf("re: https://twitter.com/%s/status/%s\n\n",
|
||||
t.Tweet.InReplyToScreenName, t.Tweet.InReplyToStatusID)
|
||||
what = "tonk"
|
||||
}
|
||||
}
|
||||
audience := []string{thewholeworld}
|
||||
|
|
11
unveil.go
11
unveil.go
|
@ -25,11 +25,10 @@ package main
|
|||
import "C"
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"unsafe"
|
||||
)
|
||||
|
||||
func Unveil(path string, perms string) error {
|
||||
func Unveil(path string, perms string) {
|
||||
cpath := C.CString(path)
|
||||
defer C.free(unsafe.Pointer(cpath))
|
||||
cperms := C.CString(perms)
|
||||
|
@ -37,20 +36,18 @@ func Unveil(path string, perms string) error {
|
|||
|
||||
rv, err := C.unveil(cpath, cperms)
|
||||
if rv != 0 {
|
||||
return fmt.Errorf("unveil(%s, %s) failure (%d)", path, perms, err)
|
||||
elog.Fatalf("unveil(%s, %s) failure (%d)", path, perms, err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func Pledge(promises string) error {
|
||||
func Pledge(promises string) {
|
||||
cpromises := C.CString(promises)
|
||||
defer C.free(unsafe.Pointer(cpromises))
|
||||
|
||||
rv, err := C.pledge(cpromises, nil)
|
||||
if rv != 0 {
|
||||
return fmt.Errorf("pledge(%s) failure (%d)", promises, err)
|
||||
elog.Fatalf("pledge(%s) failure (%d)", promises, err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func init() {
|
||||
|
|
165
upgradedb.go
165
upgradedb.go
|
@ -18,11 +18,9 @@ package main
|
|||
import (
|
||||
"database/sql"
|
||||
"os"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
var myVersion = 42
|
||||
var myVersion = 43
|
||||
|
||||
type dbexecer interface {
|
||||
Exec(query string, args ...interface{}) (sql.Result, error)
|
||||
|
@ -41,164 +39,10 @@ func upgradedb() {
|
|||
getconfig("dbversion", &dbversion)
|
||||
getconfig("servername", &serverName)
|
||||
|
||||
if dbversion < 13 {
|
||||
if dbversion < 40 {
|
||||
elog.Fatal("database is too old to upgrade")
|
||||
}
|
||||
switch dbversion {
|
||||
case 25:
|
||||
doordie(db, "delete from auth")
|
||||
doordie(db, "alter table auth add column expiry text")
|
||||
doordie(db, "update config set value = 26 where key = 'dbversion'")
|
||||
fallthrough
|
||||
case 26:
|
||||
s := ""
|
||||
getconfig("servermsg", &s)
|
||||
if s == "" {
|
||||
setconfig("servermsg", "<h2>Things happen.</h2>")
|
||||
}
|
||||
s = ""
|
||||
getconfig("aboutmsg", &s)
|
||||
if s == "" {
|
||||
setconfig("aboutmsg", "<h3>What is honk?</h3><p>Honk is amazing!")
|
||||
}
|
||||
s = ""
|
||||
getconfig("loginmsg", &s)
|
||||
if s == "" {
|
||||
setconfig("loginmsg", "<h2>login</h2>")
|
||||
}
|
||||
d := -1
|
||||
getconfig("devel", &d)
|
||||
if d == -1 {
|
||||
setconfig("devel", 0)
|
||||
}
|
||||
doordie(db, "update config set value = 27 where key = 'dbversion'")
|
||||
fallthrough
|
||||
case 27:
|
||||
createserveruser(db)
|
||||
doordie(db, "update config set value = 28 where key = 'dbversion'")
|
||||
fallthrough
|
||||
case 28:
|
||||
doordie(db, "drop table doovers")
|
||||
doordie(db, "create table doovers(dooverid integer primary key, dt text, tries integer, userid integer, rcpt text, msg blob)")
|
||||
doordie(db, "update config set value = 29 where key = 'dbversion'")
|
||||
fallthrough
|
||||
case 29:
|
||||
doordie(db, "alter table honkers add column owner text")
|
||||
doordie(db, "update honkers set owner = xid")
|
||||
doordie(db, "update config set value = 30 where key = 'dbversion'")
|
||||
fallthrough
|
||||
case 30:
|
||||
tx, err := db.Begin()
|
||||
if err != nil {
|
||||
elog.Fatal(err)
|
||||
}
|
||||
rows, err := tx.Query("select userid, options from users")
|
||||
if err != nil {
|
||||
elog.Fatal(err)
|
||||
}
|
||||
m := make(map[int64]string)
|
||||
for rows.Next() {
|
||||
var userid int64
|
||||
var options string
|
||||
err = rows.Scan(&userid, &options)
|
||||
if err != nil {
|
||||
elog.Fatal(err)
|
||||
}
|
||||
var uo UserOptions
|
||||
uo.SkinnyCSS = strings.Contains(options, " skinny ")
|
||||
m[userid], err = jsonify(uo)
|
||||
if err != nil {
|
||||
elog.Fatal(err)
|
||||
}
|
||||
}
|
||||
rows.Close()
|
||||
for u, o := range m {
|
||||
_, err = tx.Exec("update users set options = ? where userid = ?", o, u)
|
||||
if err != nil {
|
||||
elog.Fatal(err)
|
||||
}
|
||||
}
|
||||
err = tx.Commit()
|
||||
if err != nil {
|
||||
elog.Fatal(err)
|
||||
}
|
||||
doordie(db, "update config set value = 31 where key = 'dbversion'")
|
||||
fallthrough
|
||||
case 31:
|
||||
doordie(db, "create table tracks (xid text, fetches text)")
|
||||
doordie(db, "create index idx_trackhonkid on tracks(xid)")
|
||||
doordie(db, "update config set value = 32 where key = 'dbversion'")
|
||||
fallthrough
|
||||
case 32:
|
||||
doordie(db, "alter table xonkers add column dt text")
|
||||
doordie(db, "update xonkers set dt = ?", time.Now().UTC().Format(dbtimeformat))
|
||||
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:
|
||||
doordie(db, "create table chonks (chonkid integer primary key, userid integer, xid text, who txt, target text, dt text, noise text, format text)")
|
||||
doordie(db, "update config set value = 35 where key = 'dbversion'")
|
||||
fallthrough
|
||||
case 35:
|
||||
doordie(db, "alter table donks add column chonkid integer")
|
||||
doordie(db, "update donks set chonkid = -1")
|
||||
doordie(db, "create index idx_donkshonk on donks(honkid)")
|
||||
doordie(db, "create index idx_donkschonk on donks(chonkid)")
|
||||
doordie(db, "update config set value = 36 where key = 'dbversion'")
|
||||
fallthrough
|
||||
case 36:
|
||||
doordie(db, "alter table honkers add column folxid text")
|
||||
doordie(db, "update honkers set folxid = 'lostdata'")
|
||||
doordie(db, "update config set value = 37 where key = 'dbversion'")
|
||||
fallthrough
|
||||
case 37:
|
||||
doordie(db, "update honkers set combos = '' where combos is null")
|
||||
doordie(db, "update honkers set owner = '' where owner is null")
|
||||
doordie(db, "update honkers set meta = '' where meta is null")
|
||||
doordie(db, "update honkers set folxid = '' where folxid is null")
|
||||
doordie(db, "update config set value = 38 where key = 'dbversion'")
|
||||
fallthrough
|
||||
case 38:
|
||||
doordie(db, "update honkers set folxid = abs(random())")
|
||||
doordie(db, "update config set value = 39 where key = 'dbversion'")
|
||||
fallthrough
|
||||
case 39:
|
||||
blobdb := openblobdb()
|
||||
doordie(blobdb, "alter table filedata add column hash text")
|
||||
doordie(blobdb, "create index idx_filehash on filedata(hash)")
|
||||
rows, err := blobdb.Query("select xid, content from filedata")
|
||||
if err != nil {
|
||||
elog.Fatal(err)
|
||||
}
|
||||
m := make(map[string]string)
|
||||
for rows.Next() {
|
||||
var xid string
|
||||
var data sql.RawBytes
|
||||
err := rows.Scan(&xid, &data)
|
||||
if err != nil {
|
||||
elog.Fatal(err)
|
||||
}
|
||||
hash := hashfiledata(data)
|
||||
m[xid] = hash
|
||||
}
|
||||
rows.Close()
|
||||
tx, err := blobdb.Begin()
|
||||
if err != nil {
|
||||
elog.Fatal(err)
|
||||
}
|
||||
for xid, hash := range m {
|
||||
doordie(tx, "update filedata set hash = ? where xid = ?", hash, xid)
|
||||
}
|
||||
err = tx.Commit()
|
||||
if err != nil {
|
||||
elog.Fatal(err)
|
||||
}
|
||||
doordie(db, "update config set value = 40 where key = 'dbversion'")
|
||||
fallthrough
|
||||
case 40:
|
||||
doordie(db, "PRAGMA journal_mode=WAL")
|
||||
blobdb := openblobdb()
|
||||
|
@ -238,6 +82,11 @@ func upgradedb() {
|
|||
doordie(db, "update config set value = 42 where key = 'dbversion'")
|
||||
fallthrough
|
||||
case 42:
|
||||
doordie(db, "update honks set what = 'honk', flags = flags & ~ 32 where what = 'tonk' or what = 'wonk'")
|
||||
doordie(db, "delete from honkmeta where genus = 'wonkles' or genus = 'guesses'")
|
||||
doordie(db, "update config set value = 43 where key = 'dbversion'")
|
||||
fallthrough
|
||||
case 43:
|
||||
|
||||
default:
|
||||
elog.Fatalf("can't upgrade unknown version %d", dbversion)
|
||||
|
|
12
web.go
12
web.go
|
@ -723,14 +723,19 @@ func showuser(w http.ResponseWriter, r *http.Request) {
|
|||
return
|
||||
}
|
||||
u := login.GetUserInfo(r)
|
||||
honks := gethonksbyuser(name, u != nil && u.Username == name, 0)
|
||||
if u != nil && u.Username != name {
|
||||
u = nil
|
||||
}
|
||||
honks := gethonksbyuser(name, u != nil, 0)
|
||||
templinfo := getInfo(r)
|
||||
templinfo["PageName"] = "user"
|
||||
templinfo["PageArg"] = name
|
||||
templinfo["Name"] = user.Name
|
||||
templinfo["WhatAbout"] = user.HTAbout
|
||||
templinfo["ServerMessage"] = ""
|
||||
if u != nil {
|
||||
templinfo["HonkCSRF"] = login.GetCSRF("honkhonk", r)
|
||||
}
|
||||
honkpage(w, u, honks, templinfo)
|
||||
}
|
||||
|
||||
|
@ -1184,7 +1189,9 @@ func showonehonk(w http.ResponseWriter, r *http.Request) {
|
|||
}
|
||||
|
||||
templinfo["ServerMessage"] = "one honk maybe more"
|
||||
if u != nil {
|
||||
templinfo["HonkCSRF"] = login.GetCSRF("honkhonk", r)
|
||||
}
|
||||
templinfo["APAltLink"] = templates.Sprintf("<link href='%s' rel='alternate' type='application/activity+json'>", xid)
|
||||
honkpage(w, u, honks, templinfo)
|
||||
}
|
||||
|
@ -1708,9 +1715,6 @@ func submithonk(w http.ResponseWriter, r *http.Request) *Honk {
|
|||
} else {
|
||||
xid := fmt.Sprintf("%s/%s/%s", user.URL, honkSep, xfiltrate())
|
||||
what := "honk"
|
||||
if rid != "" {
|
||||
what = "tonk"
|
||||
}
|
||||
honk = &Honk{
|
||||
UserID: userinfo.UserID,
|
||||
Username: userinfo.Username,
|
||||
|
|
Loading…
Reference in New Issue