Skip to content

armgit / memos

Public Imported from GitHub
0

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.

888 B
Raw Blame
package api

import (
	"context"
	"log/slog"

	"github.com/usememos/memos/core/notification"
	"github.com/usememos/memos/store"
)

func (s *APIService) createInboxWithEmailNotification(ctx context.Context, inbox *store.Inbox) (*store.Inbox, error) {
	createdInbox, err := s.Store.CreateInbox(ctx, inbox)
	if err != nil {
		return nil, err
	}
	s.dispatchInboxEmailNotificationBestEffort(ctx, createdInbox)
	return createdInbox, nil
}

func (s *APIService) dispatchInboxEmailNotificationBestEffort(ctx context.Context, inbox *store.Inbox) {
	dispatcher := notification.NewEmailDispatcher(s.Profile, s.Store, s.NotificationEmailSender)
	if err := dispatcher.DispatchInboxEmail(ctx, inbox); err != nil {
		slog.Warn("Failed to dispatch inbox email notification",
			slog.Any("err", err),
			slog.Int64("inbox_id", int64(inbox.ID)),
			slog.Int64("receiver_id", int64(inbox.ReceiverID)))
	}
}