diff --git a/services/notifications/pkg/channels/channels.go b/services/notifications/pkg/channels/channels.go index 5ac537e3f..c53ac84c6 100644 --- a/services/notifications/pkg/channels/channels.go +++ b/services/notifications/pkg/channels/channels.go @@ -7,10 +7,11 @@ import ( stdmail "net/mail" "strings" - "github.com/owncloud/ocis/v2/ocis-pkg/log" - "github.com/owncloud/ocis/v2/services/notifications/pkg/config" "github.com/pkg/errors" mail "github.com/xhit/go-simple-mail/v2" + + "github.com/owncloud/ocis/v2/ocis-pkg/log" + "github.com/owncloud/ocis/v2/services/notifications/pkg/config" ) // Channel defines the methods of a communication channel. @@ -108,7 +109,7 @@ func (m Mail) getMailClient() (*mail.SMTPClient, error) { } // SendMessage sends a message to all given users. -func (m Mail) SendMessage(ctx context.Context, message *Message) error { +func (m Mail) SendMessage(_ context.Context, message *Message) error { if m.conf.Notifications.SMTP.Host == "" { m.logger.Info().Str("mail", "SendMessage").Msg("failed to send a message. SMTP host is not set") return nil diff --git a/services/notifications/pkg/command/server.go b/services/notifications/pkg/command/server.go index 0b635a2a2..e6e2c0b66 100644 --- a/services/notifications/pkg/command/server.go +++ b/services/notifications/pkg/command/server.go @@ -4,10 +4,12 @@ import ( "context" "fmt" + "github.com/oklog/run" + "github.com/urfave/cli/v2" + "github.com/cs3org/reva/v2/pkg/events" "github.com/cs3org/reva/v2/pkg/events/stream" "github.com/cs3org/reva/v2/pkg/rgrpc/todo/pool" - "github.com/oklog/run" "github.com/owncloud/ocis/v2/ocis-pkg/config/configlog" "github.com/owncloud/ocis/v2/ocis-pkg/handlers" "github.com/owncloud/ocis/v2/ocis-pkg/registry" @@ -21,7 +23,6 @@ import ( "github.com/owncloud/ocis/v2/services/notifications/pkg/config/parser" "github.com/owncloud/ocis/v2/services/notifications/pkg/logging" "github.com/owncloud/ocis/v2/services/notifications/pkg/service" - "github.com/urfave/cli/v2" ) // Server is the entrypoint for the server command. @@ -82,6 +83,7 @@ func Server(cfg *config.Config) *cli.Command { events.SpaceShared{}, events.SpaceUnshared{}, events.SpaceMembershipExpired{}, + events.ScienceMeshInviteTokenGenerated{}, } client, err := stream.NatsFromConfig(cfg.Service.Name, false, stream.NatsConfig(cfg.Notifications.Events)) if err != nil { diff --git a/services/notifications/pkg/service/sciencemesh.go b/services/notifications/pkg/service/sciencemesh.go new file mode 100644 index 000000000..344a6bf22 --- /dev/null +++ b/services/notifications/pkg/service/sciencemesh.go @@ -0,0 +1,9 @@ +package service + +import ( + "github.com/cs3org/reva/v2/pkg/events" +) + +func (s eventsNotifier) handleScienceMeshInviteTokenGenerated(e events.ScienceMeshInviteTokenGenerated) { + // fixMe: add implementation +} diff --git a/services/notifications/pkg/service/service.go b/services/notifications/pkg/service/service.go index 3a48f788c..0da76d217 100644 --- a/services/notifications/pkg/service/service.go +++ b/services/notifications/pkg/service/service.go @@ -16,6 +16,9 @@ import ( user "github.com/cs3org/go-cs3apis/cs3/identity/user/v1beta1" rpc "github.com/cs3org/go-cs3apis/cs3/rpc/v1beta1" provider "github.com/cs3org/go-cs3apis/cs3/storage/provider/v1beta1" + "go-micro.dev/v4/metadata" + "google.golang.org/protobuf/types/known/fieldmaskpb" + "github.com/cs3org/reva/v2/pkg/events" "github.com/cs3org/reva/v2/pkg/rgrpc/todo/pool" "github.com/owncloud/ocis/v2/ocis-pkg/l10n" @@ -25,8 +28,6 @@ import ( "github.com/owncloud/ocis/v2/services/notifications/pkg/channels" "github.com/owncloud/ocis/v2/services/notifications/pkg/email" "github.com/owncloud/ocis/v2/services/settings/pkg/store/defaults" - "go-micro.dev/v4/metadata" - "google.golang.org/protobuf/types/known/fieldmaskpb" ) // Service should be named `Runner` @@ -92,6 +93,8 @@ func (s eventsNotifier) Run() error { s.handleShareCreated(e) case events.ShareExpired: s.handleShareExpired(e) + case events.ScienceMeshInviteTokenGenerated: + s.handleScienceMeshInviteTokenGenerated(e) } }() case <-s.signals: diff --git a/services/ocm/pkg/config/config.go b/services/ocm/pkg/config/config.go index c11efe7a4..4c81695d4 100644 --- a/services/ocm/pkg/config/config.go +++ b/services/ocm/pkg/config/config.go @@ -4,8 +4,9 @@ import ( "context" "time" - "github.com/owncloud/ocis/v2/ocis-pkg/shared" "go-micro.dev/v4/client" + + "github.com/owncloud/ocis/v2/ocis-pkg/shared" ) // Config combines all available configuration parts. @@ -24,6 +25,7 @@ type Config struct { GRPCClientTLS *shared.GRPCClientTLS `yaml:"grpc_client_tls"` GrpcClient client.Client `yaml:"-"` ServiceAccount ServiceAccount `yaml:"service_account"` + Events Events `yaml:"-"` Reva *shared.Reva `yaml:"reva"` OCMD OCMD `yaml:"ocmd"` @@ -146,3 +148,14 @@ type OCMShareProviderDrivers struct { type OCMShareProviderJSONDriver struct { File string `yaml:"file" env:"OCM_OCM_SHAREPROVIDER_JSON_FILE" desc:"Path to the JSON file where OCM share data will be stored. If not defined, the root directory derives from $OCIS_BASE_DATA_PATH:/storage." introductionVersion:"5.0"` } + +// Events combine the configuration options for the event bus. +type Events struct { + Endpoint string `yaml:"endpoint" env:"OCIS_EVENTS_ENDPOINT;OCM_EVENTS_ENDPOINT" desc:"The address of the event system. The event system is the message queuing service. It is used as message broker for the microservice architecture." introductionVersion:"pre5.0"` + Cluster string `yaml:"cluster" env:"OCIS_EVENTS_CLUSTER;OCM_EVENTS_CLUSTER" desc:"The clusterID of the event system. The event system is the message queuing service. It is used as message broker for the microservice architecture. Mandatory when using NATS as event system." introductionVersion:"pre5.0"` + TLSInsecure bool `yaml:"tls_insecure" env:"OCIS_INSECURE;OCM_EVENTS_TLS_INSECURE" desc:"Whether to verify the server TLS certificates." introductionVersion:"pre5.0"` + TLSRootCACertificate string `yaml:"tls_root_ca_certificate" env:"OCIS_EVENTS_TLS_ROOT_CA_CERTIFICATE;OCM_EVENTS_TLS_ROOT_CA_CERTIFICATE" desc:"The root CA certificate used to validate the server's TLS certificate. If provided OCM_EVENTS_TLS_INSECURE will be seen as false." introductionVersion:"pre5.0"` + EnableTLS bool `yaml:"enable_tls" env:"OCIS_EVENTS_ENABLE_TLS;OCM_EVENTS_ENABLE_TLS" desc:"Enable TLS for the connection to the events broker. The events broker is the ocis service which receives and delivers events between the services." introductionVersion:"pre5.0"` + AuthUsername string `yaml:"username" env:"OCIS_EVENTS_AUTH_USERNAME;OCM_EVENTS_AUTH_USERNAME" desc:"The username to authenticate with the events broker. The events broker is the ocis service which receives and delivers events between the services." introductionVersion:"5.0"` + AuthPassword string `yaml:"password" env:"OCIS_EVENTS_AUTH_PASSWORD;OCM_EVENTS_AUTH_PASSWORD" desc:"The password to authenticate with the events broker. The events broker is the ocis service which receives and delivers events between the services." introductionVersion:"5.0"` +} diff --git a/services/ocm/pkg/config/defaults/defaultconfig.go b/services/ocm/pkg/config/defaults/defaultconfig.go index 587561fb6..311945edd 100644 --- a/services/ocm/pkg/config/defaults/defaultconfig.go +++ b/services/ocm/pkg/config/defaults/defaultconfig.go @@ -85,6 +85,10 @@ func DefaultConfig() *config.Config { Service: config.Service{ Name: "ocm", }, + Events: config.Events{ + Endpoint: "127.0.0.1:9233", + Cluster: "ocis-cluster", + }, ScienceMesh: config.ScienceMesh{ Prefix: "sciencemesh", }, diff --git a/services/ocm/pkg/revaconfig/config.go b/services/ocm/pkg/revaconfig/config.go index 2d2f69776..f50c17bbc 100644 --- a/services/ocm/pkg/revaconfig/config.go +++ b/services/ocm/pkg/revaconfig/config.go @@ -47,6 +47,14 @@ func OCMConfigFromStruct(cfg *config.Config, logger log.Logger) map[string]inter "gatewaysvc": cfg.Reva.Address, "mesh_directory_url": cfg.ScienceMesh.MeshDirectoryURL, "provider_domain": cfg.Commons.OcisURL, + "events": map[string]interface{}{ + "natsaddress": cfg.Events.Endpoint, + "natsclusterid": cfg.Events.Cluster, + "tlsinsecure": cfg.Events.TLSInsecure, + "tlsrootcacertificate": cfg.Events.TLSRootCACertificate, + "authusername": cfg.Events.AuthUsername, + "authpassword": cfg.Events.AuthPassword, + }, }, "ocmd": map[string]interface{}{ "prefix": cfg.OCMD.Prefix,