Started work on linstrom specific endpoints

Router plus a bunch of placeholder handlers
Also a poll on fedi regarding streamed events (one vs many channels)
This commit is contained in:
Melody Becker 2024-10-29 16:09:21 +01:00
parent 1fb924f59c
commit 4f4d05a335
11 changed files with 103 additions and 39 deletions

View file

@ -18,6 +18,7 @@
/>
</div>
<div class="registration-form-description-wrapper">
{{! TODO: Split into entry form on the left and live preview on the right }}
<label for="registration-description">
Description
</label>

View file

@ -1,29 +1,29 @@
import { action } from '@ember/object';
import Component from '@glimmer/component';
import { tracked } from '@glimmer/tracking';
import isValidMail from 'frontend-reactive/helpers/is-valid-mail';
import { action } from '@ember/object'
import Component from '@glimmer/component'
import { tracked } from '@glimmer/tracking'
import isValidMail from 'frontend-reactive/helpers/is-valid-mail'
export interface AuthPostRegistrationFormSignature {
// The arguments accepted by the component
Args: {
username: string;
};
username: string
}
// Any blocks yielded by the component
Blocks: {
default: [];
};
default: []
}
// The element to which `...attributes` is applied in the component template
Element: null;
Element: null
}
export default class AuthPostRegistrationForm extends Component<AuthPostRegistrationFormSignature> {
@tracked displayname: string = this.args.username;
@tracked description: string = '';
@tracked gender: Array<{ value: string }> = [];
@tracked displayname: string = this.args.username
@tracked description: string = ''
@tracked gender: Array<{ value: string }> = []
@tracked beingTypes: Array<{
name: string;
checked: boolean;
description: string;
name: string
checked: boolean
description: string
}> = [
{
name: 'Human',
@ -55,22 +55,22 @@ export default class AuthPostRegistrationForm extends Component<AuthPostRegistra
description: 'Doll',
checked: false,
},
];
@tracked defaultpostmode: string = 'Public';
@tracked followapproval: boolean = false;
// Actual custom properties stored in here
@tracked customProperties: Array<{ key: string; value: string }> = [];
@tracked indexable: boolean = true;
@tracked mail = { mail: '', valid: false };
]
@tracked defaultpostmode: string = 'Public'
@tracked followapproval: boolean = false
@tracked customProperties: Array<{ key: string; value: string }> = []
@tracked indexable: boolean = true
@tracked mail = { mail: '', valid: false }
@tracked enableBlueskyIntegration = false
genderAddedHandler(newIndex: number) {
console.log('gender added');
console.log('gender added')
}
genderRemovedHandler(removedIndex: number) {
console.log('gender removed');
console.log('gender removed')
}
@action test() {
console.log(this.mail);
console.log(this.mail)
}
}

2
go.mod
View file

@ -55,6 +55,8 @@ require (
github.com/go-webauthn/x v0.1.14 // indirect
github.com/golang-jwt/jwt/v5 v5.2.1 // indirect
github.com/google/go-tpm v0.9.1 // indirect
github.com/google/jsonapi v1.0.0 // indirect
github.com/gorilla/websocket v1.5.3 // indirect
github.com/jackc/pgpassfile v1.0.0 // indirect
github.com/jackc/pgservicefile v0.0.0-20221227161230-091c0ba34f0a // indirect
github.com/jackc/pgx/v5 v5.4.3 // indirect

4
go.sum
View file

@ -162,6 +162,8 @@ github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeN
github.com/google/go-tpm v0.9.1 h1:0pGc4X//bAlmZzMKf8iz6IsDo1nYTbYJ6FZN/rg4zdM=
github.com/google/go-tpm v0.9.1/go.mod h1:h9jEsEECg7gtLis0upRBQU+GhYVH6jMjrFxI8u6bVUY=
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
github.com/google/jsonapi v1.0.0 h1:qIGgO5Smu3yJmSs+QlvhQnrscdZfFhiV6S8ryJAglqU=
github.com/google/jsonapi v1.0.0/go.mod h1:YYHiRPJT8ARXGER8In9VuLv4qvLfDmA9ULQqptbLE4s=
github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs=
github.com/google/martian/v3 v3.0.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0=
github.com/google/pprof v0.0.0-20181206194817-3ea8567a2e57/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc=
@ -176,6 +178,8 @@ github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg=
github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk=
github.com/gorilla/websocket v1.5.3 h1:saDtZ6Pbx/0u+bgYQ3q96pZgCzfhKXGPqt7kZ72aNNg=
github.com/gorilla/websocket v1.5.3/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc=

View file

@ -1 +0,0 @@
package server

View file

@ -1,5 +0,0 @@
package server
import "net/http"
func getLinstromNote(w http.ResponseWriter, r *http.Request) {}

View file

@ -1,8 +0,0 @@
package server
import "net/http"
func setupApiFrontendRouter() http.Handler {
router := http.NewServeMux()
return router
}

36
server/apiLinstrom.go Normal file
View file

@ -0,0 +1,36 @@
package server
import "net/http"
func setupLinstromApiRouter() http.Handler {
router := http.NewServeMux()
router.Handle("/v1/", http.StripPrefix("/v1", setupLinstromApiV1Router()))
return router
}
func setupLinstromApiV1Router() http.Handler {
router := http.NewServeMux()
// Notes
router.HandleFunc("GET /note/{noteId}", linstromGetNote)
router.HandleFunc("POST /note", linstromNewNote)
router.HandleFunc("PUT /note/{noteId}", linstromUpdateNote)
router.HandleFunc("DELETE /note/{noteId}", linstromDeleteNote)
// Reactions
router.HandleFunc("GET /note/{noteId}/reactions", linstromGetReactions)
router.HandleFunc("POST /note/{noteId}/reactions", linstromAddReaction)
router.HandleFunc("PUT /note/{noteId}/reactions", linstromUpdateReaction)
router.HandleFunc("DELETE /note/{noteId}/reactions", linstromDeleteReaction)
// Boosts
router.HandleFunc("GET /note/{noteId}/boosts", linstromGetBoosts)
router.HandleFunc("POST /note/{noteId}/boosts", linstromAddBoost)
router.HandleFunc("DELETE /note/{noteId}/boosts", linstromRemoveBoost)
// Quotes
router.HandleFunc("GET /note/{noteId}/quotes", linstromGetQuotes)
router.HandleFunc("POST /note/{noteId}/quotes", linstromAddQuote)
// Pinning
router.HandleFunc("POST /note/{noteId}/pin", linstromPinNote)
router.HandleFunc("DELETE /note/{noteId}/pin", linstromUnpinNote)
return router
}

View file

@ -0,0 +1,29 @@
package server
import "net/http"
// Notes
func linstromGetNote(w http.ResponseWriter, r *http.Request) {}
func linstromUpdateNote(w http.ResponseWriter, r *http.Request) {}
func linstromNewNote(w http.ResponseWriter, r *http.Request) {}
func linstromDeleteNote(w http.ResponseWriter, r *http.Request) {}
// Reactions
func linstromGetReactions(w http.ResponseWriter, r *http.Request) {}
func linstromAddReaction(w http.ResponseWriter, r *http.Request) {}
func linstromDeleteReaction(w http.ResponseWriter, r *http.Request) {}
func linstromUpdateReaction(w http.ResponseWriter, r *http.Request) {}
// Boosts
func linstromGetBoosts(w http.ResponseWriter, r *http.Request) {}
func linstromAddBoost(w http.ResponseWriter, r *http.Request) {}
func linstromRemoveBoost(w http.ResponseWriter, r *http.Request) {}
// Quotes
func linstromGetQuotes(w http.ResponseWriter, r *http.Request) {}
func linstromAddQuote(w http.ResponseWriter, r *http.Request) {}
// No delete quote since quotes are their own notes with an extra attribute
func linstromPinNote(w http.ResponseWriter, r *http.Request) {}
func linstromUnpinNote(w http.ResponseWriter, r *http.Request) {}

View file

@ -0,0 +1,5 @@
package server
// TODO: Decide where to put data stream handlers
// Entrypoint for a new stream will be in here at least

View file

@ -5,6 +5,7 @@ import "net/http"
// Mounted at /api
func setupApiRouter() http.Handler {
router := http.NewServeMux()
router.Handle("/linstrom/", setupLinstromApiRouter())
// Section MastoApi
router.HandleFunc("GET /oauth/authorize", placeholderEndpoint)