- Introduced new functionality for managing email attachments and drafts in the mail API. - Added handlers for listing, uploading, and downloading message attachments in `internal/api/mail/handlers_attachments.go`. - Implemented draft management endpoints for creating, updating, and deleting drafts in `internal/api/mail/handlers_drafts.go`. - Created new service methods for handling draft and attachment operations in `internal/api/mail/drafts.go` and `internal/api/mail/storage.go`. - Added validation and error handling for draft and attachment operations. - Included unit tests for draft and folder functionalities in `internal/api/mail/drafts_test.go` and `internal/api/mail/folders_test.go`. - Updated API routes to support new draft and attachment features, enhancing overall mail management capabilities.
60 lines
4.6 KiB
Go
60 lines
4.6 KiB
Go
package mail
|
|
|
|
import (
|
|
"context"
|
|
"io"
|
|
|
|
"github.com/ultisuite/ulti-backend/internal/api/query"
|
|
)
|
|
|
|
// ServiceAPI is the mail handler service boundary. *Service implements it in production.
|
|
type ServiceAPI interface {
|
|
ResolveUserID(ctx context.Context, externalID string) (string, error)
|
|
ListAccounts(ctx context.Context, externalID string, params query.ListParams) (AccountsList, error)
|
|
CreateAccount(ctx context.Context, externalID string, req *createAccountRequest) (string, error)
|
|
GetAccount(ctx context.Context, externalID, accountID string) (map[string]any, error)
|
|
DeleteAccount(ctx context.Context, externalID, accountID string) error
|
|
ListMessages(ctx context.Context, externalID string, filter MessageListFilter, params query.ListParams) (MessagesList, error)
|
|
GetMessage(ctx context.Context, externalID, messageID string) (map[string]any, error)
|
|
UpdateLabels(ctx context.Context, externalID, messageID string, labels []string) error
|
|
UpdateFlags(ctx context.Context, externalID, messageID string, flags []string) error
|
|
DeleteMessage(ctx context.Context, externalID, messageID string) error
|
|
GetThread(ctx context.Context, externalID, threadID string) (map[string]any, error)
|
|
SendMessage(ctx context.Context, userID string, req *sendMessageRequest) (id, status string, err error)
|
|
ListDrafts(ctx context.Context, externalID string, params query.ListParams) (DraftsList, error)
|
|
GetDraft(ctx context.Context, externalID, draftID string) (map[string]any, error)
|
|
CreateDraft(ctx context.Context, userID string, req *draftRequest) (string, error)
|
|
UpdateDraft(ctx context.Context, externalID, draftID string, req *draftRequest) error
|
|
DeleteDraft(ctx context.Context, externalID, draftID string) error
|
|
ListRules(ctx context.Context, externalID string, params query.ListParams) (RulesList, error)
|
|
CreateRule(ctx context.Context, userID string, req *createRuleRequest) (string, error)
|
|
UpdateRule(ctx context.Context, externalID, ruleID string, req *updateRuleRequest) error
|
|
DeleteRule(ctx context.Context, externalID, ruleID string) error
|
|
ListWebhooks(ctx context.Context, externalID string, params query.ListParams) (WebhooksList, error)
|
|
CreateWebhook(ctx context.Context, externalID string, req *createWebhookRequest, method string) (string, error)
|
|
DeleteWebhook(ctx context.Context, externalID, webhookID string) error
|
|
ListIdentities(ctx context.Context, externalID, accountID string, params query.ListParams) (IdentitiesList, error)
|
|
GetIdentity(ctx context.Context, externalID, identityID string) (map[string]any, error)
|
|
CreateIdentity(ctx context.Context, externalID, accountID string, req *createIdentityRequest) (string, error)
|
|
UpdateIdentity(ctx context.Context, externalID, identityID string, req *updateIdentityRequest) error
|
|
DeleteIdentity(ctx context.Context, externalID, identityID string) error
|
|
ListFolders(ctx context.Context, externalID, accountID string, params query.ListParams) (FoldersList, error)
|
|
GetFolder(ctx context.Context, externalID, folderID string) (map[string]any, error)
|
|
CreateFolder(ctx context.Context, userID string, req *createFolderRequest) (string, error)
|
|
UpdateFolder(ctx context.Context, externalID, folderID string, req *updateFolderRequest) error
|
|
DeleteFolder(ctx context.Context, externalID, folderID string) error
|
|
ListUserLabels(ctx context.Context, externalID string, params query.ListParams) (UserLabelsList, error)
|
|
CreateUserLabel(ctx context.Context, externalID string, req *createUserLabelRequest) (string, error)
|
|
UpdateUserLabel(ctx context.Context, externalID, labelID string, req *updateUserLabelRequest) error
|
|
DeleteUserLabel(ctx context.Context, externalID, labelID string) error
|
|
SearchMessages(ctx context.Context, externalID string, filter MessageSearchFilter, params query.ListParams) (MessageSearchResult, error)
|
|
ListMessageAttachments(ctx context.Context, externalID, messageID string) ([]map[string]any, error)
|
|
MessageAttachmentCIDMap(ctx context.Context, externalID, messageID string) (map[string]string, error)
|
|
UploadMessageAttachment(ctx context.Context, externalID, messageID, filename, contentType, contentID string, isInline bool, reader io.Reader, size int64) (string, error)
|
|
OpenAttachment(ctx context.Context, externalID, attachmentID string) (filename, contentType string, size int64, isInline bool, body io.ReadCloser, err error)
|
|
UploadDraftAttachment(ctx context.Context, externalID, draftID, filename, contentType, contentID string, isInline bool, reader io.Reader, size int64) (string, error)
|
|
OpenDraftAttachment(ctx context.Context, externalID, draftID, attachmentID string) (filename, contentType string, body io.ReadCloser, err error)
|
|
}
|
|
|
|
var _ ServiceAPI = (*Service)(nil)
|