Memos is an open-source, self-hosted note-taking app that brings your everyday thoughts together in a personal timeline. Your data stays yours, and you choose what to keep private or share.
Go dockerfossgomarkdownmemomicroblognote-takingnotesopen-sourceown-your-datareactself-hostedsqlitetimeline
chore: add instance url to profile
Stevenc3f381c8c52e
diff --git a/bin/memos/main.go b/bin/memos/main.goindex 4df196a74..c44d7f5ae 100644--- a/bin/memos/main.go+++ b/bin/memos/main.go@@ -44,6 +44,7 @@ var (DSN: viper.GetString("dsn"),Public: viper.GetBool("public"),PasswordAuth: viper.GetBool("password-auth"),+ InstanceURL: viper.GetString("instance-url"),Version: version.GetCurrentVersion(viper.GetString("mode")),}if err := instanceProfile.Validate(); err != nil {@@ -107,9 +108,7 @@ var (func init() {viper.SetDefault("mode", "demo")viper.SetDefault("driver", "sqlite")- viper.SetDefault("addr", "")viper.SetDefault("port", 8081)- viper.SetDefault("public", false)viper.SetDefault("password-auth", true)rootCmd.PersistentFlags().String("mode", "demo", `mode of server, can be "prod" or "dev" or "demo"`)@@ -120,37 +119,33 @@ func init() {rootCmd.PersistentFlags().String("dsn", "", "database source name(aka. DSN)")rootCmd.PersistentFlags().Bool("public", false, "")rootCmd.PersistentFlags().Bool("password-auth", true, "")+ rootCmd.PersistentFlags().String("instance-url", "", "the url of your memos instance")- err := viper.BindPFlag("mode", rootCmd.PersistentFlags().Lookup("mode"))- if err != nil {+ if err := viper.BindPFlag("mode", rootCmd.PersistentFlags().Lookup("mode")); err != nil {panic(err)}- err = viper.BindPFlag("addr", rootCmd.PersistentFlags().Lookup("addr"))- if err != nil {+ if err := viper.BindPFlag("addr", rootCmd.PersistentFlags().Lookup("addr")); err != nil {panic(err)}- err = viper.BindPFlag("port", rootCmd.PersistentFlags().Lookup("port"))- if err != nil {+ if err := viper.BindPFlag("port", rootCmd.PersistentFlags().Lookup("port")); err != nil {panic(err)}- err = viper.BindPFlag("data", rootCmd.PersistentFlags().Lookup("data"))- if err != nil {+ if err := viper.BindPFlag("data", rootCmd.PersistentFlags().Lookup("data")); err != nil {panic(err)}- err = viper.BindPFlag("driver", rootCmd.PersistentFlags().Lookup("driver"))- if err != nil {+ if err := viper.BindPFlag("driver", rootCmd.PersistentFlags().Lookup("driver")); err != nil {panic(err)}- err = viper.BindPFlag("dsn", rootCmd.PersistentFlags().Lookup("dsn"))- if err != nil {+ if err := viper.BindPFlag("dsn", rootCmd.PersistentFlags().Lookup("dsn")); err != nil {panic(err)}- err = viper.BindPFlag("public", rootCmd.PersistentFlags().Lookup("public"))- if err != nil {+ if err := viper.BindPFlag("public", rootCmd.PersistentFlags().Lookup("public")); err != nil {panic(err)}- err = viper.BindPFlag("password-auth", rootCmd.PersistentFlags().Lookup("password-auth"))- if err != nil {+ if err := viper.BindPFlag("password-auth", rootCmd.PersistentFlags().Lookup("password-auth")); err != nil {+ panic(err)+ }+ if err := viper.BindPFlag("instance-url", rootCmd.PersistentFlags().Lookup("instance-url")); err != nil {panic(err)}@@ -159,6 +154,9 @@ func init() {if err := viper.BindEnv("password-auth", "MEMOS_PASSWORD_AUTH"); err != nil {panic(err)}+ if err := viper.BindEnv("instance-url", "MEMOS_INSTANCE_URL"); err != nil {+ panic(err)+ }}func printGreetings(profile *profile.Profile) {diff --git a/docs/apidocs.swagger.yaml b/docs/apidocs.swagger.yamlindex 499c0dc6c..3b291c7c4 100644--- a/docs/apidocs.swagger.yaml+++ b/docs/apidocs.swagger.yaml@@ -3154,3 +3154,6 @@ definitions:passwordAuth:type: booleandescription: password_auth is a flag whether the instance allows password authentication.+ instanceUrl:+ type: string+ description: instance_url is the URL of the instance.diff --git a/proto/api/v1/workspace_service.proto b/proto/api/v1/workspace_service.protoindex a6dc1c60e..36c1ad3bb 100644--- a/proto/api/v1/workspace_service.proto+++ b/proto/api/v1/workspace_service.proto@@ -25,6 +25,8 @@ message WorkspaceProfile {bool public = 4;// password_auth is a flag whether the instance allows password authentication.bool password_auth = 5;+ // instance_url is the URL of the instance.+ string instance_url = 6;}message GetWorkspaceProfileRequest {}diff --git a/proto/gen/api/v1/workspace_service.pb.go b/proto/gen/api/v1/workspace_service.pb.goindex a4fea41ef..d6904d606 100644--- a/proto/gen/api/v1/workspace_service.pb.go+++ b/proto/gen/api/v1/workspace_service.pb.go@@ -37,6 +37,8 @@ type WorkspaceProfile struct {Public bool `protobuf:"varint,4,opt,name=public,proto3" json:"public,omitempty"`// password_auth is a flag whether the instance allows password authentication.PasswordAuth bool `protobuf:"varint,5,opt,name=password_auth,json=passwordAuth,proto3" json:"password_auth,omitempty"`+ // instance_url is the URL of the instance.+ InstanceUrl string `protobuf:"bytes,6,opt,name=instance_url,json=instanceUrl,proto3" json:"instance_url,omitempty"`}func (x *WorkspaceProfile) Reset() {@@ -106,6 +108,13 @@ func (x *WorkspaceProfile) GetPasswordAuth() bool {return false}+func (x *WorkspaceProfile) GetInstanceUrl() string {+ if x != nil {+ return x.InstanceUrl+ }+ return ""+}+type GetWorkspaceProfileRequest struct {state protoimpl.MessageStatesizeCache protoimpl.SizeCache@@ -151,7 +160,7 @@ var file_api_v1_workspace_service_proto_rawDesc = []byte{0x63, 0x65, 0x5f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f,0x12, 0x0c, 0x6d, 0x65, 0x6d, 0x6f, 0x73, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x1a, 0x1c,0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x61, 0x6e, 0x6e, 0x6f, 0x74,- 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x93, 0x01, 0x0a,+ 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xb6, 0x01, 0x0a,0x10, 0x57, 0x6f, 0x72, 0x6b, 0x73, 0x70, 0x61, 0x63, 0x65, 0x50, 0x72, 0x6f, 0x66, 0x69, 0x6c,0x65, 0x12, 0x14, 0x0a, 0x05, 0x6f, 0x77, 0x6e, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09,0x52, 0x05, 0x6f, 0x77, 0x6e, 0x65, 0x72, 0x12, 0x18, 0x0a, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69,@@ -161,30 +170,32 @@ var file_api_v1_workspace_service_proto_rawDesc = []byte{0x04, 0x20, 0x01, 0x28, 0x08, 0x52, 0x06, 0x70, 0x75, 0x62, 0x6c, 0x69, 0x63, 0x12, 0x23, 0x0a,0x0d, 0x70, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x5f, 0x61, 0x75, 0x74, 0x68, 0x18, 0x05,0x20, 0x01, 0x28, 0x08, 0x52, 0x0c, 0x70, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x41, 0x75,- 0x74, 0x68, 0x22, 0x1c, 0x0a, 0x1a, 0x47, 0x65, 0x74, 0x57, 0x6f, 0x72, 0x6b, 0x73, 0x70, 0x61,- 0x63, 0x65, 0x50, 0x72, 0x6f, 0x66, 0x69, 0x6c, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74,- 0x32, 0x97, 0x01, 0x0a, 0x10, 0x57, 0x6f, 0x72, 0x6b, 0x73, 0x70, 0x61, 0x63, 0x65, 0x53, 0x65,- 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x82, 0x01, 0x0a, 0x13, 0x47, 0x65, 0x74, 0x57, 0x6f, 0x72,- 0x6b, 0x73, 0x70, 0x61, 0x63, 0x65, 0x50, 0x72, 0x6f, 0x66, 0x69, 0x6c, 0x65, 0x12, 0x28, 0x2e,- 0x6d, 0x65, 0x6d, 0x6f, 0x73, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x47, 0x65, 0x74,+ 0x74, 0x68, 0x12, 0x21, 0x0a, 0x0c, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x5f, 0x75,+ 0x72, 0x6c, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6e,+ 0x63, 0x65, 0x55, 0x72, 0x6c, 0x22, 0x1c, 0x0a, 0x1a, 0x47, 0x65, 0x74, 0x57, 0x6f, 0x72, 0x6b,+ 0x73, 0x70, 0x61, 0x63, 0x65, 0x50, 0x72, 0x6f, 0x66, 0x69, 0x6c, 0x65, 0x52, 0x65, 0x71, 0x75,+ 0x65, 0x73, 0x74, 0x32, 0x97, 0x01, 0x0a, 0x10, 0x57, 0x6f, 0x72, 0x6b, 0x73, 0x70, 0x61, 0x63,+ 0x65, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x82, 0x01, 0x0a, 0x13, 0x47, 0x65, 0x74,0x57, 0x6f, 0x72, 0x6b, 0x73, 0x70, 0x61, 0x63, 0x65, 0x50, 0x72, 0x6f, 0x66, 0x69, 0x6c, 0x65,- 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1e, 0x2e, 0x6d, 0x65, 0x6d, 0x6f, 0x73, 0x2e,- 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x57, 0x6f, 0x72, 0x6b, 0x73, 0x70, 0x61, 0x63, 0x65,- 0x50, 0x72, 0x6f, 0x66, 0x69, 0x6c, 0x65, 0x22, 0x21, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x1b, 0x12,- 0x19, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x76, 0x31, 0x2f, 0x77, 0x6f, 0x72, 0x6b, 0x73, 0x70, 0x61,- 0x63, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x66, 0x69, 0x6c, 0x65, 0x42, 0xad, 0x01, 0x0a, 0x10, 0x63,- 0x6f, 0x6d, 0x2e, 0x6d, 0x65, 0x6d, 0x6f, 0x73, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x42,- 0x15, 0x57, 0x6f, 0x72, 0x6b, 0x73, 0x70, 0x61, 0x63, 0x65, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63,- 0x65, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x30, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62,- 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x75, 0x73, 0x65, 0x6d, 0x65, 0x6d, 0x6f, 0x73, 0x2f, 0x6d, 0x65,- 0x6d, 0x6f, 0x73, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x67, 0x65, 0x6e, 0x2f, 0x61, 0x70,- 0x69, 0x2f, 0x76, 0x31, 0x3b, 0x61, 0x70, 0x69, 0x76, 0x31, 0xa2, 0x02, 0x03, 0x4d, 0x41, 0x58,- 0xaa, 0x02, 0x0c, 0x4d, 0x65, 0x6d, 0x6f, 0x73, 0x2e, 0x41, 0x70, 0x69, 0x2e, 0x56, 0x31, 0xca,- 0x02, 0x0c, 0x4d, 0x65, 0x6d, 0x6f, 0x73, 0x5c, 0x41, 0x70, 0x69, 0x5c, 0x56, 0x31, 0xe2, 0x02,- 0x18, 0x4d, 0x65, 0x6d, 0x6f, 0x73, 0x5c, 0x41, 0x70, 0x69, 0x5c, 0x56, 0x31, 0x5c, 0x47, 0x50,- 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x0e, 0x4d, 0x65, 0x6d, 0x6f,- 0x73, 0x3a, 0x3a, 0x41, 0x70, 0x69, 0x3a, 0x3a, 0x56, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74,- 0x6f, 0x33,+ 0x12, 0x28, 0x2e, 0x6d, 0x65, 0x6d, 0x6f, 0x73, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e,+ 0x47, 0x65, 0x74, 0x57, 0x6f, 0x72, 0x6b, 0x73, 0x70, 0x61, 0x63, 0x65, 0x50, 0x72, 0x6f, 0x66,+ 0x69, 0x6c, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1e, 0x2e, 0x6d, 0x65, 0x6d,+ 0x6f, 0x73, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x57, 0x6f, 0x72, 0x6b, 0x73, 0x70,+ 0x61, 0x63, 0x65, 0x50, 0x72, 0x6f, 0x66, 0x69, 0x6c, 0x65, 0x22, 0x21, 0x82, 0xd3, 0xe4, 0x93,+ 0x02, 0x1b, 0x12, 0x19, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x76, 0x31, 0x2f, 0x77, 0x6f, 0x72, 0x6b,+ 0x73, 0x70, 0x61, 0x63, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x66, 0x69, 0x6c, 0x65, 0x42, 0xad, 0x01,+ 0x0a, 0x10, 0x63, 0x6f, 0x6d, 0x2e, 0x6d, 0x65, 0x6d, 0x6f, 0x73, 0x2e, 0x61, 0x70, 0x69, 0x2e,+ 0x76, 0x31, 0x42, 0x15, 0x57, 0x6f, 0x72, 0x6b, 0x73, 0x70, 0x61, 0x63, 0x65, 0x53, 0x65, 0x72,+ 0x76, 0x69, 0x63, 0x65, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x30, 0x67, 0x69, 0x74,+ 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x75, 0x73, 0x65, 0x6d, 0x65, 0x6d, 0x6f, 0x73,+ 0x2f, 0x6d, 0x65, 0x6d, 0x6f, 0x73, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x67, 0x65, 0x6e,+ 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x76, 0x31, 0x3b, 0x61, 0x70, 0x69, 0x76, 0x31, 0xa2, 0x02, 0x03,+ 0x4d, 0x41, 0x58, 0xaa, 0x02, 0x0c, 0x4d, 0x65, 0x6d, 0x6f, 0x73, 0x2e, 0x41, 0x70, 0x69, 0x2e,+ 0x56, 0x31, 0xca, 0x02, 0x0c, 0x4d, 0x65, 0x6d, 0x6f, 0x73, 0x5c, 0x41, 0x70, 0x69, 0x5c, 0x56,+ 0x31, 0xe2, 0x02, 0x18, 0x4d, 0x65, 0x6d, 0x6f, 0x73, 0x5c, 0x41, 0x70, 0x69, 0x5c, 0x56, 0x31,+ 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x0e, 0x4d,+ 0x65, 0x6d, 0x6f, 0x73, 0x3a, 0x3a, 0x41, 0x70, 0x69, 0x3a, 0x3a, 0x56, 0x31, 0x62, 0x06, 0x70,+ 0x72, 0x6f, 0x74, 0x6f, 0x33,}var (diff --git a/server/profile/profile.go b/server/profile/profile.goindex f5ab8fd7a..8afcefcef 100644--- a/server/profile/profile.go+++ b/server/profile/profile.go@@ -31,6 +31,8 @@ type Profile struct {Public bool// PasswordAuth is the flag whether the instance uses password authentication.PasswordAuth bool+ // InstanceURL is the url of your memos instance.+ InstanceURL string}func (p *Profile) IsDev() bool {diff --git a/server/router/api/v1/workspace_service.go b/server/router/api/v1/workspace_service.goindex 1c7946912..dc74b8886 100644--- a/server/router/api/v1/workspace_service.go+++ b/server/router/api/v1/workspace_service.go@@ -17,6 +17,7 @@ func (s *APIV1Service) GetWorkspaceProfile(ctx context.Context, _ *v1pb.GetWorksMode: s.Profile.Mode,Public: s.Profile.Public,PasswordAuth: s.Profile.PasswordAuth,+ InstanceUrl: s.Profile.InstanceURL,}owner, err := s.GetInstanceOwner(ctx)if err != nil {