From bc9586893bff0b0fc3740987b3a35d586b7e7514 Mon Sep 17 00:00:00 2001 From: Alexandr Burdiyan Date: Wed, 13 Sep 2023 19:48:33 +0200 Subject: [PATCH] Make aliases one word --- backend/daemon/api/accounts/v1alpha/accounts.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/backend/daemon/api/accounts/v1alpha/accounts.go b/backend/daemon/api/accounts/v1alpha/accounts.go index 4ee91f76d2..77b3adb0c2 100644 --- a/backend/daemon/api/accounts/v1alpha/accounts.go +++ b/backend/daemon/api/accounts/v1alpha/accounts.go @@ -10,6 +10,7 @@ import ( "mintter/backend/hyper" "mintter/backend/hyper/hypersql" "mintter/backend/pkg/future" + "strings" "crawshaw.io/sqlite" "github.com/ipfs/go-cid" @@ -193,6 +194,14 @@ func UpdateProfile(ctx context.Context, me core.Identity, blobs *hyper.Storage, patch := map[string]any{} + if in.Alias != "" { + parts := strings.Fields(in.Alias) + if len(parts) != 1 { + return fmt.Errorf("alias must be a single word: got = %q", in.Alias) + } + in.Alias = parts[0] + } + v, ok := e.Get("alias") if (ok && v.(string) != in.Alias) || (!ok && in.Alias != "") { patch["alias"] = in.Alias