enhancement: handle ocm event notifications

This commit is contained in:
Florian Schade
2024-09-05 17:28:27 +02:00
parent 13271fbbd0
commit 194921eb0c
7 changed files with 48 additions and 8 deletions
@@ -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
+4 -2
View File
@@ -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 {
@@ -0,0 +1,9 @@
package service
import (
"github.com/cs3org/reva/v2/pkg/events"
)
func (s eventsNotifier) handleScienceMeshInviteTokenGenerated(e events.ScienceMeshInviteTokenGenerated) {
// fixMe: add implementation
}
@@ -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: