all repos — honk @ a9f7da5ff199ae65fb3be7d471faa54e165e87f2

my fork of honk

masto.go (view raw)

  1package main
  2
  3import (
  4	"fmt"
  5	"net/http"
  6
  7	"humungus.tedunangst.com/r/webs/junk"
  8)
  9
 10func badjunk(rw http.ResponseWriter, j junk.Junk, path string) {
 11	elog.Printf("%s: bad junk: %s", path, j.ToString())
 12	http.Error(rw, fmt.Sprintf("%s: bad junk", path), http.StatusBadRequest)
 13}
 14
 15// https://docs.joinmastodon.org/methods/apps/#create
 16func apiapps(rw http.ResponseWriter, r *http.Request) {
 17	dlog.Println(r.Form.Encode())
 18	clientName := r.Form.Get("client_name")
 19	redirectUris := r.Form.Get("redirect_uris")
 20	scopes := r.Form.Get("scopes")
 21	web := r.Form.Get("website")
 22
 23	dlog.Println(clientName, redirectUris, scopes, web)
 24}
 25
 26// https://docs.joinmastodon.org/methods/oauth/#authorize
 27func oauthorize(rw http.ResponseWriter, r *http.Request) {
 28	dlog.Println(r.URL.RawQuery)
 29}
 30
 31// https://docs.joinmastodon.org/methods/instance/#v2
 32func instance(rw http.ResponseWriter, r *http.Request) {
 33	j := junk.New()
 34
 35	var servername string
 36	if err := getconfig("servername", &servername); err != nil {
 37		http.Error(rw, "getting servername", http.StatusInternalServerError)
 38		return
 39	}
 40
 41	j["uri"] = servername
 42	j["title"] = "honk"
 43	j["description"] = "federated honk conveyance"
 44	j["version"] = "develop"
 45
 46	thumbnail := junk.New()
 47	thumbnail["url"] = fmt.Sprintf("https://%s/icon.png", servername)
 48	j["thumbnail"] = thumbnail
 49	j["languages"] = []string{"en"}
 50
 51	config := junk.New()
 52
 53	a := junk.New()
 54	a["max_featured_tags"] = 10
 55	config["accounts"] = a
 56
 57	s := junk.New()
 58	s["max_characters"] = 5000
 59	s["max_media_attachments"] = 1
 60	s["characters_reserved_per_url"] = 23
 61	config["statuses"] = s
 62
 63	m := junk.New()
 64	m["supported_mime_types"] = []string{
 65		"image/jpeg",
 66		"image/png",
 67		"image/gif",
 68		"image/heic",
 69		"image/heif",
 70		"image/webp",
 71		"image/avif",
 72		"video/webm",
 73		"video/mp4",
 74		"video/quicktime",
 75		"video/ogg",
 76		"audio/wave",
 77		"audio/wav",
 78		"audio/x-wav",
 79		"audio/x-pn-wave",
 80		"audio/vnd.wave",
 81		"audio/ogg",
 82		"audio/vorbis",
 83		"audio/mpeg",
 84		"audio/mp3",
 85		"audio/webm",
 86		"audio/flac",
 87		"audio/aac",
 88		"audio/m4a",
 89		"audio/x-m4a",
 90		"audio/mp4",
 91		"audio/3gpp",
 92		"video/x-ms-asf",
 93	}
 94
 95	m["image_size_limit"] = 10485760
 96	m["image_matrix_limit"] = 16777216
 97	m["video_size_limit"] = 41943040
 98	m["video_frame_rate_limit"] = 60
 99	m["video_matrix_limit"] = 2304000
100	j["media_attachments"] = m
101
102	err := j.Write(rw)
103	if err != nil {
104		http.Error(rw, "writing json", http.StatusInternalServerError)
105	}
106	return
107}