This commit is contained in:
parent
9990a205d8
commit
671d18d2ba
4 changed files with 51 additions and 3 deletions
|
@ -7,7 +7,6 @@ import (
|
|||
|
||||
"git.mstar.dev/mstar/goutils/other"
|
||||
"github.com/google/uuid"
|
||||
"github.com/rs/zerolog/log"
|
||||
"gorm.io/gorm"
|
||||
|
||||
"git.mstar.dev/mstar/linstrom/config"
|
||||
|
@ -27,7 +26,6 @@ func InsertSelf() error {
|
|||
if err != nil {
|
||||
return other.Error("storage", "failed to save/update self server", err)
|
||||
}
|
||||
log.Debug().Any("server", server).Send()
|
||||
user, err := insertUser(server)
|
||||
if err != nil {
|
||||
return other.Error("storage", "failed to save/update self user", err)
|
||||
|
@ -35,6 +33,9 @@ func InsertSelf() error {
|
|||
if err = insertUserPronoun(user); err != nil {
|
||||
return other.Error("storage", "failed to save/update self user pronoun", err)
|
||||
}
|
||||
if err = attachUserToRole(user); err != nil {
|
||||
return other.Error("storage", "failed to save/update self user to full admin role", err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
|
@ -152,3 +153,13 @@ func insertUserPronoun(user *models.User) error {
|
|||
return err
|
||||
}
|
||||
}
|
||||
|
||||
func attachUserToRole(user *models.User) error {
|
||||
u2r := models.UserToRole{
|
||||
User: *user,
|
||||
UserId: user.ID,
|
||||
Role: models.FullAdminRole,
|
||||
RoleId: models.FullAdminRole.ID,
|
||||
}
|
||||
return dbgen.UserToRole.Save(&u2r)
|
||||
}
|
||||
|
|
|
@ -1,3 +1,12 @@
|
|||
// Package webdebug provides a http server for local debugging.
|
||||
// The server is explicitly for localhost only as it offers
|
||||
// a lot more control and access than the public one.
|
||||
// Additionally, there is no guarantee for functional authentication
|
||||
// and authorisation of requests.
|
||||
// Using it can be considered a security risk.
|
||||
//
|
||||
// There is no guarantee for API stability. It might change drastically
|
||||
// across versions or even commits and doesn't need announcements
|
||||
package webdebug
|
||||
|
||||
import (
|
||||
|
@ -16,6 +25,8 @@ func New() *Server {
|
|||
handler.HandleFunc("GET /non-deleted", getNonDeletedUsers)
|
||||
handler.HandleFunc("POST /local-user", createLocalUser)
|
||||
handler.HandleFunc("GET /delete", deleteUser)
|
||||
handler.HandleFunc("POST /post-as", postAs)
|
||||
handler.HandleFunc("GET /notes-for", notesFrom)
|
||||
web := http.Server{
|
||||
Addr: DebugAddr,
|
||||
Handler: handler,
|
||||
|
|
|
@ -1,3 +1,29 @@
|
|||
// Package webpublic contains the public webserver
|
||||
// which provides the primary and only intended access point
|
||||
// for interacting with the system.
|
||||
//
|
||||
// # Sections
|
||||
//
|
||||
// - Frontend: Serves the various web frontend versions
|
||||
// - Main: The original Linstrom specific frontend
|
||||
// - NoJs: An entirely serverside rendered frontend, no JS included
|
||||
// - Custom: Custom frontend files will be served here
|
||||
//
|
||||
// - API: Endpoints for the actual interactions
|
||||
// - Frontend: The API used by the main frontend
|
||||
// - Masto: Mastodon compatible adapter for internal structures
|
||||
// - ActivityPub: For integration with the Fediverse via ActivityPub
|
||||
// - Linstrom-RPC: For Linstrom to Linstrom server communication
|
||||
//
|
||||
// # Guarantees
|
||||
//
|
||||
// - The Masto and ActivityPub API will remain stable
|
||||
// - Frontend API might change, but the intended consumer (Main frontend)
|
||||
// will always be up to date with the changes
|
||||
// - Linstrom-RPC API is versioned and will keep
|
||||
// a few versions of backwards compatibility
|
||||
//
|
||||
// TODO: Decide how long the Linstrom-RPC API will remain backwards compatible
|
||||
package webpublic
|
||||
|
||||
import "net/http"
|
||||
|
|
|
@ -39,7 +39,7 @@ type User struct {
|
|||
}
|
||||
|
||||
// Compiler assertations for interface implementations
|
||||
var _ shared.Santisable = &User{}
|
||||
var _ shared.Sanitisable = &User{}
|
||||
var _ shared.Clonable = &User{}
|
||||
|
||||
func (u *User) Sanitize() {
|
||||
|
|
Loading…
Reference in a new issue