all repos — honk @ e72543c2cb7debfcbf050d71328be636afb2c0bb

my fork of honk

u
Anirudh Oppiliappan x@icyphox.sh
Mon, 13 Mar 2023 23:20:04 +0530
commit

e72543c2cb7debfcbf050d71328be636afb2c0bb

parent

c07856ff6a490ff41b22116029ee578acf96a77f

2 files changed, 85 insertions(+), 0 deletions(-)

jump to
M masto.gomasto.go

@@ -1,6 +1,7 @@

package main import ( + "fmt" "net/http" "humungus.tedunangst.com/r/webs/junk"

@@ -11,21 +12,103 @@ elog.Printf("oauthorize: bad junk: %v", j)

http.Error(rw, "oauthorize: bad junk", http.StatusBadRequest) } +// https://docs.joinmastodon.org/methods/apps/#create func apiapps(rw http.ResponseWriter, r *http.Request) { j, err := junk.Read(r.Body) if err != nil { badjunk(rw, j) + return } dlog.Println(j) } +// https://docs.joinmastodon.org/methods/oauth/#authorize func oauthorize(rw http.ResponseWriter, r *http.Request) { j, err := junk.Read(r.Body) if err != nil { badjunk(rw, j) + return } dlog.Println(j) } + +// https://docs.joinmastodon.org/methods/instance/#v2 +func instance(rw http.ResponseWriter, r *http.Request) { + j := junk.New() + + var servername string + if err := getconfig("servername", &servername); err != nil { + http.Error(rw, "getting servername", http.StatusInternalServerError) + return + } + + j["uri"] = servername + j["title"] = "honk" + j["description"] = "federated honk conveyance" + j["version"] = "develop" + + thumbnail := junk.New() + thumbnail["url"] = fmt.Sprintf("https://%s/icon.png", servername) + j["thumbnail"] = thumbnail + j["languages"] = []string{"en"} + + config := junk.New() + + a := junk.New() + a["max_featured_tags"] = 10 + config["accounts"] = a + + s := junk.New() + s["max_characters"] = 5000 + s["max_media_attachments"] = 1 + s["characters_reserved_per_url"] = 23 + config["statuses"] = s + + m := junk.New() + m["supported_mime_types"] = []string{ + "image/jpeg", + "image/png", + "image/gif", + "image/heic", + "image/heif", + "image/webp", + "image/avif", + "video/webm", + "video/mp4", + "video/quicktime", + "video/ogg", + "audio/wave", + "audio/wav", + "audio/x-wav", + "audio/x-pn-wave", + "audio/vnd.wave", + "audio/ogg", + "audio/vorbis", + "audio/mpeg", + "audio/mp3", + "audio/webm", + "audio/flac", + "audio/aac", + "audio/m4a", + "audio/x-m4a", + "audio/mp4", + "audio/3gpp", + "video/x-ms-asf", + } + + m["image_size_limit"] = 10485760 + m["image_matrix_limit"] = 16777216 + m["video_size_limit"] = 41943040 + m["video_frame_rate_limit"] = 60 + m["video_matrix_limit"] = 2304000 + j["media_attachments"] = m + + err := j.Write(rw) + if err != nil { + http.Error(rw, "writing json", http.StatusInternalServerError) + } + return +}
M web.goweb.go

@@ -2850,6 +2850,8 @@ loggedin.Handle("/submithonker", login.CSRFWrap("submithonker", http.HandlerFunc(websubmithonker)))

// mastoshit getters.HandleFunc("/oauth/authorize", oauthorize) + getters.HandleFunc("/api/v1/instance", instance) + posters.HandleFunc("/api/v1/apps", apiapps) err = http.Serve(listener, mux) if err != nil {