Self-hosted email delivery platform that enables applications to send emails via HTTP APIs while handling SMTP delivery, templates, storage, security, and analytics. Fully self-hostable alternative to services like SendGrid or Mailgun.
Go email-relayemail-routinghttp-to-smtpmail-deliverymailchimp-alternativemailgun-alternativemailsendermailservermailtemplatemailtestpostmark-alternativesend-emailsendgrid-alternativesendmailtransactional-emailtransactional-outbox
feat(rbac): enforce viewer permissions and restrict UI actions in workspaces
Jonas Kanindae850e8c40859
diff --git a/cmd/posta/server.go b/cmd/posta/server.goindex 02d6fbd..7df6f23 100644--- a/cmd/posta/server.go+++ b/cmd/posta/server.go@@ -21,9 +21,6 @@ import ("context""time"- "github.com/hibiken/asynq"- "github.com/jkaninda/logger"- "github.com/jkaninda/okapi/okapicli""github.com/goposta/posta/internal/config"cronpkg "github.com/goposta/posta/internal/cron""github.com/goposta/posta/internal/cron/jobs"@@ -31,14 +28,17 @@ import ("github.com/goposta/posta/internal/routes""github.com/goposta/posta/internal/services/retry""github.com/goposta/posta/internal/services/seeder"- "github.com/goposta/posta/internal/services/tracking""github.com/goposta/posta/internal/services/settings"+ "github.com/goposta/posta/internal/services/tracking""github.com/goposta/posta/internal/services/webhook""github.com/goposta/posta/internal/storage""github.com/goposta/posta/internal/storage/blob""github.com/goposta/posta/internal/storage/migration""github.com/goposta/posta/internal/storage/repositories""github.com/goposta/posta/internal/worker"+ "github.com/hibiken/asynq"+ "github.com/jkaninda/logger"+ "github.com/jkaninda/okapi/okapicli""github.com/redis/go-redis/v9""gorm.io/gorm")@@ -78,15 +78,15 @@ func runServer(cli *okapicli.CLI) {// Initialize blob storage (S3 or filesystem) for attachmentsif cfg.BlobProvider != "" {bs, err := blob.New(blob.Config{- Provider: cfg.BlobProvider,- S3Endpoint: cfg.BlobS3Endpoint,- S3Region: cfg.BlobS3Region,- S3Bucket: cfg.BlobS3Bucket,- S3AccessKeyID: cfg.BlobS3AccessKey,+ Provider: cfg.BlobProvider,+ S3Endpoint: cfg.BlobS3Endpoint,+ S3Region: cfg.BlobS3Region,+ S3Bucket: cfg.BlobS3Bucket,+ S3AccessKeyID: cfg.BlobS3AccessKey,S3SecretAccessKey: cfg.BlobS3SecretKey,- S3UseSSL: cfg.BlobS3UseSSL,- S3ForcePathStyle: cfg.BlobS3PathStyle,- FSBasePath: cfg.BlobFSPath,+ S3UseSSL: cfg.BlobS3UseSSL,+ S3ForcePathStyle: cfg.BlobS3PathStyle,+ FSBasePath: cfg.BlobFSPath,})if err != nil {logger.Fatal("failed to initialize blob storage", "error", err)diff --git a/cmd/posta/worker.go b/cmd/posta/worker.goindex f9f1202..b0e0770 100644--- a/cmd/posta/worker.go+++ b/cmd/posta/worker.go@@ -18,14 +18,14 @@package mainimport (- "github.com/hibiken/asynq"- "github.com/jkaninda/logger""github.com/goposta/posta/internal/config""github.com/goposta/posta/internal/metrics""github.com/goposta/posta/internal/services/tracking""github.com/goposta/posta/internal/storage/blob""github.com/goposta/posta/internal/storage/repositories""github.com/goposta/posta/internal/worker"+ "github.com/hibiken/asynq"+ "github.com/jkaninda/logger")func runWorker() error {diff --git a/internal/config/config.go b/internal/config/config.goindex f7833cd..42c91d6 100644--- a/internal/config/config.go+++ b/internal/config/config.go@@ -21,11 +21,11 @@ import ("fmt""strings"+ errorhandlers "github.com/goposta/posta/internal/error_handlers"+ "github.com/goposta/posta/internal/storage"goutils "github.com/jkaninda/go-utils""github.com/jkaninda/logger""github.com/jkaninda/okapi"- errorhandlers "github.com/goposta/posta/internal/error_handlers"- "github.com/goposta/posta/internal/storage""github.com/joho/godotenv""github.com/redis/go-redis/v9""gorm.io/gorm"@@ -66,15 +66,15 @@ type Config struct {OAuthCallbackBaseURL string// Blob storage settings (S3-compatible or filesystem)- BlobProvider string- BlobS3Endpoint string- BlobS3Region string- BlobS3Bucket string- BlobS3AccessKey string- BlobS3SecretKey string- BlobS3UseSSL bool- BlobS3PathStyle bool- BlobFSPath string+ BlobProvider string+ BlobS3Endpoint string+ BlobS3Region string+ BlobS3Bucket string+ BlobS3AccessKey string+ BlobS3SecretKey string+ BlobS3UseSSL bool+ BlobS3PathStyle bool+ BlobFSPath string}type DatabaseConfig struct {DB *gorm.DB@@ -148,15 +148,15 @@ func New() *Config {GoogleOAuthClientSecret: goutils.Env("POSTA_GOOGLE_OAUTH_CLIENT_SECRET", ""),OAuthCallbackBaseURL: goutils.Env("POSTA_OAUTH_CALLBACK_URL", ""),- BlobProvider: goutils.Env("POSTA_BLOB_PROVIDER", ""),- BlobS3Endpoint: goutils.Env("POSTA_BLOB_S3_ENDPOINT", ""),- BlobS3Region: goutils.Env("POSTA_BLOB_S3_REGION", "us-east-1"),- BlobS3Bucket: goutils.Env("POSTA_BLOB_S3_BUCKET", ""),+ BlobProvider: goutils.Env("POSTA_BLOB_PROVIDER", ""),+ BlobS3Endpoint: goutils.Env("POSTA_BLOB_S3_ENDPOINT", ""),+ BlobS3Region: goutils.Env("POSTA_BLOB_S3_REGION", "us-east-1"),+ BlobS3Bucket: goutils.Env("POSTA_BLOB_S3_BUCKET", ""),BlobS3AccessKey: goutils.Env("POSTA_BLOB_S3_ACCESS_KEY", ""),BlobS3SecretKey: goutils.Env("POSTA_BLOB_S3_SECRET_KEY", ""),- BlobS3UseSSL: goutils.EnvBool("POSTA_BLOB_S3_USE_SSL", true),+ BlobS3UseSSL: goutils.EnvBool("POSTA_BLOB_S3_USE_SSL", true),BlobS3PathStyle: goutils.EnvBool("POSTA_BLOB_S3_PATH_STYLE", false),- BlobFSPath: goutils.Env("POSTA_BLOB_FS_PATH", "data/attachments"),+ BlobFSPath: goutils.Env("POSTA_BLOB_FS_PATH", "data/attachments"),}}func (c *Config) validate() error {diff --git a/internal/cron/jobs/account_cleanup.go b/internal/cron/jobs/account_cleanup.goindex 3ea16a9..33959ba 100644--- a/internal/cron/jobs/account_cleanup.go+++ b/internal/cron/jobs/account_cleanup.go@@ -20,9 +20,9 @@ package jobsimport ("context"+ "github.com/goposta/posta/internal/storage/repositories""github.com/hibiken/asynq""github.com/jkaninda/logger"- "github.com/goposta/posta/internal/storage/repositories")// AccountCleanupJob permanently deletes user accounts whose scheduleddiff --git a/internal/cron/jobs/daily_report.go b/internal/cron/jobs/daily_report.goindex beed144..ef296f6 100644--- a/internal/cron/jobs/daily_report.go+++ b/internal/cron/jobs/daily_report.go@@ -21,10 +21,10 @@ import ("context""encoding/json"- "github.com/hibiken/asynq"- "github.com/jkaninda/logger""github.com/goposta/posta/internal/cron""github.com/goposta/posta/internal/storage/repositories"+ "github.com/hibiken/asynq"+ "github.com/jkaninda/logger")const TypeDailyReport = "cron:daily-report"diff --git a/internal/cron/jobs/retention.go b/internal/cron/jobs/retention.goindex 2fd8600..dbbc8ea 100644--- a/internal/cron/jobs/retention.go+++ b/internal/cron/jobs/retention.go@@ -21,10 +21,10 @@ import ("context""time"- "github.com/hibiken/asynq"- "github.com/jkaninda/logger""github.com/goposta/posta/internal/services/settings""github.com/goposta/posta/internal/storage/repositories"+ "github.com/hibiken/asynq"+ "github.com/jkaninda/logger")// RetentionCleanupJob purges old email logs, audit events, and webhookdiff --git a/internal/error_handlers/errors.go b/internal/error_handlers/errors.goindex 2f4add1..1fe1b57 100644--- a/internal/error_handlers/errors.go+++ b/internal/error_handlers/errors.go@@ -18,8 +18,8 @@package errorhandlersimport (- "github.com/jkaninda/okapi""github.com/goposta/posta/internal/dto"+ "github.com/jkaninda/okapi")// CustomErrorHandler returns an okapi.ErrorHandler that formats errorsdiff --git a/internal/handlers/admin_handler.go b/internal/handlers/admin_handler.goindex 08cf1ef..31bdd88 100644--- a/internal/handlers/admin_handler.go+++ b/internal/handlers/admin_handler.go@@ -22,14 +22,14 @@ import ("os""time"- "github.com/hibiken/asynq"- "github.com/jkaninda/okapi""github.com/goposta/posta/internal/models""github.com/goposta/posta/internal/services/cache""github.com/goposta/posta/internal/services/eventbus""github.com/goposta/posta/internal/services/seeder""github.com/goposta/posta/internal/services/settings""github.com/goposta/posta/internal/storage/repositories"+ "github.com/hibiken/asynq"+ "github.com/jkaninda/okapi""golang.org/x/crypto/bcrypt""gorm.io/gorm")@@ -376,14 +376,14 @@ func (h *AdminHandler) UserMetrics(c *okapi.Context, req *AdminGetUserRequest) e// AdminWorkspace is a workspace with its plan name for admin views.type AdminWorkspace struct {- ID uint `json:"id"`- Name string `json:"name"`- Slug string `json:"slug"`- OwnerID uint `json:"owner_id"`- PlanID *uint `json:"plan_id"`- PlanName string `json:"plan_name"`- CreatedAt time.Time `json:"created_at"`- UpdatedAt time.Time `json:"updated_at"`+ ID uint `json:"id"`+ Name string `json:"name"`+ Slug string `json:"slug"`+ OwnerID uint `json:"owner_id"`+ PlanID *uint `json:"plan_id"`+ PlanName string `json:"plan_name"`+ CreatedAt time.Time `json:"created_at"`+ UpdatedAt time.Time `json:"updated_at"`}// UserWorkspaces returns workspaces for a specific user (admin only).diff --git a/internal/handlers/analytics_handler.go b/internal/handlers/analytics_handler.goindex a6477e5..6ad40a0 100644--- a/internal/handlers/analytics_handler.go+++ b/internal/handlers/analytics_handler.go@@ -20,9 +20,9 @@ package handlersimport ("time"- "github.com/jkaninda/okapi""github.com/goposta/posta/internal/services/cache""github.com/goposta/posta/internal/storage/repositories"+ "github.com/jkaninda/okapi")type AnalyticsHandler struct {diff --git a/internal/handlers/api_key_handler.go b/internal/handlers/api_key_handler.goindex 01eff1a..3934f9b 100644--- a/internal/handlers/api_key_handler.go+++ b/internal/handlers/api_key_handler.go@@ -20,10 +20,10 @@ package handlersimport ("time"- "github.com/jkaninda/okapi""github.com/goposta/posta/internal/services/audit""github.com/goposta/posta/internal/services/auth""github.com/goposta/posta/internal/storage/repositories"+ "github.com/jkaninda/okapi""gorm.io/gorm")@@ -66,13 +66,13 @@ func (h *APIKeyHandler) SetQuota(q QuotaChecker, db *gorm.DB) {func (h *APIKeyHandler) Create(c *okapi.Context, req *CreateAPIKeyRequest) error {if err := requireEdit(c); err != nil {- return err+ return c.AbortForbidden("Insufficient workspace permissions", err)}scope := getScope(c)if h.quota != nil {if err := h.quota.CheckQuota(h.db, scope.WorkspaceID, "api_keys"); err != nil {- return c.AbortForbidden(err.Error())+ return c.AbortForbidden("API key quota exceeded for this workspace", err)}}@@ -124,7 +124,7 @@ func (h *APIKeyHandler) List(c *okapi.Context, req *ListRequest) error {func (h *APIKeyHandler) Revoke(c *okapi.Context, req *RevokeAPIKeyRequest) error {if err := requireEdit(c); err != nil {- return err+ return c.AbortForbidden("Insufficient workspace permissions", err)}key, err := h.repo.FindByID(uint(req.ID))if err != nil || !ownsResource(c, key.UserID, key.WorkspaceID) {@@ -142,7 +142,7 @@ func (h *APIKeyHandler) Revoke(c *okapi.Context, req *RevokeAPIKeyRequest) errorfunc (h *APIKeyHandler) Delete(c *okapi.Context, req *DeleteAPIKeyRequest) error {if err := requireEdit(c); err != nil {- return err+ return c.AbortForbidden("Insufficient workspace permissions", err)}key, err := h.repo.FindByID(uint(req.ID))if err != nil || !ownsResource(c, key.UserID, key.WorkspaceID) {diff --git a/internal/handlers/bounce_handler.go b/internal/handlers/bounce_handler.goindex 17d309f..4517c38 100644--- a/internal/handlers/bounce_handler.go+++ b/internal/handlers/bounce_handler.go@@ -18,10 +18,16 @@package handlersimport (- "github.com/jkaninda/okapi""github.com/goposta/posta/internal/metrics""github.com/goposta/posta/internal/models""github.com/goposta/posta/internal/storage/repositories"+ "github.com/jkaninda/okapi"+)++const (+ bounceTypeHard = "hard"+ bounceTypeSoft = "soft"+ bounceTypeComplaint = "complaint")type BounceHandler struct {@@ -44,11 +50,11 @@ func NewBounceHandler(bounceRepo *repositories.BounceRepository, suppressionRepofunc (h *BounceHandler) Record(c *okapi.Context, req *RecordBounceRequest) error {if err := requireEdit(c); err != nil {- return err+ return c.AbortForbidden("insufficient workspace permissions", err)}scope := getScope(c)- validTypes := map[string]bool{"hard": true, "soft": true, "complaint": true}+ validTypes := map[string]bool{bounceTypeHard: true, bounceTypeSoft: true, bounceTypeComplaint: true}if !validTypes[req.Body.Type] {return c.AbortBadRequest("invalid bounce type. Valid types: hard, soft, complaint")}@@ -61,10 +67,10 @@ func (h *BounceHandler) Record(c *okapi.Context, req *RecordBounceRequest) errorbounce := &models.Bounce{UserID: scope.UserID,WorkspaceID: scope.WorkspaceID,- EmailID: em.ID,- Recipient: req.Body.Recipient,- Type: models.BounceType(req.Body.Type),- Reason: req.Body.Reason,+ EmailID: em.ID,+ Recipient: req.Body.Recipient,+ Type: models.BounceType(req.Body.Type),+ Reason: req.Body.Reason,}if err := h.bounceRepo.Create(bounce); err != nil {@@ -74,7 +80,7 @@ func (h *BounceHandler) Record(c *okapi.Context, req *RecordBounceRequest) errormetrics.IncrementBounce(req.Body.Type)// Auto-suppress on hard bounce or complaint- if req.Body.Type == "hard" || req.Body.Type == "complaint" {+ if req.Body.Type == bounceTypeHard || req.Body.Type == bounceTypeComplaint {suppression := &models.Suppression{UserID: scope.UserID,WorkspaceID: scope.WorkspaceID,diff --git a/internal/handlers/bounce_webhook_handler.go b/internal/handlers/bounce_webhook_handler.goindex 45b5dd1..7f53d3d 100644--- a/internal/handlers/bounce_webhook_handler.go+++ b/internal/handlers/bounce_webhook_handler.go@@ -21,10 +21,10 @@ import ("strings""time"- "github.com/jkaninda/logger"- "github.com/jkaninda/okapi""github.com/goposta/posta/internal/models""github.com/goposta/posta/internal/storage/repositories"+ "github.com/jkaninda/logger"+ "github.com/jkaninda/okapi")// BounceWebhookHandler processes inbound bounce notifications.diff --git a/internal/handlers/campaign_handler.go b/internal/handlers/campaign_handler.goindex 80d91fe..53ff269 100644--- a/internal/handlers/campaign_handler.go+++ b/internal/handlers/campaign_handler.go@@ -20,19 +20,19 @@ package handlersimport ("time"- "github.com/jkaninda/okapi""github.com/goposta/posta/internal/models""github.com/goposta/posta/internal/storage/repositories""github.com/goposta/posta/internal/worker"+ "github.com/jkaninda/okapi")type CampaignHandler struct {- campaignRepo *repositories.CampaignRepository- messageRepo *repositories.CampaignMessageRepository- listRepo *repositories.SubscriberListRepository- subscriberRepo *repositories.SubscriberRepository- templateRepo *repositories.TemplateRepository- producer *worker.Producer+ campaignRepo *repositories.CampaignRepository+ messageRepo *repositories.CampaignMessageRepository+ listRepo *repositories.SubscriberListRepository+ subscriberRepo *repositories.SubscriberRepository+ templateRepo *repositories.TemplateRepository+ producer *worker.Producer}func NewCampaignHandler(@@ -53,7 +53,6 @@ func NewCampaignHandler(}}-type CreateCampaignRequest struct {Body struct {Name string `json:"name" required:"true"`@@ -68,7 +67,7 @@ type CreateCampaignRequest struct {SendRate int `json:"send_rate"`SendAtLocalTime bool `json:"send_at_local_time"`ABTestEnabled bool `json:"ab_test_enabled"`- ABTestVariants []models.ABTestVariant `json:"ab_test_variants"`+ ABTestVariants []models.ABTestVariant `json:"ab_test_variants"`ScheduledAt *time.Time `json:"scheduled_at"`} `json:"body"`}@@ -88,7 +87,7 @@ type UpdateCampaignRequest struct {SendRate *int `json:"send_rate"`SendAtLocalTime *bool `json:"send_at_local_time"`ABTestEnabled *bool `json:"ab_test_enabled"`- ABTestVariants []models.ABTestVariant `json:"ab_test_variants"`+ ABTestVariants []models.ABTestVariant `json:"ab_test_variants"`ScheduledAt *time.Time `json:"scheduled_at"`} `json:"body"`}@@ -110,7 +109,6 @@ type ListCampaignMessagesRequest struct {Status string `query:"status"`}-type CampaignStats struct {Total int64 `json:"total"`Pending int64 `json:"pending"`@@ -125,10 +123,9 @@ type CampaignWithStats struct {Stats *CampaignStats `json:"stats,omitempty"`}-func (h *CampaignHandler) Create(c *okapi.Context, req *CreateCampaignRequest) error {if err := requireEdit(c); err != nil {- return err+ return c.AbortForbidden("insufficient workspace permissions", err)}scope := getScope(c)@@ -209,7 +206,7 @@ func (h *CampaignHandler) Get(c *okapi.Context, req *CampaignActionRequest) errofunc (h *CampaignHandler) Update(c *okapi.Context, req *UpdateCampaignRequest) error {if err := requireEdit(c); err != nil {- return err+ return c.AbortForbidden("insufficient workspace permissions", err)}campaign, err := h.campaignRepo.FindByID(uint(req.ID))if err != nil || !ownsResource(c, campaign.UserID, campaign.WorkspaceID) {@@ -272,7 +269,7 @@ func (h *CampaignHandler) Update(c *okapi.Context, req *UpdateCampaignRequest) efunc (h *CampaignHandler) Delete(c *okapi.Context, req *CampaignActionRequest) error {if err := requireEdit(c); err != nil {- return err+ return c.AbortForbidden("insufficient workspace permissions", err)}campaign, err := h.campaignRepo.FindByID(uint(req.ID))if err != nil || !ownsResource(c, campaign.UserID, campaign.WorkspaceID) {@@ -289,7 +286,7 @@ func (h *CampaignHandler) Delete(c *okapi.Context, req *CampaignActionRequest) efunc (h *CampaignHandler) Send(c *okapi.Context, req *CampaignActionRequest) error {if err := requireEdit(c); err != nil {- return err+ return c.AbortForbidden("insufficient workspace permissions", err)}campaign, err := h.campaignRepo.FindByID(uint(req.ID))if err != nil || !ownsResource(c, campaign.UserID, campaign.WorkspaceID) {@@ -321,7 +318,7 @@ func (h *CampaignHandler) Send(c *okapi.Context, req *CampaignActionRequest) errfunc (h *CampaignHandler) Pause(c *okapi.Context, req *CampaignActionRequest) error {if err := requireEdit(c); err != nil {- return err+ return c.AbortForbidden("insufficient workspace permissions", err)}campaign, err := h.campaignRepo.FindByID(uint(req.ID))if err != nil || !ownsResource(c, campaign.UserID, campaign.WorkspaceID) {@@ -339,7 +336,7 @@ func (h *CampaignHandler) Pause(c *okapi.Context, req *CampaignActionRequest) erfunc (h *CampaignHandler) Resume(c *okapi.Context, req *CampaignActionRequest) error {if err := requireEdit(c); err != nil {- return err+ return c.AbortForbidden("insufficient workspace permissions", err)}campaign, err := h.campaignRepo.FindByID(uint(req.ID))if err != nil || !ownsResource(c, campaign.UserID, campaign.WorkspaceID) {@@ -360,7 +357,7 @@ func (h *CampaignHandler) Resume(c *okapi.Context, req *CampaignActionRequest) efunc (h *CampaignHandler) Cancel(c *okapi.Context, req *CampaignActionRequest) error {if err := requireEdit(c); err != nil {- return err+ return c.AbortForbidden("insufficient workspace permissions", err)}campaign, err := h.campaignRepo.FindByID(uint(req.ID))if err != nil || !ownsResource(c, campaign.UserID, campaign.WorkspaceID) {@@ -380,7 +377,7 @@ func (h *CampaignHandler) Cancel(c *okapi.Context, req *CampaignActionRequest) efunc (h *CampaignHandler) Duplicate(c *okapi.Context, req *CampaignActionRequest) error {if err := requireEdit(c); err != nil {- return err+ return c.AbortForbidden("insufficient workspace permissions", err)}campaign, err := h.campaignRepo.FindByID(uint(req.ID))if err != nil || !ownsResource(c, campaign.UserID, campaign.WorkspaceID) {diff --git a/internal/handlers/contact_handler.go b/internal/handlers/contact_handler.goindex 5eef222..c1efd79 100644--- a/internal/handlers/contact_handler.go+++ b/internal/handlers/contact_handler.go@@ -18,9 +18,9 @@package handlersimport (- "github.com/jkaninda/okapi""github.com/goposta/posta/internal/models""github.com/goposta/posta/internal/storage/repositories"+ "github.com/jkaninda/okapi")type ContactHandler struct {diff --git a/internal/handlers/contact_list_handler.go b/internal/handlers/contact_list_handler.goindex 8f70199..b8e29ed 100644--- a/internal/handlers/contact_list_handler.go+++ b/internal/handlers/contact_list_handler.go@@ -18,9 +18,9 @@package handlersimport (- "github.com/jkaninda/okapi""github.com/goposta/posta/internal/models""github.com/goposta/posta/internal/storage/repositories"+ "github.com/jkaninda/okapi")type ContactListHandler struct {@@ -74,7 +74,7 @@ type ContactListWithCount struct {func (h *ContactListHandler) Create(c *okapi.Context, req *CreateContactListRequest) error {if err := requireEdit(c); err != nil {- return err+ return c.AbortForbidden("insufficient workspace permissions", err)}scope := getScope(c)list := &models.ContactList{@@ -110,7 +110,7 @@ func (h *ContactListHandler) List(c *okapi.Context, req *ListRequest) error {func (h *ContactListHandler) Update(c *okapi.Context, req *UpdateContactListRequest) error {if err := requireEdit(c); err != nil {- return err+ return c.AbortForbidden("insufficient workspace permissions", err)}list, err := h.repo.FindByID(uint(req.ID))if err != nil || !ownsResource(c, list.UserID, list.WorkspaceID) {@@ -126,7 +126,7 @@ func (h *ContactListHandler) Update(c *okapi.Context, req *UpdateContactListRequfunc (h *ContactListHandler) Delete(c *okapi.Context, req *GetByIDRequest) error {if err := requireEdit(c); err != nil {- return err+ return c.AbortForbidden("insufficient workspace permissions", err)}list, err := h.repo.FindByID(uint(req.ID))if err != nil || !ownsResource(c, list.UserID, list.WorkspaceID) {@@ -140,7 +140,7 @@ func (h *ContactListHandler) Delete(c *okapi.Context, req *GetByIDRequest) errorfunc (h *ContactListHandler) AddMember(c *okapi.Context, req *AddMemberRequest) error {if err := requireEdit(c); err != nil {- return err+ return c.AbortForbidden("insufficient workspace permissions", err)}list, err := h.repo.FindByID(uint(req.ID))if err != nil || !ownsResource(c, list.UserID, list.WorkspaceID) {@@ -159,7 +159,7 @@ func (h *ContactListHandler) AddMember(c *okapi.Context, req *AddMemberRequest)func (h *ContactListHandler) RemoveMember(c *okapi.Context, req *RemoveMemberRequest) error {if err := requireEdit(c); err != nil {- return err+ return c.AbortForbidden("insufficient workspace permissions", err)}list, err := h.repo.FindByID(uint(req.ID))if err != nil || !ownsResource(c, list.UserID, list.WorkspaceID) {diff --git a/internal/handlers/cron_handler.go b/internal/handlers/cron_handler.goindex 08d8481..080c78b 100644--- a/internal/handlers/cron_handler.go+++ b/internal/handlers/cron_handler.go@@ -18,8 +18,8 @@package handlersimport (- "github.com/jkaninda/okapi""github.com/goposta/posta/internal/cron"+ "github.com/jkaninda/okapi")// CronHandler exposes cron job status to admin users.diff --git a/internal/handlers/dashboard_handler.go b/internal/handlers/dashboard_handler.goindex 1ed0ff8..31c941a 100644--- a/internal/handlers/dashboard_handler.go+++ b/internal/handlers/dashboard_handler.go@@ -20,10 +20,10 @@ package handlersimport ("time"- "github.com/jkaninda/okapi""github.com/goposta/posta/internal/models""github.com/goposta/posta/internal/services/cache""github.com/goposta/posta/internal/storage/repositories"+ "github.com/jkaninda/okapi""gorm.io/gorm")diff --git a/internal/handlers/data_export.go b/internal/handlers/data_export.goindex f96231d..e4463fe 100644--- a/internal/handlers/data_export.go+++ b/internal/handlers/data_export.go@@ -26,7 +26,6 @@ import (// exportLimit is the maximum number of records to export per resource type.const exportLimit = 10000-type ExportStyleSheet struct {Name string `json:"name"`CSS string `json:"css"`@@ -45,8 +44,8 @@ type ExportContact struct {}type ExportContactList struct {- Name string `json:"name"`- Description string `json:"description"`+ Name string `json:"name"`+ Description string `json:"description"`Members []ExportContactListMember `json:"members"`}@@ -114,7 +113,6 @@ type ExportWorkspaceSettings struct {DefaultLanguage string `json:"default_language"`}-func exportTemplates(templates []models.Template,versionRepo *repositories.TemplateVersionRepository,@@ -270,7 +268,6 @@ func exportSubscriberLists(lists []models.SubscriberList) []ExportSubscriberListreturn result}-func importTemplates(data []TemplateExport,userID uint,@@ -471,7 +468,7 @@ func importSMTPServers(data []ExportSMTPServer, userID uint, workspaceID *uint,Host: s.Host, Port: s.Port, Username: s.Username,Encryption: s.Encryption, MaxRetries: s.MaxRetries,AllowedEmails: s.AllowedEmails,- Status: models.SMTPStatusDisabled,+ Status: models.SMTPStatusDisabled,}).Error; err != nil {continue}diff --git a/internal/handlers/domain_handler.go b/internal/handlers/domain_handler.goindex e8c4519..f871e93 100644--- a/internal/handlers/domain_handler.go+++ b/internal/handlers/domain_handler.go@@ -21,10 +21,10 @@ import ("crypto/rand""encoding/hex"- "github.com/jkaninda/okapi""github.com/goposta/posta/internal/models""github.com/goposta/posta/internal/services/domain""github.com/goposta/posta/internal/storage/repositories"+ "github.com/jkaninda/okapi""gorm.io/gorm")@@ -64,13 +64,13 @@ func (h *DomainHandler) SetQuota(q QuotaChecker, db *gorm.DB) {func (h *DomainHandler) Create(c *okapi.Context, req *CreateDomainRequest) error {if err := requireEdit(c); err != nil {- return err+ return c.AbortForbidden("insufficient workspace permissions", err)}scope := getScope(c)if h.quota != nil {if err := h.quota.CheckQuota(h.db, scope.WorkspaceID, "domains"); err != nil {- return c.AbortForbidden(err.Error())+ return c.AbortForbidden("Domain quota exceeded for this workspace", err)}}@@ -121,7 +121,7 @@ func (h *DomainHandler) Get(c *okapi.Context, req *GetDomainRequest) error {func (h *DomainHandler) Delete(c *okapi.Context, req *DeleteDomainRequest) error {if err := requireEdit(c); err != nil {- return err+ return c.AbortForbidden("insufficient workspace permissions", err)}d, err := h.repo.FindByID(uint(req.ID))if err != nil || !ownsResource(c, d.UserID, d.WorkspaceID) {@@ -137,7 +137,7 @@ func (h *DomainHandler) Delete(c *okapi.Context, req *DeleteDomainRequest) errorfunc (h *DomainHandler) Verify(c *okapi.Context, req *VerifyDomainRequest) error {if err := requireEdit(c); err != nil {- return err+ return c.AbortForbidden("insufficient workspace permissions", err)}d, err := h.repo.FindByID(uint(req.ID))if err != nil || !ownsResource(c, d.UserID, d.WorkspaceID) {diff --git a/internal/handlers/email_handler.go b/internal/handlers/email_handler.goindex 641e4f0..b22df99 100644--- a/internal/handlers/email_handler.go+++ b/internal/handlers/email_handler.go@@ -21,13 +21,13 @@ import ("fmt""strings"- "github.com/jkaninda/okapi""github.com/goposta/posta/internal/models""github.com/goposta/posta/internal/services/cache""github.com/goposta/posta/internal/services/email""github.com/goposta/posta/internal/services/eventbus""github.com/goposta/posta/internal/services/settings""github.com/goposta/posta/internal/storage/repositories"+ "github.com/jkaninda/okapi")type EmailHandler struct {@@ -124,7 +124,7 @@ func redactEmails(emails []models.Email) {func (h *EmailHandler) Send(c *okapi.Context, req *SendEmailRequest) error {if err := requireEdit(c); err != nil {- return err+ return c.AbortForbidden("insufficient workspace permissions", err)}userID := c.GetInt("user_id")userEmail := c.GetString("user_email")@@ -141,7 +141,7 @@ func (h *EmailHandler) Send(c *okapi.Context, req *SendEmailRequest) error {return c.AbortTooManyRequests(err.Error())}if isDomainVerificationError(err) {- return c.AbortForbidden(err.Error())+ return c.AbortForbidden("insufficient workspace permissions", err)}return c.AbortInternalServerError(err.Error())}@@ -166,7 +166,7 @@ func (h *EmailHandler) handleDryRun(c *okapi.Context, userID int, workspaceID *ureturn c.AbortTooManyRequests(err.Error())}if isDomainVerificationError(err) {- return c.AbortForbidden(err.Error())+ return c.AbortForbidden("insufficient workspace permissions", err)}return c.AbortBadRequest(err.Error())}@@ -175,7 +175,7 @@ func (h *EmailHandler) handleDryRun(c *okapi.Context, userID int, workspaceID *ufunc (h *EmailHandler) SendWithTemplate(c *okapi.Context, req *SendTemplateEmailRequest) error {if err := requireEdit(c); err != nil {- return err+ return c.AbortForbidden("insufficient workspace permissions", err)}userID := c.GetInt("user_id")userEmail := c.GetString("user_email")@@ -188,7 +188,7 @@ func (h *EmailHandler) SendWithTemplate(c *okapi.Context, req *SendTemplateEmailreturn c.AbortTooManyRequests(err.Error())}if isDomainVerificationError(err) {- return c.AbortForbidden(err.Error())+ return c.AbortForbidden("insufficient workspace permissions", err)}return c.AbortBadRequest(err.Error())}@@ -202,7 +202,7 @@ func (h *EmailHandler) SendWithTemplate(c *okapi.Context, req *SendTemplateEmailreturn c.AbortTooManyRequests(err.Error())}if isDomainVerificationError(err) {- return c.AbortForbidden(err.Error())+ return c.AbortForbidden("insufficient workspace permissions", err)}return c.AbortInternalServerError(err.Error())}@@ -221,7 +221,7 @@ func (h *EmailHandler) SendWithTemplate(c *okapi.Context, req *SendTemplateEmailfunc (h *EmailHandler) SendBatch(c *okapi.Context, req *SendBatchEmailRequest) error {if err := requireEdit(c); err != nil {- return err+ return c.AbortForbidden("insufficient workspace permissions", err)}userID := c.GetInt("user_id")userEmail := c.GetString("user_email")@@ -245,7 +245,7 @@ func (h *EmailHandler) SendBatch(c *okapi.Context, req *SendBatchEmailRequest) ereturn c.AbortTooManyRequests(err.Error())}if isDomainVerificationError(err) {- return c.AbortForbidden(err.Error())+ return c.AbortForbidden("insufficient workspace permissions", err)}return c.AbortInternalServerError(err.Error())}diff --git a/internal/handlers/event_handler.go b/internal/handlers/event_handler.goindex fdb5c08..10cde81 100644--- a/internal/handlers/event_handler.go+++ b/internal/handlers/event_handler.go@@ -20,10 +20,10 @@ package handlersimport ("time"- "github.com/jkaninda/okapi""github.com/goposta/posta/internal/models""github.com/goposta/posta/internal/services/eventbus""github.com/goposta/posta/internal/storage/repositories"+ "github.com/jkaninda/okapi")type EventHandler struct {diff --git a/internal/handlers/helper.go b/internal/handlers/helper.goindex ed5b164..d9104ac 100644--- a/internal/handlers/helper.go+++ b/internal/handlers/helper.go@@ -18,15 +18,18 @@package handlersimport (+ "errors""net/http"- "github.com/jkaninda/okapi""github.com/goposta/posta/internal/dto""github.com/goposta/posta/internal/models""github.com/goposta/posta/internal/storage/repositories"+ "github.com/jkaninda/okapi""gorm.io/gorm")+var errForbidden = errors.New("insufficient workspace permissions: editor role or higher required")+// QuotaChecker verifies that creating a resource would not exceed plan limits.type QuotaChecker interface {CheckQuota(db *gorm.DB, workspaceID *uint, resource string) error@@ -86,11 +89,10 @@ func canEditInWorkspace(c *okapi.Context) bool {return role.CanEdit()}-// requireEdit checks workspace edit permission and aborts with 403 if denied.-// Returns true if the request should be aborted (caller should return).+// requireEdit returns errForbidden when the user lacks editor+ permission.func requireEdit(c *okapi.Context) error {if !canEditInWorkspace(c) {- return c.AbortForbidden("insufficient workspace permissions: editor role or higher required")+ return errForbidden}return nil}diff --git a/internal/handlers/info_handler.go b/internal/handlers/info_handler.goindex 4b31b12..5eb3605 100644--- a/internal/handlers/info_handler.go+++ b/internal/handlers/info_handler.go@@ -18,8 +18,8 @@package handlersimport (- "github.com/jkaninda/okapi""github.com/goposta/posta/internal/config"+ "github.com/jkaninda/okapi")type AppInfo struct {diff --git a/internal/handlers/language_handler.go b/internal/handlers/language_handler.goindex 478f7b2..3613690 100644--- a/internal/handlers/language_handler.go+++ b/internal/handlers/language_handler.go@@ -18,9 +18,9 @@package handlersimport (- "github.com/jkaninda/okapi""github.com/goposta/posta/internal/models""github.com/goposta/posta/internal/storage/repositories"+ "github.com/jkaninda/okapi")type LanguageHandler struct {@@ -51,7 +51,7 @@ func NewLanguageHandler(repo *repositories.LanguageRepository) *LanguageHandlerfunc (h *LanguageHandler) Create(c *okapi.Context, req *CreateLanguageRequest) error {if err := requireEdit(c); err != nil {- return err+ return c.AbortForbidden("insufficient workspace permissions", err)}scope := getScope(c)@@ -77,7 +77,7 @@ func (h *LanguageHandler) Create(c *okapi.Context, req *CreateLanguageRequest) efunc (h *LanguageHandler) Update(c *okapi.Context, req *UpdateLanguageRequest) error {if err := requireEdit(c); err != nil {- return err+ return c.AbortForbidden("insufficient workspace permissions", err)}l, err := h.repo.FindByID(uint(req.ID))if err != nil || !ownsResource(c, l.UserID, l.WorkspaceID) {@@ -110,7 +110,7 @@ func (h *LanguageHandler) Update(c *okapi.Context, req *UpdateLanguageRequest) efunc (h *LanguageHandler) Delete(c *okapi.Context, req *DeleteLanguageRequest) error {if err := requireEdit(c); err != nil {- return err+ return c.AbortForbidden("insufficient workspace permissions", err)}l, err := h.repo.FindByID(uint(req.ID))if err != nil || !ownsResource(c, l.UserID, l.WorkspaceID) {diff --git a/internal/handlers/oauth_admin_handler.go b/internal/handlers/oauth_admin_handler.goindex 8f202bb..ca69410 100644--- a/internal/handlers/oauth_admin_handler.go+++ b/internal/handlers/oauth_admin_handler.go@@ -4,9 +4,9 @@ import ("strings""time"- "github.com/jkaninda/okapi""github.com/goposta/posta/internal/models""github.com/goposta/posta/internal/storage/repositories"+ "github.com/jkaninda/okapi")type OAuthAdminHandler struct {@@ -18,7 +18,6 @@ func NewOAuthAdminHandler(providerRepo *repositories.OAuthProviderRepository, ssreturn &OAuthAdminHandler{providerRepo: providerRepo, ssoRepo: ssoRepo}}-type CreateOAuthProviderRequest struct {Body struct {Name string `json:"name" required:"true"`@@ -87,7 +86,6 @@ type WorkspaceSSOResponse struct {AllowedDomains string `json:"allowed_domains"`}-func (h *OAuthAdminHandler) CreateProvider(c *okapi.Context, req *CreateOAuthProviderRequest) error {slug := strings.ToLower(strings.TrimSpace(req.Body.Slug))providerType := models.OAuthProviderType(req.Body.Type)@@ -192,7 +190,6 @@ func (h *OAuthAdminHandler) DeleteProvider(c *okapi.Context, req *DeleteOAuthProreturn noContent(c)}-func (h *OAuthAdminHandler) GetWorkspaceSSO(c *okapi.Context) error {wsID := c.GetInt("workspace_id")if wsID == 0 {diff --git a/internal/handlers/oauth_handler.go b/internal/handlers/oauth_handler.goindex 3d373d2..d87bdce 100644--- a/internal/handlers/oauth_handler.go+++ b/internal/handlers/oauth_handler.go@@ -9,13 +9,13 @@ import ("time""github.com/google/uuid"- "github.com/jkaninda/logger"- "github.com/jkaninda/okapi""github.com/goposta/posta/internal/models""github.com/goposta/posta/internal/services/auth""github.com/goposta/posta/internal/services/eventbus""github.com/goposta/posta/internal/services/seeder""github.com/goposta/posta/internal/storage/repositories"+ "github.com/jkaninda/logger"+ "github.com/jkaninda/okapi""github.com/redis/go-redis/v9")@@ -61,7 +61,6 @@ func NewOAuthHandler(}}-type OAuthProviderInfo struct {Slug string `json:"slug"`Name string `json:"name"`diff --git a/internal/handlers/plan_handler.go b/internal/handlers/plan_handler.goindex f106ad9..65a8a34 100644--- a/internal/handlers/plan_handler.go+++ b/internal/handlers/plan_handler.go@@ -21,12 +21,12 @@ import ("fmt""net/http"- "github.com/jkaninda/okapi""github.com/goposta/posta/internal/dto""github.com/goposta/posta/internal/models""github.com/goposta/posta/internal/services/audit"planpkg "github.com/goposta/posta/internal/services/plan""github.com/goposta/posta/internal/storage/repositories"+ "github.com/jkaninda/okapi""gorm.io/gorm")diff --git a/internal/handlers/server_handler.go b/internal/handlers/server_handler.goindex d0d4801..b9579f5 100644--- a/internal/handlers/server_handler.go+++ b/internal/handlers/server_handler.go@@ -21,12 +21,12 @@ import ("net/http""time"- "github.com/jkaninda/okapi""github.com/goposta/posta/internal/dto""github.com/goposta/posta/internal/models""github.com/goposta/posta/internal/services/audit""github.com/goposta/posta/internal/services/email""github.com/goposta/posta/internal/storage/repositories"+ "github.com/jkaninda/okapi")// ServerHandler handles admin management of shared SMTP servers.@@ -40,7 +40,6 @@ func NewServerHandler(repo *repositories.ServerRepository, audit *audit.Logger)return &ServerHandler{repo: repo, sender: email.NewSMTPSender(), audit: audit}}-type CreateServerRequest struct {Body struct {Name string `json:"name" required:"true"`diff --git a/internal/handlers/session_handler.go b/internal/handlers/session_handler.goindex 4850a5b..3186cb6 100644--- a/internal/handlers/session_handler.go+++ b/internal/handlers/session_handler.go@@ -20,9 +20,9 @@ package handlersimport ("fmt"- "github.com/jkaninda/okapi""github.com/goposta/posta/internal/services/session""github.com/goposta/posta/internal/storage/repositories"+ "github.com/jkaninda/okapi")type SessionHandler struct {diff --git a/internal/handlers/setting_handler.go b/internal/handlers/setting_handler.goindex 1512f4e..d7f8944 100644--- a/internal/handlers/setting_handler.go+++ b/internal/handlers/setting_handler.go@@ -18,10 +18,10 @@package handlersimport (- "github.com/jkaninda/okapi""github.com/goposta/posta/internal/models""github.com/goposta/posta/internal/services/audit""github.com/goposta/posta/internal/storage/repositories"+ "github.com/jkaninda/okapi")// SettingHandler handles admin management of platform settings.@@ -34,7 +34,6 @@ func NewSettingHandler(repo *repositories.SettingRepository, audit *audit.Loggerreturn &SettingHandler{repo: repo, audit: audit}}-type UpdateSettingsRequest struct {Body struct {Settings []SettingInput `json:"settings" required:"true"`diff --git a/internal/handlers/smtp_handler.go b/internal/handlers/smtp_handler.goindex 8bd3b57..da8b4c5 100644--- a/internal/handlers/smtp_handler.go+++ b/internal/handlers/smtp_handler.go@@ -22,11 +22,11 @@ import ("strings""time"- "github.com/jkaninda/okapi""github.com/goposta/posta/internal/models""github.com/goposta/posta/internal/services/audit""github.com/goposta/posta/internal/services/email""github.com/goposta/posta/internal/storage/repositories"+ "github.com/jkaninda/okapi""gorm.io/gorm")@@ -119,13 +119,13 @@ func (h *SMTPHandler) SetQuota(q QuotaChecker, db *gorm.DB) {func (h *SMTPHandler) Create(c *okapi.Context, req *CreateSMTPRequest) error {if err := requireEdit(c); err != nil {- return err+ return c.AbortForbidden("Insufficient workspace permissions", err)}scope := getScope(c)if h.quota != nil {if err := h.quota.CheckQuota(h.db, scope.WorkspaceID, "smtp_servers"); err != nil {- return c.AbortForbidden(err.Error())+ return c.AbortForbidden("SMTP server quota exceeded for this workspace", err)}}@@ -181,7 +181,7 @@ func (h *SMTPHandler) Get(c *okapi.Context, req *GetSMTPRequest) error {func (h *SMTPHandler) Update(c *okapi.Context, req *UpdateSMTPRequest) error {if err := requireEdit(c); err != nil {- return err+ return c.AbortForbidden("Insufficient workspace permissions", err)}server, err := h.repo.FindByID(uint(req.ID))if err != nil || !ownsResource(c, server.UserID, server.WorkspaceID) {@@ -274,7 +274,7 @@ func (h *SMTPHandler) List(c *okapi.Context, req *ListRequest) error {func (h *SMTPHandler) Delete(c *okapi.Context, req *DeleteSMTPRequest) error {if err := requireEdit(c); err != nil {- return err+ return c.AbortForbidden("Insufficient workspace permissions", err)}server, err := h.repo.FindByID(uint(req.ID))if err != nil || !ownsResource(c, server.UserID, server.WorkspaceID) {@@ -292,7 +292,7 @@ func (h *SMTPHandler) Delete(c *okapi.Context, req *DeleteSMTPRequest) error {func (h *SMTPHandler) Test(c *okapi.Context, req *TestSMTPRequest) error {if err := requireEdit(c); err != nil {- return err+ return c.AbortForbidden("Insufficient workspace permissions", err)}server, err := h.repo.FindByID(uint(req.ID))if err != nil || !ownsResource(c, server.UserID, server.WorkspaceID) {diff --git a/internal/handlers/stylesheet_handler.go b/internal/handlers/stylesheet_handler.goindex 719a45d..a238fd1 100644--- a/internal/handlers/stylesheet_handler.go+++ b/internal/handlers/stylesheet_handler.go@@ -20,9 +20,9 @@ package handlersimport ("time"- "github.com/jkaninda/okapi""github.com/goposta/posta/internal/models""github.com/goposta/posta/internal/storage/repositories"+ "github.com/jkaninda/okapi")type StyleSheetHandler struct {@@ -51,7 +51,7 @@ func NewStyleSheetHandler(repo *repositories.StyleSheetRepository) *StyleSheetHafunc (h *StyleSheetHandler) Create(c *okapi.Context, req *CreateStyleSheetRequest) error {if err := requireEdit(c); err != nil {- return err+ return c.AbortForbidden("Insufficient workspace permissions", err)}scope := getScope(c)@@ -59,7 +59,7 @@ func (h *StyleSheetHandler) Create(c *okapi.Context, req *CreateStyleSheetRequesUserID: scope.UserID,WorkspaceID: scope.WorkspaceID,Name: req.Body.Name,- CSS: req.Body.CSS,+ CSS: req.Body.CSS,}if err := h.repo.Create(ss); err != nil {@@ -71,7 +71,7 @@ func (h *StyleSheetHandler) Create(c *okapi.Context, req *CreateStyleSheetRequesfunc (h *StyleSheetHandler) Update(c *okapi.Context, req *UpdateStyleSheetRequest) error {if err := requireEdit(c); err != nil {- return err+ return c.AbortForbidden("Insufficient workspace permissions", err)}ss, err := h.repo.FindByID(uint(req.ID))if err != nil || !ownsResource(c, ss.UserID, ss.WorkspaceID) {@@ -97,7 +97,7 @@ func (h *StyleSheetHandler) Update(c *okapi.Context, req *UpdateStyleSheetRequesfunc (h *StyleSheetHandler) Delete(c *okapi.Context, req *DeleteStyleSheetRequest) error {if err := requireEdit(c); err != nil {- return err+ return c.AbortForbidden("Insufficient workspace permissions", err)}ss, err := h.repo.FindByID(uint(req.ID))if err != nil || !ownsResource(c, ss.UserID, ss.WorkspaceID) {diff --git a/internal/handlers/subscriber_handler.go b/internal/handlers/subscriber_handler.goindex 86ebc45..2169284 100644--- a/internal/handlers/subscriber_handler.go+++ b/internal/handlers/subscriber_handler.go@@ -25,9 +25,9 @@ import ("strings""time"- "github.com/jkaninda/okapi""github.com/goposta/posta/internal/models""github.com/goposta/posta/internal/storage/repositories"+ "github.com/jkaninda/okapi")type SubscriberHandler struct {@@ -97,7 +97,7 @@ type BulkImportResult struct {func (h *SubscriberHandler) Create(c *okapi.Context, req *CreateSubscriberRequest) error {if err := requireEdit(c); err != nil {- return err+ return c.AbortForbidden("Insufficient workspace permissions", err)}scope := getScope(c)@@ -149,7 +149,7 @@ func (h *SubscriberHandler) Get(c *okapi.Context, req *GetSubscriberRequest) errfunc (h *SubscriberHandler) Update(c *okapi.Context, req *UpdateSubscriberRequest) error {if err := requireEdit(c); err != nil {- return err+ return c.AbortForbidden("Insufficient workspace permissions", err)}s, err := h.repo.FindByID(uint(req.ID))if err != nil || !ownsResource(c, s.UserID, s.WorkspaceID) {@@ -187,7 +187,7 @@ func (h *SubscriberHandler) Update(c *okapi.Context, req *UpdateSubscriberRequesfunc (h *SubscriberHandler) Delete(c *okapi.Context, req *DeleteSubscriberRequest) error {if err := requireEdit(c); err != nil {- return err+ return c.AbortForbidden("Insufficient workspace permissions", err)}s, err := h.repo.FindByID(uint(req.ID))if err != nil || !ownsResource(c, s.UserID, s.WorkspaceID) {@@ -201,7 +201,7 @@ func (h *SubscriberHandler) Delete(c *okapi.Context, req *DeleteSubscriberRequesfunc (h *SubscriberHandler) BulkImportJSON(c *okapi.Context, req *BulkImportSubscribersRequest) error {if err := requireEdit(c); err != nil {- return err+ return c.AbortForbidden("Insufficient workspace permissions", err)}scope := getScope(c)@@ -239,7 +239,7 @@ func (h *SubscriberHandler) BulkImportJSON(c *okapi.Context, req *BulkImportSubsfunc (h *SubscriberHandler) BulkImportCSV(c *okapi.Context) error {if err := requireEdit(c); err != nil {- return err+ return c.AbortForbidden("Insufficient workspace permissions", err)}scope := getScope(c)@@ -247,7 +247,7 @@ func (h *SubscriberHandler) BulkImportCSV(c *okapi.Context) error {if err != nil {return c.AbortBadRequest("file is required")}- defer file.Close()+ defer func() { _ = file.Close() }()// Parse optional column mapping: {"0":"email","1":"name","2":"custom_fields.company"}mappingStr := c.Request().FormValue("column_mapping")diff --git a/internal/handlers/subscriber_list_handler.go b/internal/handlers/subscriber_list_handler.goindex 90c4365..11bc073 100644--- a/internal/handlers/subscriber_list_handler.go+++ b/internal/handlers/subscriber_list_handler.go@@ -20,9 +20,9 @@ package handlersimport ("time"- "github.com/jkaninda/okapi""github.com/goposta/posta/internal/models""github.com/goposta/posta/internal/storage/repositories"+ "github.com/jkaninda/okapi")type SubscriberListHandler struct {@@ -99,7 +99,7 @@ type SubscriberListWithCount struct {func (h *SubscriberListHandler) Create(c *okapi.Context, req *CreateSubscriberListRequest) error {if err := requireEdit(c); err != nil {- return err+ return c.AbortForbidden("Insufficient workspace permissions", err)}scope := getScope(c)@@ -179,7 +179,7 @@ func (h *SubscriberListHandler) Get(c *okapi.Context, req *GetSubscriberListRequfunc (h *SubscriberListHandler) Update(c *okapi.Context, req *UpdateSubscriberListRequest) error {if err := requireEdit(c); err != nil {- return err+ return c.AbortForbidden("Insufficient workspace permissions", err)}list, err := h.repo.FindByID(uint(req.ID))if err != nil || !ownsResource(c, list.UserID, list.WorkspaceID) {@@ -206,7 +206,7 @@ func (h *SubscriberListHandler) Update(c *okapi.Context, req *UpdateSubscriberLifunc (h *SubscriberListHandler) Delete(c *okapi.Context, req *DeleteSubscriberListRequest) error {if err := requireEdit(c); err != nil {- return err+ return c.AbortForbidden("Insufficient workspace permissions", err)}list, err := h.repo.FindByID(uint(req.ID))if err != nil || !ownsResource(c, list.UserID, list.WorkspaceID) {@@ -220,7 +220,7 @@ func (h *SubscriberListHandler) Delete(c *okapi.Context, req *DeleteSubscriberLifunc (h *SubscriberListHandler) AddMember(c *okapi.Context, req *AddSubscriberToListRequest) error {if err := requireEdit(c); err != nil {- return err+ return c.AbortForbidden("Insufficient workspace permissions", err)}list, err := h.repo.FindByID(uint(req.ID))if err != nil || !ownsResource(c, list.UserID, list.WorkspaceID) {@@ -248,7 +248,7 @@ func (h *SubscriberListHandler) AddMember(c *okapi.Context, req *AddSubscriberTofunc (h *SubscriberListHandler) RemoveMember(c *okapi.Context, req *RemoveSubscriberFromListRequest) error {if err := requireEdit(c); err != nil {- return err+ return c.AbortForbidden("Insufficient workspace permissions", err)}list, err := h.repo.FindByID(uint(req.ID))if err != nil || !ownsResource(c, list.UserID, list.WorkspaceID) {diff --git a/internal/handlers/suppression_handler.go b/internal/handlers/suppression_handler.goindex cfdbb0b..24e4c0d 100644--- a/internal/handlers/suppression_handler.go+++ b/internal/handlers/suppression_handler.go@@ -18,9 +18,9 @@package handlersimport (- "github.com/jkaninda/okapi""github.com/goposta/posta/internal/models""github.com/goposta/posta/internal/storage/repositories"+ "github.com/jkaninda/okapi")type SuppressionHandler struct {@@ -44,7 +44,7 @@ func NewSuppressionHandler(repo *repositories.SuppressionRepository) *Suppressiofunc (h *SuppressionHandler) Create(c *okapi.Context, req *CreateSuppressionRequest) error {if err := requireEdit(c); err != nil {- return err+ return c.AbortForbidden("Insufficient workspace permissions", err)}scope := getScope(c)@@ -75,7 +75,7 @@ func (h *SuppressionHandler) List(c *okapi.Context, req *ListRequest) error {func (h *SuppressionHandler) Delete(c *okapi.Context, req *DeleteSuppressionRequest) error {if err := requireEdit(c); err != nil {- return err+ return c.AbortForbidden("Insufficient workspace permissions", err)}scope := getScope(c)diff --git a/internal/handlers/template_handler.go b/internal/handlers/template_handler.goindex ad8ec85..d23fe16 100644--- a/internal/handlers/template_handler.go+++ b/internal/handlers/template_handler.go@@ -23,11 +23,11 @@ import ("strings""time"- "github.com/jkaninda/okapi""github.com/goposta/posta/internal/config""github.com/goposta/posta/internal/models""github.com/goposta/posta/internal/services/email""github.com/goposta/posta/internal/storage/repositories"+ "github.com/jkaninda/okapi")type TemplateHandler struct {@@ -83,7 +83,7 @@ func NewTemplateHandler(repo *repositories.TemplateRepository, ssRepo *repositorfunc (h *TemplateHandler) Create(c *okapi.Context, req *CreateTemplateRequest) error {if err := requireEdit(c); err != nil {- return err+ return c.AbortForbidden("Insufficient workspace permissions", err)}scope := getScope(c)@@ -130,7 +130,7 @@ func (h *TemplateHandler) Create(c *okapi.Context, req *CreateTemplateRequest) efunc (h *TemplateHandler) Update(c *okapi.Context, req *UpdateTemplateRequest) error {if err := requireEdit(c); err != nil {- return err+ return c.AbortForbidden("Insufficient workspace permissions", err)}tmpl, err := h.repo.FindByID(uint(req.ID))if err != nil || !ownsResource(c, tmpl.UserID, tmpl.WorkspaceID) {@@ -173,7 +173,7 @@ func (h *TemplateHandler) List(c *okapi.Context, req *ListRequest) error {func (h *TemplateHandler) Delete(c *okapi.Context, req *DeleteTemplateRequest) error {if err := requireEdit(c); err != nil {- return err+ return c.AbortForbidden("Insufficient workspace permissions", err)}tmpl, err := h.repo.FindByID(uint(req.ID))if err != nil || !ownsResource(c, tmpl.UserID, tmpl.WorkspaceID) {@@ -224,7 +224,7 @@ func (h *TemplateHandler) Preview(c *okapi.Context, req *PreviewTemplateRequest)func (h *TemplateHandler) SendTest(c *okapi.Context, req *SendTestRequest) error {if err := requireEdit(c); err != nil {- return err+ return c.AbortForbidden("Insufficient workspace permissions", err)}userEmail := c.GetString("email")scope := getScope(c)@@ -242,7 +242,6 @@ func (h *TemplateHandler) SendTest(c *okapi.Context, req *SendTestRequest) errorreturn ok(c, resp)}-type ExportTemplateRequest struct {ID int `param:"id"`}@@ -327,7 +326,7 @@ func (h *TemplateHandler) Export(c *okapi.Context, req *ExportTemplateRequest) efunc (h *TemplateHandler) Import(c *okapi.Context, req *ImportTemplateRequest) error {if err := requireEdit(c); err != nil {- return err+ return c.AbortForbidden("Insufficient workspace permissions", err)}scope := getScope(c)data := req.Body@@ -421,7 +420,7 @@ func (h *TemplateHandler) Import(c *okapi.Context, req *ImportTemplateRequest) e// as the template localization content.func (h *TemplateHandler) ImportHTML(c *okapi.Context) error {if err := requireEdit(c); err != nil {- return err+ return c.AbortForbidden("Insufficient workspace permissions", err)}scope := getScope(c)@@ -429,7 +428,7 @@ func (h *TemplateHandler) ImportHTML(c *okapi.Context) error {if err != nil {return c.AbortBadRequest("file is required")}- defer file.Close()+ defer func() { _ = file.Close() }()// Validate file extensionfilename := header.Filenamediff --git a/internal/handlers/template_localization_handler.go b/internal/handlers/template_localization_handler.goindex 5a41ba0..beff4a0 100644--- a/internal/handlers/template_localization_handler.go+++ b/internal/handlers/template_localization_handler.go@@ -20,10 +20,10 @@ package handlersimport ("time"- "github.com/jkaninda/okapi""github.com/goposta/posta/internal/models""github.com/goposta/posta/internal/services/email""github.com/goposta/posta/internal/storage/repositories"+ "github.com/jkaninda/okapi")type TemplateLocalizationHandler struct {@@ -103,7 +103,7 @@ func (h *TemplateLocalizationHandler) List(c *okapi.Context, req *ListLocalizatifunc (h *TemplateLocalizationHandler) Create(c *okapi.Context, req *CreateLocalizationRequest) error {if err := requireEdit(c); err != nil {- return err+ return c.AbortForbidden("Insufficient workspace permissions", err)}tmpl, err := h.templateRepo.FindByID(uint(req.TemplateID))if err != nil || !ownsResource(c, tmpl.UserID, tmpl.WorkspaceID) {@@ -133,7 +133,7 @@ func (h *TemplateLocalizationHandler) Create(c *okapi.Context, req *CreateLocalifunc (h *TemplateLocalizationHandler) Update(c *okapi.Context, req *UpdateLocalizationRequest) error {if err := requireEdit(c); err != nil {- return err+ return c.AbortForbidden("Insufficient workspace permissions", err)}l, err := h.localizationRepo.FindByID(uint(req.ID))if err != nil {@@ -175,7 +175,7 @@ func (h *TemplateLocalizationHandler) Update(c *okapi.Context, req *UpdateLocalifunc (h *TemplateLocalizationHandler) Delete(c *okapi.Context, req *DeleteLocalizationRequest) error {if err := requireEdit(c); err != nil {- return err+ return c.AbortForbidden("Insufficient workspace permissions", err)}l, err := h.localizationRepo.FindByID(uint(req.ID))if err != nil {diff --git a/internal/handlers/template_version_handler.go b/internal/handlers/template_version_handler.goindex 7380351..0d1ada7 100644--- a/internal/handlers/template_version_handler.go+++ b/internal/handlers/template_version_handler.go@@ -20,9 +20,9 @@ package handlersimport ("time"- "github.com/jkaninda/okapi""github.com/goposta/posta/internal/models""github.com/goposta/posta/internal/storage/repositories"+ "github.com/jkaninda/okapi")type TemplateVersionHandler struct {@@ -81,7 +81,7 @@ func (h *TemplateVersionHandler) List(c *okapi.Context, req *ListVersionsRequestfunc (h *TemplateVersionHandler) Create(c *okapi.Context, req *CreateVersionRequest) error {if err := requireEdit(c); err != nil {- return err+ return c.AbortForbidden("Insufficient workspace permissions", err)}tmpl, err := h.templateRepo.FindByID(uint(req.TemplateID))if err != nil || !ownsResource(c, tmpl.UserID, tmpl.WorkspaceID) {@@ -110,7 +110,7 @@ func (h *TemplateVersionHandler) Create(c *okapi.Context, req *CreateVersionRequfunc (h *TemplateVersionHandler) Update(c *okapi.Context, req *UpdateVersionRequest) error {if err := requireEdit(c); err != nil {- return err+ return c.AbortForbidden("Insufficient workspace permissions", err)}tmpl, err := h.templateRepo.FindByID(uint(req.TemplateID))if err != nil || !ownsResource(c, tmpl.UserID, tmpl.WorkspaceID) {@@ -135,7 +135,7 @@ func (h *TemplateVersionHandler) Update(c *okapi.Context, req *UpdateVersionRequfunc (h *TemplateVersionHandler) Activate(c *okapi.Context, req *ActivateVersionRequest) error {if err := requireEdit(c); err != nil {- return err+ return c.AbortForbidden("Insufficient workspace permissions", err)}tmpl, err := h.templateRepo.FindByID(uint(req.TemplateID))if err != nil || !ownsResource(c, tmpl.UserID, tmpl.WorkspaceID) {@@ -161,7 +161,7 @@ func (h *TemplateVersionHandler) Activate(c *okapi.Context, req *ActivateVersionfunc (h *TemplateVersionHandler) Delete(c *okapi.Context, req *DeleteVersionRequest) error {if err := requireEdit(c); err != nil {- return err+ return c.AbortForbidden("Insufficient workspace permissions", err)}tmpl, err := h.templateRepo.FindByID(uint(req.TemplateID))if err != nil || !ownsResource(c, tmpl.UserID, tmpl.WorkspaceID) {diff --git a/internal/handlers/tracking_handler.go b/internal/handlers/tracking_handler.goindex fda4ceb..6f13262 100644--- a/internal/handlers/tracking_handler.go+++ b/internal/handlers/tracking_handler.go@@ -24,10 +24,10 @@ import ("strings""time"- "github.com/jkaninda/okapi""github.com/goposta/posta/internal/models""github.com/goposta/posta/internal/services/tracking""github.com/goposta/posta/internal/storage/repositories"+ "github.com/jkaninda/okapi")// 1x1 transparent GIF@@ -78,7 +78,7 @@ func (h *TrackingHandler) OpenPixel(c *okapi.Context, req *TrackingOpenRequest)c.ResponseWriter().Header().Set("Content-Type", "image/gif")c.ResponseWriter().Header().Set("Cache-Control", "no-cache, no-store, must-revalidate")c.ResponseWriter().WriteHeader(http.StatusOK)- c.ResponseWriter().Write(transparentPixel)+ _, _ = c.ResponseWriter().Write(transparentPixel)return nil}@@ -129,7 +129,7 @@ button:hover{background:#7e22ce}.done{color:#16a34a;font-weight:600}</style></hec.ResponseWriter().Header().Set("Content-Type", "text/html; charset=utf-8")c.ResponseWriter().WriteHeader(http.StatusOK)- c.ResponseWriter().Write([]byte(html))+ _, _ = c.ResponseWriter().Write([]byte(html))return nil}@@ -161,7 +161,7 @@ func (h *TrackingHandler) UnsubscribeConfirm(c *okapi.Context, req *TrackingUnsu_ = h.messageRepo.UpdateUnsubscribedAt(msg.ID)// Record event- h.trackingRepo.CreateEvent(&models.TrackingEvent{+ _ = h.trackingRepo.CreateEvent(&models.TrackingEvent{CampaignMessageID: msg.ID,EventType: models.TrackingEventUnsubscribe,IP: c.RealIP(),@@ -176,11 +176,10 @@ h1{font-size:20px;color:#16a34a}p{color:#6b7280;font-size:14px}</style></head><bc.ResponseWriter().Header().Set("Content-Type", "text/html; charset=utf-8")c.ResponseWriter().WriteHeader(http.StatusOK)- c.ResponseWriter().Write([]byte(html))+ _, _ = c.ResponseWriter().Write([]byte(html))return nil}-type CampaignAnalyticsRequest struct {ID int `param:"id"`}@@ -219,7 +218,6 @@ func (h *TrackingHandler) CampaignAnalytics(c *okapi.Context, req *CampaignAnaly})}-func (h *TrackingHandler) recordOpen(messageID uint, ip, userAgent string) {msg, err := h.messageRepo.FindByCampaignMessageID(messageID)if err != nil {@@ -234,7 +232,7 @@ func (h *TrackingHandler) recordOpen(messageID uint, ip, userAgent string) {}// Always record the event (for total open tracking)- h.trackingRepo.CreateEvent(&models.TrackingEvent{+ _ = h.trackingRepo.CreateEvent(&models.TrackingEvent{CampaignMessageID: msg.ID,EventType: models.TrackingEventOpen,IP: ip,@@ -260,7 +258,7 @@ func (h *TrackingHandler) recordClick(messageID uint, linkID uint, ip, userAgent// Record event (unique per link per message for deduplication stats)if !h.trackingRepo.HasClickEvent(msg.ID, linkID) {- h.trackingRepo.CreateEvent(&models.TrackingEvent{+ _ = h.trackingRepo.CreateEvent(&models.TrackingEvent{CampaignMessageID: msg.ID,EventType: models.TrackingEventClick,TrackedLinkID: &linkID,diff --git a/internal/handlers/user_data_handler.go b/internal/handlers/user_data_handler.goindex 4981f0e..7756819 100644--- a/internal/handlers/user_data_handler.go+++ b/internal/handlers/user_data_handler.go@@ -21,10 +21,10 @@ import ("fmt""time"- "github.com/jkaninda/okapi""github.com/goposta/posta/internal/config""github.com/goposta/posta/internal/models""github.com/goposta/posta/internal/storage/repositories"+ "github.com/jkaninda/okapi""gorm.io/gorm")@@ -67,7 +67,6 @@ func NewUserDataHandler(}}-type UserDataExport struct {PostaVersion string `json:"posta_version"`ExportedAt string `json:"exported_at"`@@ -84,7 +83,6 @@ type ImportUserDataRequest struct {Body UserDataExport `json:"body"`}-type GDPRDeleteContactsRequest struct {Body struct {Email string `json:"email"`@@ -102,7 +100,6 @@ type GDPRDeleteResult struct {Message string `json:"message"`}-func (h *UserDataHandler) Export(c *okapi.Context) error {userID := uint(c.GetInt("user_id"))scope := repositories.ResourceScope{UserID: userID}@@ -205,7 +202,6 @@ func (h *UserDataHandler) Import(c *okapi.Context, req *ImportUserDataRequest) e})}-func (h *UserDataHandler) DeleteContacts(c *okapi.Context, req *GDPRDeleteContactsRequest) error {userID := uint(c.GetInt("user_id"))email := req.Body.Email@@ -240,7 +236,6 @@ func (h *UserDataHandler) DeleteContacts(c *okapi.Context, req *GDPRDeleteContac})}-func (h *UserDataHandler) DeleteEmailLogs(c *okapi.Context, req *GDPRDeleteEmailLogsRequest) error {userID := uint(c.GetInt("user_id"))diff --git a/internal/handlers/user_handler.go b/internal/handlers/user_handler.goindex 96b09cc..16cb1c8 100644--- a/internal/handlers/user_handler.go+++ b/internal/handlers/user_handler.go@@ -25,7 +25,6 @@ import ("strings""github.com/google/uuid"- "github.com/jkaninda/okapi""github.com/goposta/posta/internal/dto""github.com/goposta/posta/internal/models""github.com/goposta/posta/internal/services/eventbus"@@ -33,6 +32,7 @@ import ("github.com/goposta/posta/internal/services/settings""github.com/goposta/posta/internal/services/twofactor""github.com/goposta/posta/internal/storage/repositories"+ "github.com/jkaninda/okapi""golang.org/x/crypto/bcrypt")@@ -488,7 +488,7 @@ func (h *UserHandler) RequestAccountDeletion(c *okapi.Context) error {}return ok(c, map[string]any{- "message": "Account scheduled for deletion",+ "message": "Account scheduled for deletion","scheduled_deletion_at": deletionDate,})}diff --git a/internal/handlers/user_setting_handler.go b/internal/handlers/user_setting_handler.goindex ba4c3f5..944bd16 100644--- a/internal/handlers/user_setting_handler.go+++ b/internal/handlers/user_setting_handler.go@@ -18,8 +18,8 @@package handlersimport (- "github.com/jkaninda/okapi""github.com/goposta/posta/internal/storage/repositories"+ "github.com/jkaninda/okapi")// UserSettingHandler handles per-user settings.@@ -31,7 +31,6 @@ func NewUserSettingHandler(repo *repositories.UserSettingRepository) *UserSettinreturn &UserSettingHandler{repo: repo}}-type UpdateUserSettingsRequest struct {Body struct {Timezone *string `json:"timezone"`diff --git a/internal/handlers/webhook_delivery_handler.go b/internal/handlers/webhook_delivery_handler.goindex eb90f8b..8b224f1 100644--- a/internal/handlers/webhook_delivery_handler.go+++ b/internal/handlers/webhook_delivery_handler.go@@ -18,8 +18,8 @@package handlersimport (- "github.com/jkaninda/okapi""github.com/goposta/posta/internal/storage/repositories"+ "github.com/jkaninda/okapi")type WebhookDeliveryHandler struct {diff --git a/internal/handlers/webhook_handler.go b/internal/handlers/webhook_handler.goindex 87f9302..456cc13 100644--- a/internal/handlers/webhook_handler.go+++ b/internal/handlers/webhook_handler.go@@ -21,10 +21,10 @@ import ("crypto/rand""encoding/hex"- "github.com/jkaninda/okapi""github.com/goposta/posta/internal/models""github.com/goposta/posta/internal/services/audit""github.com/goposta/posta/internal/storage/repositories"+ "github.com/jkaninda/okapi")type WebhookHandler struct {@@ -48,7 +48,7 @@ func NewWebhookHandler(repo *repositories.WebhookRepository, audit *audit.Loggerfunc (h *WebhookHandler) Create(c *okapi.Context, req *CreateWebhookRequest) error {if err := requireEdit(c); err != nil {- return err+ return c.AbortForbidden("Insufficient workspace permissions", err)}scope := getScope(c)@@ -70,10 +70,10 @@ func (h *WebhookHandler) Create(c *okapi.Context, req *CreateWebhookRequest) errwh := &models.Webhook{UserID: scope.UserID,WorkspaceID: scope.WorkspaceID,- URL: req.Body.URL,- Events: req.Body.Events,- Filters: req.Body.Filters,- Secret: secret,+ URL: req.Body.URL,+ Events: req.Body.Events,+ Filters: req.Body.Filters,+ Secret: secret,}if err := h.repo.Create(wh); err != nil {@@ -98,7 +98,7 @@ func (h *WebhookHandler) List(c *okapi.Context, req *ListRequest) error {func (h *WebhookHandler) Delete(c *okapi.Context, req *DeleteWebhookRequest) error {if err := requireEdit(c); err != nil {- return err+ return c.AbortForbidden("Insufficient workspace permissions", err)}wh, err := h.repo.FindByID(uint(req.ID))if err != nil || !ownsResource(c, wh.UserID, wh.WorkspaceID) {diff --git a/internal/handlers/workspace_data_handler.go b/internal/handlers/workspace_data_handler.goindex 2f25ce9..0903dad 100644--- a/internal/handlers/workspace_data_handler.go+++ b/internal/handlers/workspace_data_handler.go@@ -20,9 +20,9 @@ package handlersimport ("time"- "github.com/jkaninda/okapi""github.com/goposta/posta/internal/config""github.com/goposta/posta/internal/storage/repositories"+ "github.com/jkaninda/okapi""gorm.io/gorm")@@ -80,7 +80,6 @@ func NewWorkspaceDataHandler(}}-type WorkspaceDataExport struct {PostaVersion string `json:"posta_version"`ExportedAt string `json:"exported_at"`@@ -193,6 +192,9 @@ func (h *WorkspaceDataHandler) Export(c *okapi.Context) error {}func (h *WorkspaceDataHandler) Import(c *okapi.Context, req *ImportWorkspaceDataRequest) error {+ if err := requireEdit(c); err != nil {+ return c.AbortForbidden("Insufficient workspace permissions", err)+ }userID := uint(c.GetInt("user_id"))wsID := uint(c.GetInt("workspace_id"))data := req.Bodydiff --git a/internal/handlers/workspace_handler.go b/internal/handlers/workspace_handler.goindex 6769495..777b643 100644--- a/internal/handlers/workspace_handler.go+++ b/internal/handlers/workspace_handler.go@@ -25,9 +25,9 @@ import ("strings""time"- "github.com/jkaninda/okapi""github.com/goposta/posta/internal/models""github.com/goposta/posta/internal/storage/repositories"+ "github.com/jkaninda/okapi""gorm.io/gorm")@@ -52,7 +52,6 @@ func NewWorkspaceHandler(workspaceRepo *repositories.WorkspaceRepository, userRe}}-type CreateWorkspaceRequest struct {Body struct {Name string `json:"name" required:"true" minLength:"1"`@@ -72,7 +71,7 @@ type UpdateWorkspaceRequest struct {type InviteMemberRequest struct {Body struct {- Email string `json:"email" required:"true" format:"email"`+ Email string `json:"email" required:"true" format:"email"`Role models.WorkspaceRole `json:"role" required:"true"`} `json:"body"`}@@ -135,7 +134,7 @@ func (h *WorkspaceHandler) Create(c *okapi.Context, req *CreateWorkspaceRequest)if h.planService != nil {if err := h.planService.CheckWorkspaceQuota(h.db, uint(userID)); err != nil {- return c.AbortForbidden(err.Error())+ return c.AbortForbidden("Workspace quota exceeded for your plan", err)}}@@ -288,7 +287,6 @@ func (h *WorkspaceHandler) Delete(c *okapi.Context) error {return noContent(c)}-func (h *WorkspaceHandler) ListMembers(c *okapi.Context) error {wsID := c.GetInt("workspace_id")@@ -356,7 +354,6 @@ func (h *WorkspaceHandler) RemoveMember(c *okapi.Context, req *RemoveWorkspaceMereturn noContent(c)}-func (h *WorkspaceHandler) InviteMember(c *okapi.Context, req *InviteMemberRequest) error {wsID := c.GetInt("workspace_id")inviterID := c.GetInt("user_id")@@ -443,7 +440,6 @@ func (h *WorkspaceHandler) DeleteInvitation(c *okapi.Context, req *DeleteInvitatreturn noContent(c)}-func (h *WorkspaceHandler) MyInvitations(c *okapi.Context) error {userEmail := c.GetString("email")@@ -491,7 +487,7 @@ func (h *WorkspaceHandler) AcceptInvitation(c *okapi.Context, req *AcceptInvitatreturn c.AbortInternalServerError("user not found")}- if strings.ToLower(user.Email) != strings.ToLower(inv.Email) {+ if !strings.EqualFold(user.Email, inv.Email) {return c.AbortForbidden("invitation is for a different email address")}@@ -552,7 +548,7 @@ func (h *WorkspaceHandler) AcceptInvitationByID(c *okapi.Context, req *AcceptInvreturn c.AbortInternalServerError("user not found")}- if strings.ToLower(user.Email) != strings.ToLower(inv.Email) {+ if !strings.EqualFold(user.Email, inv.Email) {return c.AbortForbidden("invitation is for a different email address")}@@ -599,7 +595,7 @@ func (h *WorkspaceHandler) DeclineInvitationByID(c *okapi.Context, req *DeclineIif err != nil {return c.AbortInternalServerError("user not found")}- if strings.ToLower(user.Email) != strings.ToLower(inv.Email) {+ if !strings.EqualFold(user.Email, inv.Email) {return c.AbortForbidden("invitation is for a different email address")}@@ -625,7 +621,6 @@ func (h *WorkspaceHandler) DeclineInvitation(c *okapi.Context, req *DeclineInvitreturn ok(c, okapi.M{"message": "invitation declined"})}-type TransferDataRequest struct {Body struct {Resources []string `json:"resources" required:"true"`@@ -638,9 +633,9 @@ type TransferResult struct {}type TransferResponse struct {- Message string `json:"message"`- Results []TransferResult `json:"results"`- Total int64 `json:"total"`+ Message string `json:"message"`+ Results []TransferResult `json:"results"`+ Total int64 `json:"total"`}// TransferData moves the current user's personal data into the workspace.@@ -652,19 +647,19 @@ func (h *WorkspaceHandler) TransferData(c *okapi.Context, req *TransferDataReque}allowedResources := map[string]string{- "templates": "templates",- "stylesheets": "style_sheets",- "languages": "languages",- "smtp_servers": "smtp_servers",- "domains": "domains",- "webhooks": "webhooks",- "contacts": "contacts",- "subscribers": "subscribers",- "subscriber_lists": "subscriber_lists",- "suppressions": "suppressions",- "api_keys": "api_keys",- "bounces": "bounces",- "emails": "emails",+ "templates": "templates",+ "stylesheets": "style_sheets",+ "languages": "languages",+ "smtp_servers": "smtp_servers",+ "domains": "domains",+ "webhooks": "webhooks",+ "contacts": "contacts",+ "subscribers": "subscribers",+ "subscriber_lists": "subscriber_lists",+ "suppressions": "suppressions",+ "api_keys": "api_keys",+ "bounces": "bounces",+ "emails": "emails",}var results []TransferResult@@ -705,7 +700,6 @@ func (h *WorkspaceHandler) TransferData(c *okapi.Context, req *TransferDataReque})}-var slugRegex = regexp.MustCompile(`^[a-z0-9]+(?:-[a-z0-9]+)*$`)func isValidSlug(s string) bool {diff --git a/internal/middlewares/middleware.go b/internal/middlewares/middleware.goindex dfb3471..abd8481 100644--- a/internal/middlewares/middleware.go+++ b/internal/middlewares/middleware.go@@ -23,12 +23,12 @@ import ("strings""github.com/golang-jwt/jwt/v5"- "github.com/jkaninda/okapi""github.com/goposta/posta/internal/config""github.com/goposta/posta/internal/services/auth""github.com/goposta/posta/internal/services/ratelimit"sessionpkg "github.com/goposta/posta/internal/services/session""github.com/goposta/posta/internal/storage/repositories"+ "github.com/jkaninda/okapi")func baseJWTAuth(cfg *config.Config) okapi.JWTAuth {diff --git a/internal/middlewares/workspace.go b/internal/middlewares/workspace.goindex ad1f0b8..9a4fd8f 100644--- a/internal/middlewares/workspace.go+++ b/internal/middlewares/workspace.go@@ -20,9 +20,9 @@ package middlewaresimport ("strconv"- "github.com/jkaninda/okapi""github.com/goposta/posta/internal/models""github.com/goposta/posta/internal/storage/repositories"+ "github.com/jkaninda/okapi")// OptionalWorkspaceMiddleware reads the X-Posta-Workspace-Id header if present.diff --git a/internal/models/bounce.go b/internal/models/bounce.goindex 21583c7..a3ea9cc 100644--- a/internal/models/bounce.go+++ b/internal/models/bounce.go@@ -31,11 +31,11 @@ type Bounce struct {ID uint `json:"id" gorm:"primaryKey"`UserID uint `json:"user_id" gorm:"index;not null"`WorkspaceID *uint `json:"workspace_id,omitempty" gorm:"index"`- EmailID uint `json:"email_id" gorm:"index;not null"`- Recipient string `json:"recipient" gorm:"not null"`- Type BounceType `json:"type" gorm:"not null"`- Reason string `json:"reason"`- CreatedAt time.Time `json:"created_at"`+ EmailID uint `json:"email_id" gorm:"index;not null"`+ Recipient string `json:"recipient" gorm:"not null"`+ Type BounceType `json:"type" gorm:"not null"`+ Reason string `json:"reason"`+ CreatedAt time.Time `json:"created_at"`User User `json:"-" gorm:"foreignKey:UserID"`Email Email `json:"-" gorm:"foreignKey:EmailID"`diff --git a/internal/models/contact.go b/internal/models/contact.goindex f7251fc..cac86e4 100644--- a/internal/models/contact.go+++ b/internal/models/contact.go@@ -23,10 +23,10 @@ type Contact struct {ID uint `json:"id" gorm:"primaryKey"`UserID uint `json:"user_id" gorm:"index;not null"`WorkspaceID *uint `json:"workspace_id,omitempty" gorm:"index"`- Email string `json:"email" gorm:"not null"`- Name string `json:"name" gorm:"default:''"`- SentCount int64 `json:"sent_count" gorm:"default:0;not null"`- FailCount int64 `json:"fail_count" gorm:"default:0;not null"`- LastSentAt *time.Time `json:"last_sent_at"`- CreatedAt time.Time `json:"created_at"`+ Email string `json:"email" gorm:"not null"`+ Name string `json:"name" gorm:"default:''"`+ SentCount int64 `json:"sent_count" gorm:"default:0;not null"`+ FailCount int64 `json:"fail_count" gorm:"default:0;not null"`+ LastSentAt *time.Time `json:"last_sent_at"`+ CreatedAt time.Time `json:"created_at"`}diff --git a/internal/models/event.go b/internal/models/event.goindex f9ba090..9baa3a4 100644--- a/internal/models/event.go+++ b/internal/models/event.go@@ -34,9 +34,9 @@ type Event struct {Type string `json:"type" gorm:"index;not null"`WorkspaceID *uint `json:"workspace_id,omitempty" gorm:"index"`ActorID *uint `json:"actor_id" gorm:"index"`- ActorName string `json:"actor_name"`- ClientIP string `json:"client_ip,omitempty" gorm:"size:45"`- Message string `json:"message" gorm:"not null"`- Metadata string `json:"metadata" gorm:"type:text"`- CreatedAt time.Time `json:"created_at" gorm:"index"`+ ActorName string `json:"actor_name"`+ ClientIP string `json:"client_ip,omitempty" gorm:"size:45"`+ Message string `json:"message" gorm:"not null"`+ Metadata string `json:"metadata" gorm:"type:text"`+ CreatedAt time.Time `json:"created_at" gorm:"index"`}diff --git a/internal/models/language.go b/internal/models/language.goindex 7a72534..a1f68db 100644--- a/internal/models/language.go+++ b/internal/models/language.go@@ -23,10 +23,10 @@ type Language struct {ID uint `json:"id" gorm:"primaryKey"`UserID uint `json:"user_id" gorm:"index;not null"`WorkspaceID *uint `json:"workspace_id,omitempty" gorm:"index"`- Code string `json:"code" gorm:"not null;size:10"`- Name string `json:"name" gorm:"not null"`- IsDefault bool `json:"is_default" gorm:"default:false"`- CreatedAt time.Time `json:"created_at"`+ Code string `json:"code" gorm:"not null;size:10"`+ Name string `json:"name" gorm:"not null"`+ IsDefault bool `json:"is_default" gorm:"default:false"`+ CreatedAt time.Time `json:"created_at"`User User `json:"-" gorm:"foreignKey:UserID"`}diff --git a/internal/models/stylesheet.go b/internal/models/stylesheet.goindex b4129d6..bb6b3dc 100644--- a/internal/models/stylesheet.go+++ b/internal/models/stylesheet.go@@ -23,10 +23,10 @@ type StyleSheet struct {ID uint `json:"id" gorm:"primaryKey"`UserID uint `json:"user_id" gorm:"index;not null"`WorkspaceID *uint `json:"workspace_id,omitempty" gorm:"index"`- Name string `json:"name" gorm:"not null"`- CSS string `json:"css"`- CreatedAt time.Time `json:"created_at"`- UpdatedAt *time.Time `json:"updated_at,omitempty"`+ Name string `json:"name" gorm:"not null"`+ CSS string `json:"css"`+ CreatedAt time.Time `json:"created_at"`+ UpdatedAt *time.Time `json:"updated_at,omitempty"`User User `json:"-" gorm:"foreignKey:UserID"`}diff --git a/internal/models/suppression.go b/internal/models/suppression.goindex d422faa..ac66974 100644--- a/internal/models/suppression.go+++ b/internal/models/suppression.go@@ -23,9 +23,9 @@ type Suppression struct {ID uint `json:"id" gorm:"primaryKey"`UserID uint `json:"user_id" gorm:"index;not null"`WorkspaceID *uint `json:"workspace_id,omitempty" gorm:"index"`- Email string `json:"email" gorm:"not null"`- Reason string `json:"reason"`- CreatedAt time.Time `json:"created_at"`+ Email string `json:"email" gorm:"not null"`+ Reason string `json:"reason"`+ CreatedAt time.Time `json:"created_at"`User User `json:"-" gorm:"foreignKey:UserID"`}diff --git a/internal/models/webhook.go b/internal/models/webhook.goindex 29c1dc7..36703d4 100644--- a/internal/models/webhook.go+++ b/internal/models/webhook.go@@ -27,11 +27,11 @@ type Webhook struct {ID uint `json:"id" gorm:"primaryKey"`UserID uint `json:"user_id" gorm:"index;not null"`WorkspaceID *uint `json:"workspace_id,omitempty" gorm:"index"`- URL string `json:"url" gorm:"not null"`- Events pq.StringArray `json:"events" gorm:"type:text[];not null"`- Filters pq.StringArray `json:"filters" gorm:"type:text[]"`- Secret string `json:"secret,omitempty" gorm:"type:varchar(64);not null;default:''"`- CreatedAt time.Time `json:"created_at"`+ URL string `json:"url" gorm:"not null"`+ Events pq.StringArray `json:"events" gorm:"type:text[];not null"`+ Filters pq.StringArray `json:"filters" gorm:"type:text[]"`+ Secret string `json:"secret,omitempty" gorm:"type:varchar(64);not null;default:''"`+ CreatedAt time.Time `json:"created_at"`User User `json:"-" gorm:"foreignKey:UserID"`}diff --git a/internal/routes/admin_routes.go b/internal/routes/admin_routes.goindex 5d2e72c..5d2a9c8 100644--- a/internal/routes/admin_routes.go+++ b/internal/routes/admin_routes.go@@ -20,11 +20,11 @@ package routesimport ("net/http"- "github.com/jkaninda/okapi"cronpkg "github.com/goposta/posta/internal/cron""github.com/goposta/posta/internal/dto""github.com/goposta/posta/internal/handlers""github.com/goposta/posta/internal/models"+ "github.com/jkaninda/okapi")// adminRoutes returns route definitions for admin endpoints.diff --git a/internal/routes/auth_routes.go b/internal/routes/auth_routes.goindex e18c5d7..d81b13c 100644--- a/internal/routes/auth_routes.go+++ b/internal/routes/auth_routes.go@@ -20,10 +20,10 @@ package routesimport ("net/http"- "github.com/jkaninda/okapi""github.com/goposta/posta/internal/dto""github.com/goposta/posta/internal/handlers""github.com/goposta/posta/internal/services/email"+ "github.com/jkaninda/okapi")// healthRoutes returns route definitions for health check endpoints.diff --git a/internal/routes/oauth_routes.go b/internal/routes/oauth_routes.goindex b0dd13b..09cc442 100644--- a/internal/routes/oauth_routes.go+++ b/internal/routes/oauth_routes.go@@ -3,9 +3,9 @@ package routesimport ("net/http"- "github.com/jkaninda/okapi""github.com/goposta/posta/internal/dto""github.com/goposta/posta/internal/handlers"+ "github.com/jkaninda/okapi")// oauthRoutes returns route definitions for OAuth authentication.diff --git a/internal/routes/routes.go b/internal/routes/routes.goindex 1ebf222..03de811 100644--- a/internal/routes/routes.go+++ b/internal/routes/routes.go@@ -25,8 +25,6 @@ import ("strings""time"- "github.com/hibiken/asynq"- "github.com/jkaninda/okapi""github.com/goposta/posta/internal/config"cronpkg "github.com/goposta/posta/internal/cron""github.com/goposta/posta/internal/handlers"@@ -40,15 +38,17 @@ import ("github.com/goposta/posta/internal/services/eventbus"planpkg "github.com/goposta/posta/internal/services/plan""github.com/goposta/posta/internal/services/ratelimit"- "github.com/goposta/posta/internal/storage/blob""github.com/goposta/posta/internal/services/seeder"sessionpkg "github.com/goposta/posta/internal/services/session"- "github.com/goposta/posta/internal/services/tracking""github.com/goposta/posta/internal/services/settings"+ "github.com/goposta/posta/internal/services/tracking""github.com/goposta/posta/internal/services/webhook""github.com/goposta/posta/internal/services/workermon"+ "github.com/goposta/posta/internal/storage/blob""github.com/goposta/posta/internal/storage/repositories""github.com/goposta/posta/internal/worker"+ "github.com/hibiken/asynq"+ "github.com/jkaninda/okapi""github.com/redis/go-redis/v9""gorm.io/gorm")diff --git a/internal/routes/tracking_routes.go b/internal/routes/tracking_routes.goindex d8d4b25..ffda13a 100644--- a/internal/routes/tracking_routes.go+++ b/internal/routes/tracking_routes.go@@ -20,8 +20,8 @@ package routesimport ("net/http"- "github.com/jkaninda/okapi""github.com/goposta/posta/internal/handlers"+ "github.com/jkaninda/okapi")// trackingRoutes returns public (no auth) route definitions for open/click/unsubscribe tracking.diff --git a/internal/routes/user_routes.go b/internal/routes/user_routes.goindex 8bda6dd..8098ca9 100644--- a/internal/routes/user_routes.go+++ b/internal/routes/user_routes.go@@ -20,11 +20,11 @@ package routesimport ("net/http"- "github.com/jkaninda/okapi""github.com/goposta/posta/internal/dto""github.com/goposta/posta/internal/handlers""github.com/goposta/posta/internal/models""github.com/goposta/posta/internal/services/email"+ "github.com/jkaninda/okapi")// userRoutes returns route definitions for all authenticated user endpoints.diff --git a/internal/routes/workspace_routes.go b/internal/routes/workspace_routes.goindex b390a2b..eb0fd60 100644--- a/internal/routes/workspace_routes.go+++ b/internal/routes/workspace_routes.go@@ -20,10 +20,10 @@ package routesimport ("net/http"- "github.com/jkaninda/okapi""github.com/goposta/posta/internal/dto""github.com/goposta/posta/internal/handlers""github.com/goposta/posta/internal/models"+ "github.com/jkaninda/okapi")// workspaceRoutes returns route definitions for workspace management.diff --git a/internal/services/email/service.go b/internal/services/email/service.goindex d03de94..3e125f3 100644--- a/internal/services/email/service.go+++ b/internal/services/email/service.go@@ -28,13 +28,13 @@ import ("strings""time"- "github.com/jkaninda/logger""github.com/goposta/posta/internal/models""github.com/goposta/posta/internal/services/ratelimit""github.com/goposta/posta/internal/services/settings""github.com/goposta/posta/internal/services/webhook""github.com/goposta/posta/internal/storage/blob""github.com/goposta/posta/internal/storage/repositories"+ "github.com/jkaninda/logger")const (diff --git a/internal/services/eventbus/eventbus.go b/internal/services/eventbus/eventbus.goindex c566c54..4c7fc46 100644--- a/internal/services/eventbus/eventbus.go+++ b/internal/services/eventbus/eventbus.go@@ -21,9 +21,9 @@ import ("encoding/json""sync"- "github.com/jkaninda/logger""github.com/goposta/posta/internal/models""github.com/goposta/posta/internal/storage/repositories"+ "github.com/jkaninda/logger")// EventBus provides an in-memory pub/sub for events with database persistence.diff --git a/internal/services/retry/worker.go b/internal/services/retry/worker.goindex 88f05be..f8bde38 100644--- a/internal/services/retry/worker.go+++ b/internal/services/retry/worker.go@@ -22,11 +22,11 @@ import ("sync""time"- "github.com/jkaninda/logger""github.com/goposta/posta/internal/models""github.com/goposta/posta/internal/services/email""github.com/goposta/posta/internal/services/webhook""github.com/goposta/posta/internal/storage/repositories"+ "github.com/jkaninda/logger")// Worker periodically retries failed emails that haven't exceeded theirdiff --git a/internal/services/seeder/seeder.go b/internal/services/seeder/seeder.goindex c44c8d3..0aa56f1 100644--- a/internal/services/seeder/seeder.go+++ b/internal/services/seeder/seeder.go@@ -22,11 +22,11 @@ import ("fmt""time"+ "github.com/goposta/posta/internal/models"+ "github.com/goposta/posta/internal/storage/repositories"goutils "github.com/jkaninda/go-utils""github.com/jkaninda/logger""github.com/jkaninda/okapi"- "github.com/goposta/posta/internal/models"- "github.com/goposta/posta/internal/storage/repositories")type Seeder struct {diff --git a/internal/services/seeder/settings.go b/internal/services/seeder/settings.goindex abbe3c2..40bf5d3 100644--- a/internal/services/seeder/settings.go+++ b/internal/services/seeder/settings.go@@ -18,9 +18,9 @@package seederimport (- "github.com/jkaninda/logger""github.com/goposta/posta/internal/models""github.com/goposta/posta/internal/storage/repositories"+ "github.com/jkaninda/logger")// SeedDefaultSettings creates default platform settings if they don't already exist.diff --git a/internal/services/settings/provider.go b/internal/services/settings/provider.goindex 1f5cb30..62c6723 100644--- a/internal/services/settings/provider.go+++ b/internal/services/settings/provider.go@@ -22,8 +22,8 @@ import ("sync""time"- "github.com/jkaninda/logger""github.com/goposta/posta/internal/storage/repositories"+ "github.com/jkaninda/logger")// Provider gives live access to platform settings with a short cache.@@ -131,7 +131,9 @@ func (p *Provider) AuditLogRetentionDays() int { return p.GetInt("audit_log_retfunc (p *Provider) WebhookDeliveryRetentionDays() int {return p.GetInt("webhook_delivery_retention_days", 30)}-func (p *Provider) TrackingEventRetentionDays() int { return p.GetInt("tracking_event_retention_days", 90) }+func (p *Provider) TrackingEventRetentionDays() int {+ return p.GetInt("tracking_event_retention_days", 90)+}func (p *Provider) LoginRateLimitCount() int {return p.GetInt("login_rate_limit_count", 10)}diff --git a/internal/services/webhook/dispatcher_test.go b/internal/services/webhook/dispatcher_test.goindex e553db9..213c941 100644--- a/internal/services/webhook/dispatcher_test.go+++ b/internal/services/webhook/dispatcher_test.go@@ -31,7 +31,6 @@ import ("github.com/goposta/posta/internal/models")-func TestSignPayload(t *testing.T) {secret := "test-secret"body := []byte(`{"event":"email.sent"}`)@@ -66,7 +65,6 @@ func TestSignPayloadDifferentBodies(t *testing.T) {}}-func TestMatchesFilters_EmptyFilters(t *testing.T) {if !matchesFilters(nil, "[email protected]") {t.Error("empty filters should match any sender")@@ -125,7 +123,6 @@ func TestMatchesFilters_MultipleFilters(t *testing.T) {}}-func TestDispatcher_SignatureHeader(t *testing.T) {var receivedSig stringvar receivedBody []bytediff --git a/internal/services/workermon/monitor.go b/internal/services/workermon/monitor.goindex 1de3d09..01a82e1 100644--- a/internal/services/workermon/monitor.go+++ b/internal/services/workermon/monitor.go@@ -23,10 +23,10 @@ import ("sync""time"- "github.com/hibiken/asynq"- "github.com/jkaninda/logger""github.com/goposta/posta/internal/models""github.com/goposta/posta/internal/services/eventbus"+ "github.com/hibiken/asynq"+ "github.com/jkaninda/logger")// Monitor periodically checks asynq worker connections and publishesdiff --git a/internal/storage/migration/migration.go b/internal/storage/migration/migration.goindex 9ae278a..40112ba 100644--- a/internal/storage/migration/migration.go+++ b/internal/storage/migration/migration.go@@ -20,8 +20,8 @@ package migrationimport ("fmt"- "github.com/jkaninda/logger""github.com/goposta/posta/internal/models"+ "github.com/jkaninda/logger""gorm.io/gorm")diff --git a/internal/storage/postgres.go b/internal/storage/postgres.goindex 379c3f7..19176fd 100644--- a/internal/storage/postgres.go+++ b/internal/storage/postgres.go@@ -20,8 +20,8 @@ package storageimport ("fmt"- "github.com/jkaninda/logger""github.com/goposta/posta/internal/models"+ "github.com/jkaninda/logger""golang.org/x/crypto/bcrypt""gorm.io/driver/postgres""gorm.io/gorm"diff --git a/internal/storage/repositories/analytics_repo.go b/internal/storage/repositories/analytics_repo.goindex 69fa0d2..4037169 100644--- a/internal/storage/repositories/analytics_repo.go+++ b/internal/storage/repositories/analytics_repo.go@@ -295,7 +295,6 @@ func (r *AnalyticsRepository) AdminLatencyPercentiles(from, to time.Time) (*Latereturn &result, err}-func (r *AnalyticsRepository) WorkspaceDailyCounts(workspaceID uint, from, to time.Time, status string) ([]DailyCount, error) {var results []DailyCountquery := r.db.Table("emails").diff --git a/internal/storage/repositories/tracking_repo.go b/internal/storage/repositories/tracking_repo.goindex c44c4bd..0afc1f4 100644--- a/internal/storage/repositories/tracking_repo.go+++ b/internal/storage/repositories/tracking_repo.go@@ -32,7 +32,6 @@ func NewTrackingRepository(db *gorm.DB) *TrackingRepository {return &TrackingRepository{db: db}}-func (r *TrackingRepository) CreateLink(link *models.TrackedLink) error {return r.db.Create(link).Error}@@ -80,7 +79,6 @@ func (r *TrackingRepository) FindOrCreateLink(campaignID uint, originalURL, hashreturn &link, nil}-func (r *TrackingRepository) CreateEvent(event *models.TrackingEvent) error {return r.db.Create(event).Error}@@ -104,20 +102,19 @@ func (r *TrackingRepository) HasClickEvent(campaignMessageID uint, trackedLinkIDreturn count > 0}-type CampaignAnalytics struct {- TotalMessages int64 `json:"total_messages"`- SentMessages int64 `json:"sent_messages"`- FailedMessages int64 `json:"failed_messages"`- OpenedMessages int64 `json:"opened_messages"`- ClickedMessages int64 `json:"clicked_messages"`- BouncedMessages int64 `json:"bounced_messages"`- Unsubscribed int64 `json:"unsubscribed"`- DeliveryRate float64 `json:"delivery_rate"`- OpenRate float64 `json:"open_rate"`- ClickRate float64 `json:"click_rate"`- BounceRate float64 `json:"bounce_rate"`- UnsubscribeRate float64 `json:"unsubscribe_rate"`+ TotalMessages int64 `json:"total_messages"`+ SentMessages int64 `json:"sent_messages"`+ FailedMessages int64 `json:"failed_messages"`+ OpenedMessages int64 `json:"opened_messages"`+ ClickedMessages int64 `json:"clicked_messages"`+ BouncedMessages int64 `json:"bounced_messages"`+ Unsubscribed int64 `json:"unsubscribed"`+ DeliveryRate float64 `json:"delivery_rate"`+ OpenRate float64 `json:"open_rate"`+ ClickRate float64 `json:"click_rate"`+ BounceRate float64 `json:"bounce_rate"`+ UnsubscribeRate float64 `json:"unsubscribe_rate"`}func (r *TrackingRepository) CampaignAnalytics(campaignID uint) (*CampaignAnalytics, error) {@@ -172,14 +169,14 @@ func (r *TrackingRepository) EventTimeSeries(campaignID uint, eventType models.T// CampaignAnalyticsByVariant returns analytics grouped by A/B test variant.func (r *TrackingRepository) CampaignAnalyticsByVariant(campaignID uint) (map[string]*CampaignAnalytics, error) {type variantRow struct {- Variant string- TotalMessages int64- SentMessages int64- FailedMessages int64- OpenedMessages int64- ClickedMessages int64- BouncedMessages int64- Unsubscribed int64+ Variant string+ TotalMessages int64+ SentMessages int64+ FailedMessages int64+ OpenedMessages int64+ ClickedMessages int64+ BouncedMessages int64+ Unsubscribed int64}var rows []variantRowerr := r.db.Model(&models.CampaignMessage{}).diff --git a/internal/worker/campaign_processor.go b/internal/worker/campaign_processor.goindex 4fe703a..f6a40db 100644--- a/internal/worker/campaign_processor.go+++ b/internal/worker/campaign_processor.go@@ -24,14 +24,14 @@ import ("math/rand""time"- "github.com/hibiken/asynq"- "github.com/jkaninda/logger"- "github.com/jkaninda/okapi""github.com/goposta/posta/internal/models""github.com/goposta/posta/internal/services/email""github.com/goposta/posta/internal/services/tracking""github.com/goposta/posta/internal/services/webhook""github.com/goposta/posta/internal/storage/repositories"+ "github.com/hibiken/asynq"+ "github.com/jkaninda/logger"+ "github.com/jkaninda/okapi""github.com/lib/pq")diff --git a/internal/worker/handler.go b/internal/worker/handler.goindex 0788ae6..dd3f81b 100644--- a/internal/worker/handler.go+++ b/internal/worker/handler.go@@ -27,13 +27,13 @@ import ("strings""time"- "github.com/hibiken/asynq"- "github.com/jkaninda/logger""github.com/goposta/posta/internal/models""github.com/goposta/posta/internal/services/email""github.com/goposta/posta/internal/services/webhook""github.com/goposta/posta/internal/storage/blob""github.com/goposta/posta/internal/storage/repositories"+ "github.com/hibiken/asynq"+ "github.com/jkaninda/logger")// EmailSendHandler processes email:send tasks from the Asynq queue.diff --git a/web/src/stores/workspace.ts b/web/src/stores/workspace.tsindex 3935a02..4206978 100644--- a/web/src/stores/workspace.ts+++ b/web/src/stores/workspace.ts@@ -23,6 +23,11 @@ export const useWorkspaceStore = defineStore('workspace', () => {const isPersonal = computed(() => currentWorkspaceId.value === null)const isWorkspaceContext = computed(() => currentWorkspaceId.value !== null)const isWorkspaceAdmin = computed(() => currentRole.value === 'owner' || currentRole.value === 'admin')+ const canEdit = computed(() => {+ if (!currentWorkspaceId.value) return true // personal mode+ const role = currentRole.value+ return role === 'owner' || role === 'admin' || role === 'editor'+ })const contextLabel = computed(() => currentWorkspace.value?.name ?? 'Personal')@@ -61,6 +66,7 @@ export const useWorkspaceStore = defineStore('workspace', () => {isPersonal,isWorkspaceContext,isWorkspaceAdmin,+ canEdit,contextLabel,setWorkspace,fetchWorkspaces,diff --git a/web/src/views/apikeys/ApiKeys.vue b/web/src/views/apikeys/ApiKeys.vueindex 10ebafe..781326f 100644--- a/web/src/views/apikeys/ApiKeys.vue+++ b/web/src/views/apikeys/ApiKeys.vue@@ -6,8 +6,10 @@ import type { ApiKey, ApiKeyCreateResponse, Pageable } from '../../api/types'import { useNotificationStore } from '../../stores/notification'import { useConfirm } from '../../composables/useConfirm'import { useModalSafeClose } from '../../composables/useModalSafeClose';+import { useWorkspaceStore } from '../../stores/workspace'const notify = useNotificationStore()+const wsStore = useWorkspaceStore()const { confirm } = useConfirm()const keys = ref<ApiKey[]>([])@@ -170,7 +172,7 @@ onMounted(() => {<div><div class="page-header"><h1>API Keys</h1>- <button class="btn btn-primary" @click="showCreateModal = true">Create Key</button>+ <button v-if="wsStore.canEdit" class="btn btn-primary" @click="showCreateModal = true">Create Key</button></div><div v-if="loading" class="loading-page">@@ -218,14 +220,14 @@ onMounted(() => {<td><div style="display: flex; gap: 6px"><button- v-if="isActive(key)"+ v-if="wsStore.canEdit && isActive(key)"class="btn btn-warning btn-sm"@click="revokeKey(key)">Revoke</button><button- v-if="canDelete(key)"+ v-if="wsStore.canEdit && canDelete(key)"class="btn btn-danger btn-sm"@click="deleteKey(key)">diff --git a/web/src/views/campaigns/CampaignDetail.vue b/web/src/views/campaigns/CampaignDetail.vueindex 2c4442e..a4fdcbc 100644--- a/web/src/views/campaigns/CampaignDetail.vue+++ b/web/src/views/campaigns/CampaignDetail.vue@@ -5,10 +5,12 @@ import { campaignsApi } from '../../api/campaigns'import type { Campaign, CampaignMessage, CampaignMessageStatus, CampaignAnalyticsData, Pageable } from '../../api/types'import { useNotificationStore } from '../../stores/notification'import { useConfirm } from '../../composables/useConfirm'+import { useWorkspaceStore } from '../../stores/workspace'const route = useRoute()const router = useRouter()const notify = useNotificationStore()+const wsStore = useWorkspaceStore()const { confirm } = useConfirm()const campaignId = Number(route.params.id)@@ -221,11 +223,11 @@ onMounted(async () => {<h1 v-if="campaign">{{ campaign.name }}</h1></div><div v-if="campaign" style="display: flex; gap: 8px; align-items: flex-start;">- <button v-if="canSend" class="btn btn-primary" :disabled="actionLoading" @click="sendCampaign">Send</button>- <button v-if="canPause" class="btn btn-warning" :disabled="actionLoading" @click="pauseCampaign">Pause</button>- <button v-if="canResume" class="btn btn-primary" :disabled="actionLoading" @click="resumeCampaign">Resume</button>- <button v-if="canCancel" class="btn btn-danger" :disabled="actionLoading" @click="cancelCampaign">Cancel</button>- <button v-if="canDelete" class="btn btn-danger" @click="deleteCampaign">Delete</button>+ <button v-if="wsStore.canEdit && canSend" class="btn btn-primary" :disabled="actionLoading" @click="sendCampaign">Send</button>+ <button v-if="wsStore.canEdit && canPause" class="btn btn-warning" :disabled="actionLoading" @click="pauseCampaign">Pause</button>+ <button v-if="wsStore.canEdit && canResume" class="btn btn-primary" :disabled="actionLoading" @click="resumeCampaign">Resume</button>+ <button v-if="wsStore.canEdit && canCancel" class="btn btn-danger" :disabled="actionLoading" @click="cancelCampaign">Cancel</button>+ <button v-if="wsStore.canEdit && canDelete" class="btn btn-danger" @click="deleteCampaign">Delete</button></div></div>diff --git a/web/src/views/campaigns/Campaigns.vue b/web/src/views/campaigns/Campaigns.vueindex 0ffe982..20b5a54 100644--- a/web/src/views/campaigns/Campaigns.vue+++ b/web/src/views/campaigns/Campaigns.vue@@ -7,9 +7,11 @@ import type { Campaign, CampaignStatus, Pageable, SubscriberListItem } from '../import { useNotificationStore } from '../../stores/notification'import { useConfirm } from '../../composables/useConfirm'import { useModalSafeClose } from '../../composables/useModalSafeClose'+import { useWorkspaceStore } from '../../stores/workspace'const router = useRouter()const notify = useNotificationStore()+const wsStore = useWorkspaceStore()const { confirm } = useConfirm()const campaigns = ref<Campaign[]>([])@@ -167,7 +169,7 @@ onMounted(() => loadCampaigns())<div><div class="page-header"><h1>Campaigns</h1>- <button class="btn btn-primary" @click="openCreate">Create Campaign</button>+ <button v-if="wsStore.canEdit" class="btn btn-primary" @click="openCreate">Create Campaign</button></div><!-- Status filter tabs -->@@ -219,7 +221,7 @@ onMounted(() => loadCampaigns())<div style="display: flex; gap: 6px"><button class="btn btn-secondary btn-sm" @click="router.push(`/campaigns/${campaign.id}`)">View</button><button- v-if="campaign.status === 'draft' || campaign.status === 'cancelled'"+ v-if="wsStore.canEdit && (campaign.status === 'draft' || campaign.status === 'cancelled')"class="btn btn-danger btn-sm"@click="deleteCampaign(campaign)">Delete</button>diff --git a/web/src/views/contact-lists/ContactListMembers.vue b/web/src/views/contact-lists/ContactListMembers.vueindex 1928437..a67ade6 100644--- a/web/src/views/contact-lists/ContactListMembers.vue+++ b/web/src/views/contact-lists/ContactListMembers.vue@@ -6,10 +6,12 @@ import type { ContactListWithCount, ContactListMember, Pageable } from '../../apimport { useNotificationStore } from '../../stores/notification'import { useConfirm } from '../../composables/useConfirm'import { useModalSafeClose } from '../../composables/useModalSafeClose';+import { useWorkspaceStore } from '../../stores/workspace'const route = useRoute()const router = useRouter()const notify = useNotificationStore()+const wsStore = useWorkspaceStore()const { confirm } = useConfirm()const listId = Number(route.params.id)@@ -112,7 +114,7 @@ onMounted(async () => {<h1>{{ list?.name || 'Members' }}</h1><p v-if="list?.description" class="page-description">{{ list.description }}</p></div>- <button class="btn btn-primary" @click="openAddModal">Add Member</button>+ <button v-if="wsStore.canEdit" class="btn btn-primary" @click="openAddModal">Add Member</button></div><div v-if="loading" class="loading-page">@@ -141,7 +143,7 @@ onMounted(async () => {<td>{{ member.email }}</td><td>{{ member.name || '-' }}</td><td>{{ formatDate(member.created_at) }}</td>- <td>+ <td v-if="wsStore.canEdit"><button class="btn btn-danger btn-sm" @click="removeMember(member)">Remove</button></td></tr>diff --git a/web/src/views/contact-lists/ContactLists.vue b/web/src/views/contact-lists/ContactLists.vueindex 02fc45f..dd07369 100644--- a/web/src/views/contact-lists/ContactLists.vue+++ b/web/src/views/contact-lists/ContactLists.vue@@ -6,9 +6,11 @@ import type { ContactListWithCount, Pageable } from '../../api/types'import { useNotificationStore } from '../../stores/notification'import { useConfirm } from '../../composables/useConfirm'import { useModalSafeClose } from '../../composables/useModalSafeClose';+import { useWorkspaceStore } from '../../stores/workspace'const router = useRouter()const notify = useNotificationStore()+const wsStore = useWorkspaceStore()const { confirm } = useConfirm()const lists = ref<ContactListWithCount[]>([])@@ -103,7 +105,7 @@ onMounted(() => loadLists())<div><div class="page-header"><h1>Contact Lists</h1>- <button class="btn btn-primary" @click="openCreate">Create List</button>+ <button v-if="wsStore.canEdit" class="btn btn-primary" @click="openCreate">Create List</button></div><div v-if="loading" class="loading-page">@@ -139,8 +141,8 @@ onMounted(() => loadLists())<td><div style="display: flex; gap: 6px"><button class="btn btn-secondary btn-sm" @click="openMembers(list)">Members</button>- <button class="btn btn-secondary btn-sm" @click="openEdit(list)">Edit</button>- <button class="btn btn-danger btn-sm" @click="deleteList(list)">Delete</button>+ <button v-if="wsStore.canEdit" class="btn btn-secondary btn-sm" @click="openEdit(list)">Edit</button>+ <button v-if="wsStore.canEdit" class="btn btn-danger btn-sm" @click="deleteList(list)">Delete</button></div></td></tr>diff --git a/web/src/views/contacts/ContactDetail.vue b/web/src/views/contacts/ContactDetail.vueindex 563d76e..492d254 100644--- a/web/src/views/contacts/ContactDetail.vue+++ b/web/src/views/contacts/ContactDetail.vue@@ -8,10 +8,12 @@ import type { Contact, ContactListWithCount } from '../../api/types'import { useNotificationStore } from '../../stores/notification'import { useConfirm } from '../../composables/useConfirm'import { useModalSafeClose } from '../../composables/useModalSafeClose';+import { useWorkspaceStore } from '../../stores/workspace'const route = useRoute()const router = useRouter()const notify = useNotificationStore()+const wsStore = useWorkspaceStore()const { confirm } = useConfirm()const loading = ref(true)@@ -155,9 +157,9 @@ const { watchClickStart, confirmClickEnd } = useModalSafeClose(() => {<h2>Actions</h2></div><div class="card-body" style="display: flex; gap: 8px">- <button class="btn btn-secondary" @click="openAddToList">Add to List</button>+ <button v-if="wsStore.canEdit" class="btn btn-secondary" @click="openAddToList">Add to List</button><button- v-if="!contact.suppressed"+ v-if="wsStore.canEdit && !contact.suppressed"class="btn btn-danger":disabled="suppressingEmail === contact.email"@click="suppressContact"diff --git a/web/src/views/contacts/Contacts.vue b/web/src/views/contacts/Contacts.vueindex 65b81bd..3741a60 100644--- a/web/src/views/contacts/Contacts.vue+++ b/web/src/views/contacts/Contacts.vue@@ -10,9 +10,11 @@ import { usePagination } from '../../composables/usePagination'import { useNotificationStore } from '../../stores/notification'import { useConfirm } from '../../composables/useConfirm'import { useModalSafeClose } from '../../composables/useModalSafeClose';+import { useWorkspaceStore } from '../../stores/workspace'const router = useRouter()const notify = useNotificationStore()+const wsStore = useWorkspaceStore()const { confirm } = useConfirm()const contacts = ref<Contact[]>([])@@ -159,9 +161,9 @@ const { watchClickStart, confirmClickEnd } = useModalSafeClose(() => {<td>{{ formatDate(contact.created_at) }}</td><td><div style="display: flex; gap: 6px; white-space: nowrap" @click.stop>- <button class="btn btn-secondary btn-sm" @click="openAddToList(contact)">Add to List</button>+ <button v-if="wsStore.canEdit" class="btn btn-secondary btn-sm" @click="openAddToList(contact)">Add to List</button><button- v-if="!contact.suppressed"+ v-if="wsStore.canEdit && !contact.suppressed"class="btn btn-danger btn-sm":disabled="suppressingEmail === contact.email"@click="suppressContact(contact)"diff --git a/web/src/views/domains/Domains.vue b/web/src/views/domains/Domains.vueindex 98ddd0f..402188a 100644--- a/web/src/views/domains/Domains.vue+++ b/web/src/views/domains/Domains.vue@@ -5,8 +5,10 @@ import type { Domain, Pageable } from '../../api/types'import { useNotificationStore } from '../../stores/notification'import { useConfirm } from '../../composables/useConfirm'import { useModalSafeClose } from '../../composables/useModalSafeClose';+import { useWorkspaceStore } from '../../stores/workspace'const notify = useNotificationStore()+const wsStore = useWorkspaceStore()const { confirm } = useConfirm()const domains = ref<Domain[]>([])@@ -124,7 +126,7 @@ onMounted(fetchDomains)<div><div class="page-header"><h1>Domains</h1>- <button class="btn btn-primary" @click="showAddModal = true">Add Domain</button>+ <button v-if="wsStore.canEdit" class="btn btn-primary" @click="showAddModal = true">Add Domain</button></div><div v-if="loading" class="loading-page">@@ -167,11 +169,11 @@ onMounted(fetchDomains)</td><td><div class="flex gap-2">- <button class="btn btn-secondary btn-sm" @click="verifyDomain(domain)">Verify</button>+ <button v-if="wsStore.canEdit" class="btn btn-secondary btn-sm" @click="verifyDomain(domain)">Verify</button><button class="btn btn-secondary btn-sm" @click="viewDnsRecords(domain)">{{ expandedDomainId === domain.id ? 'Hide DNS' : 'View DNS Records' }}</button>- <button class="btn btn-danger btn-sm" @click="deleteDomain(domain)">Delete</button>+ <button v-if="wsStore.canEdit" class="btn btn-danger btn-sm" @click="deleteDomain(domain)">Delete</button></div></td></tr>diff --git a/web/src/views/languages/Languages.vue b/web/src/views/languages/Languages.vueindex 826b99b..91ce077 100644--- a/web/src/views/languages/Languages.vue+++ b/web/src/views/languages/Languages.vue@@ -5,8 +5,10 @@ import type { Language, LanguageInput, Pageable } from '../../api/types'import { useNotificationStore } from '../../stores/notification'import { useConfirm } from '../../composables/useConfirm'import { useModalSafeClose } from '../../composables/useModalSafeClose';+import { useWorkspaceStore } from '../../stores/workspace'const notify = useNotificationStore()+const wsStore = useWorkspaceStore()const { confirm } = useConfirm()const languages = ref<Language[]>([])@@ -111,7 +113,7 @@ onMounted(() => loadLanguages())<div><div class="page-header"><h1>Languages</h1>- <button class="btn btn-primary" @click="openCreate">Add Language</button>+ <button v-if="wsStore.canEdit" class="btn btn-primary" @click="openCreate">Add Language</button></div><div v-if="loading" class="loading-page">@@ -144,8 +146,8 @@ onMounted(() => loadLanguages())<td>{{ formatDate(lang.created_at) }}</td><td><div class="flex gap-2">- <button class="btn btn-secondary btn-sm" @click="openEdit(lang)">Edit</button>- <button class="btn btn-danger btn-sm" @click="deleteLanguage(lang)">Delete</button>+ <button v-if="wsStore.canEdit" class="btn btn-secondary btn-sm" @click="openEdit(lang)">Edit</button>+ <button v-if="wsStore.canEdit" class="btn btn-danger btn-sm" @click="deleteLanguage(lang)">Delete</button></div></td></tr>diff --git a/web/src/views/smtp/SmtpServers.vue b/web/src/views/smtp/SmtpServers.vueindex 6a2a0eb..f9f1f0c 100644--- a/web/src/views/smtp/SmtpServers.vue+++ b/web/src/views/smtp/SmtpServers.vue@@ -6,9 +6,11 @@ import type { SmtpServer, SmtpServerInput, Pageable } from '../../api/types'import { useNotificationStore } from '../../stores/notification'import { useConfirm } from '../../composables/useConfirm'import { useModalSafeClose } from '../../composables/useModalSafeClose';+import { useWorkspaceStore } from '../../stores/workspace'const router = useRouter()const notify = useNotificationStore()+const wsStore = useWorkspaceStore()const { confirm } = useConfirm()const servers = ref<SmtpServer[]>([])@@ -130,7 +132,7 @@ onMounted(fetchServers)<div><div class="page-header"><h1>SMTP Servers</h1>- <button class="btn btn-primary" @click="openCreate">Add Server</button>+ <button v-if="wsStore.canEdit" class="btn btn-primary" @click="openCreate">Add Server</button></div><div v-if="loading" class="loading-page">@@ -178,8 +180,8 @@ onMounted(fetchServers)<td><div class="flex gap-2"><button class="btn btn-secondary btn-sm" @click="router.push(`/smtp-servers/${server.id}`)">View</button>- <button class="btn btn-secondary btn-sm" @click="openEdit(server)">Edit</button>- <button class="btn btn-danger btn-sm" @click="deleteServer(server)">Delete</button>+ <button v-if="wsStore.canEdit" class="btn btn-secondary btn-sm" @click="openEdit(server)">Edit</button>+ <button v-if="wsStore.canEdit" class="btn btn-danger btn-sm" @click="deleteServer(server)">Delete</button></div></td></tr>diff --git a/web/src/views/stylesheets/Stylesheets.vue b/web/src/views/stylesheets/Stylesheets.vueindex 9b4659f..77cb4c7 100644--- a/web/src/views/stylesheets/Stylesheets.vue+++ b/web/src/views/stylesheets/Stylesheets.vue@@ -5,8 +5,10 @@ import type { StyleSheet, StyleSheetInput, Pageable } from '../../api/types'import { useNotificationStore } from '../../stores/notification'import { useConfirm } from '../../composables/useConfirm'import { useModalSafeClose } from '../../composables/useModalSafeClose';+import { useWorkspaceStore } from '../../stores/workspace'const notify = useNotificationStore()+const wsStore = useWorkspaceStore()const { confirm } = useConfirm()const stylesheets = ref<StyleSheet[]>([])@@ -109,7 +111,7 @@ onMounted(() => loadStylesheets())<div><div class="page-header"><h1>Stylesheets</h1>- <button class="btn btn-primary" @click="openCreate">Create Stylesheet</button>+ <button v-if="wsStore.canEdit" class="btn btn-primary" @click="openCreate">Create Stylesheet</button></div><div v-if="loading" class="loading-page">@@ -143,8 +145,8 @@ onMounted(() => loadStylesheets())</td><td><div class="flex gap-2">- <button class="btn btn-secondary btn-sm" @click="openEdit(sheet)">Edit</button>- <button class="btn btn-danger btn-sm" @click="deleteStylesheet(sheet)">Delete</button>+ <button v-if="wsStore.canEdit" class="btn btn-secondary btn-sm" @click="openEdit(sheet)">Edit</button>+ <button v-if="wsStore.canEdit" class="btn btn-danger btn-sm" @click="deleteStylesheet(sheet)">Delete</button></div></td></tr>diff --git a/web/src/views/subscriber-lists/SubscriberListDetail.vue b/web/src/views/subscriber-lists/SubscriberListDetail.vueindex 34a6623..ea73a19 100644--- a/web/src/views/subscriber-lists/SubscriberListDetail.vue+++ b/web/src/views/subscriber-lists/SubscriberListDetail.vue@@ -7,10 +7,12 @@ import type { SubscriberListItem, Subscriber, FilterRule, Pageable } from '../..import { useNotificationStore } from '../../stores/notification'import { useConfirm } from '../../composables/useConfirm'import { useModalSafeClose } from '../../composables/useModalSafeClose'+import { useWorkspaceStore } from '../../stores/workspace'const route = useRoute()const router = useRouter()const notify = useNotificationStore()+const wsStore = useWorkspaceStore()const { confirm } = useConfirm()const listId = Number(route.params.id)@@ -185,7 +187,7 @@ onMounted(async () => {<h1>{{ list?.name || 'List Detail' }}</h1><p v-if="list?.description" class="page-description">{{ list.description }}</p></div>- <button v-if="!isDynamic" class="btn btn-primary" @click="openAddMember">Add Member</button>+ <button v-if="!isDynamic && wsStore.canEdit" class="btn btn-primary" @click="openAddMember">Add Member</button></div><!-- Edit Details -->@@ -202,7 +204,7 @@ onMounted(async () => {<label class="form-label">Description</label><input v-model="editDescription" class="form-input" /></div>- <div style="margin-top: 12px">+ <div v-if="wsStore.canEdit" style="margin-top: 12px"><button class="btn btn-primary" :disabled="saving || !editName.trim()" @click="saveDetails">{{ saving ? 'Saving...' : 'Save' }}</button>@@ -306,7 +308,7 @@ onMounted(async () => {<td>{{ member.name || '-' }}</td><td><span :class="statusBadgeClass(member.status)">{{ member.status }}</span></td><td>{{ formatDate(member.created_at) }}</td>- <td>+ <td v-if="wsStore.canEdit"><button class="btn btn-danger btn-sm" @click="removeMember(member)">Remove</button></td></tr>diff --git a/web/src/views/subscriber-lists/SubscriberLists.vue b/web/src/views/subscriber-lists/SubscriberLists.vueindex 04a98d3..48f3ed1 100644--- a/web/src/views/subscriber-lists/SubscriberLists.vue+++ b/web/src/views/subscriber-lists/SubscriberLists.vue@@ -6,9 +6,11 @@ import type { SubscriberListItem, SubscriberListType, FilterRule, Pageable } froimport { useNotificationStore } from '../../stores/notification'import { useConfirm } from '../../composables/useConfirm'import { useModalSafeClose } from '../../composables/useModalSafeClose'+import { useWorkspaceStore } from '../../stores/workspace'const router = useRouter()const notify = useNotificationStore()+const wsStore = useWorkspaceStore()const { confirm } = useConfirm()const lists = ref<SubscriberListItem[]>([])@@ -119,7 +121,7 @@ onMounted(() => loadLists())<div><div class="page-header"><h1>Lists</h1>- <button class="btn btn-primary" @click="openCreate">Create List</button>+ <button v-if="wsStore.canEdit" class="btn btn-primary" @click="openCreate">Create List</button></div><div v-if="loading" class="loading-page">@@ -155,7 +157,7 @@ onMounted(() => loadLists())<td><div style="display: flex; gap: 6px"><button class="btn btn-secondary btn-sm" @click="router.push(`/subscriber-lists/${list.id}`)">View</button>- <button class="btn btn-danger btn-sm" @click="deleteList(list)">Delete</button>+ <button v-if="wsStore.canEdit" class="btn btn-danger btn-sm" @click="deleteList(list)">Delete</button></div></td></tr>diff --git a/web/src/views/subscribers/SubscriberDetail.vue b/web/src/views/subscribers/SubscriberDetail.vueindex a302a9a..929c0d0 100644--- a/web/src/views/subscribers/SubscriberDetail.vue+++ b/web/src/views/subscribers/SubscriberDetail.vue@@ -5,10 +5,12 @@ import { subscribersApi } from '../../api/subscribers'import type { Subscriber, SubscriberStatus } from '../../api/types'import { useNotificationStore } from '../../stores/notification'import { useConfirm } from '../../composables/useConfirm'+import { useWorkspaceStore } from '../../stores/workspace'const route = useRoute()const router = useRouter()const notify = useNotificationStore()+const wsStore = useWorkspaceStore()const { confirm } = useConfirm()const loading = ref(true)@@ -147,7 +149,7 @@ const customFieldEntries = (fields: Record<string, any>) => {<label class="form-label">Custom Fields (JSON)</label><textarea v-model="editForm.custom_fields" class="form-input" rows="6"></textarea></div>- <div style="display: flex; gap: 8px; margin-top: 16px">+ <div v-if="wsStore.canEdit" style="display: flex; gap: 8px; margin-top: 16px"><button class="btn btn-primary" :disabled="saving" @click="saveSubscriber">{{ saving ? 'Saving...' : 'Save Changes' }}</button>diff --git a/web/src/views/subscribers/Subscribers.vue b/web/src/views/subscribers/Subscribers.vueindex 7c09149..ceb72f4 100644--- a/web/src/views/subscribers/Subscribers.vue+++ b/web/src/views/subscribers/Subscribers.vue@@ -7,9 +7,11 @@ import Pagination from '../../components/Pagination.vue'import { usePagination } from '../../composables/usePagination'import { useNotificationStore } from '../../stores/notification'import { useModalSafeClose } from '../../composables/useModalSafeClose'+import { useWorkspaceStore } from '../../stores/workspace'const router = useRouter()const notify = useNotificationStore()+const wsStore = useWorkspaceStore()const subscribers = ref<Subscriber[]>([])const loading = ref(true)@@ -168,7 +170,7 @@ const { watchClickStart: watchImportStart, confirmClickEnd: confirmImportEnd } =<div><div class="page-header"><h1>Subscribers</h1>- <div style="display: flex; gap: 8px">+ <div v-if="wsStore.canEdit" style="display: flex; gap: 8px"><button class="btn btn-secondary" @click="openImportJson">Import JSON</button><button class="btn btn-secondary" :disabled="importingCsv" @click="triggerCsvUpload">{{ importingCsv ? 'Importing...' : 'Import CSV' }}diff --git a/web/src/views/templates/TemplateDetail.vue b/web/src/views/templates/TemplateDetail.vueindex c9fc5a9..8f42410 100644--- a/web/src/views/templates/TemplateDetail.vue+++ b/web/src/views/templates/TemplateDetail.vue@@ -16,10 +16,12 @@ import type {import { useNotificationStore } from "../../stores/notification";import { useConfirm } from "../../composables/useConfirm";import { useModalSafeClose } from "../../composables/useModalSafeClose";+import { useWorkspaceStore } from "../../stores/workspace";const route = useRoute();const router = useRouter();const notify = useNotificationStore();+const wsStore = useWorkspaceStore();const { confirm } = useConfirm();const templateId = Number(route.params.id);@@ -469,7 +471,7 @@ onMounted(loadAll);<div class="card" style="margin-bottom: 24px"><div class="card-header"><h2>Versions</h2>- <div class="flex gap-2 align-center">+ <div v-if="wsStore.canEdit" class="flex gap-2 align-center"><select v-model="newVersionStylesheetId" class="form-select form-select-sm"><option :value="null">No stylesheet</option><option v-for="ss in stylesheets" :key="ss.id" :value="ss.id">@@ -526,20 +528,21 @@ onMounted(loadAll);<td><div class="flex gap-2" @click.stop><button+ v-if="wsStore.canEdit"class="btn btn-secondary btn-sm"@click="openEditVersionStylesheet(v)">Edit</button><button- v-if="!isActive(v)"+ v-if="wsStore.canEdit && !isActive(v)"class="btn btn-primary btn-sm"@click="activateVersion(v)">Activate</button><button- v-if="!isActive(v)"+ v-if="wsStore.canEdit && !isActive(v)"class="btn btn-danger btn-sm"@click="deleteVersion(v)">@@ -557,7 +560,7 @@ onMounted(loadAll);<div v-if="selectedVersion" class="card"><div class="card-header"><h2>Localizations — v{{ selectedVersion.version }}</h2>- <button class="btn btn-primary btn-sm" @click="openCreateLoc">+ <button v-if="wsStore.canEdit" class="btn btn-primary btn-sm" @click="openCreateLoc">Add Language</button></div>@@ -603,15 +606,16 @@ onMounted(loadAll);Preview</button><button+ v-if="wsStore.canEdit"class="btn btn-secondary btn-sm"@click="router.push(`/templates/${templateId}/versions/${selectedVersion?.id}/localizations/${l.id}/edit`)">Editor</button>- <button class="btn btn-secondary btn-sm" @click="openEditLoc(l)">+ <button v-if="wsStore.canEdit" class="btn btn-secondary btn-sm" @click="openEditLoc(l)">Quick Edit</button>- <button class="btn btn-danger btn-sm" @click="deleteLoc(l)">+ <button v-if="wsStore.canEdit" class="btn btn-danger btn-sm" @click="deleteLoc(l)">Delete</button></div>diff --git a/web/src/views/templates/Templates.vue b/web/src/views/templates/Templates.vueindex c71ca70..fcc3e51 100644--- a/web/src/views/templates/Templates.vue+++ b/web/src/views/templates/Templates.vue@@ -13,9 +13,11 @@ import type {import { useNotificationStore } from "../../stores/notification";import { useConfirm } from "../../composables/useConfirm";import { useModalSafeClose } from "../../composables/useModalSafeClose";+import { useWorkspaceStore } from "../../stores/workspace";const router = useRouter();const notify = useNotificationStore();+const wsStore = useWorkspaceStore();const { confirm } = useConfirm();const templates = ref<Template[]>([]);@@ -208,10 +210,10 @@ onMounted(() => {style="display: none"@change="handleImportFile"/>- <button class="btn btn-secondary" :disabled="importing" @click="triggerImport">+ <button v-if="wsStore.canEdit" class="btn btn-secondary" :disabled="importing" @click="triggerImport">{{ importing ? "Importing..." : "Import" }}</button>- <button class="btn btn-primary" @click="openCreate">Create Template</button>+ <button v-if="wsStore.canEdit" class="btn btn-primary" @click="openCreate">Create Template</button></div></div>@@ -278,7 +280,7 @@ onMounted(() => {>Preview</button>- <button class="btn btn-secondary btn-sm" @click.stop="openEdit(tmpl)">+ <button v-if="wsStore.canEdit" class="btn btn-secondary btn-sm" @click.stop="openEdit(tmpl)">Edit</button><button@@ -288,6 +290,7 @@ onMounted(() => {Export</button><button+ v-if="wsStore.canEdit"class="btn btn-danger btn-sm"@click.stop="deleteTemplate(tmpl)">diff --git a/web/src/views/webhooks/Webhooks.vue b/web/src/views/webhooks/Webhooks.vueindex 2a6ca5a..43eea4d 100644--- a/web/src/views/webhooks/Webhooks.vue+++ b/web/src/views/webhooks/Webhooks.vue@@ -7,8 +7,10 @@ import { usePagination } from '../../composables/usePagination'import { useNotificationStore } from '../../stores/notification'import { useConfirm } from '../../composables/useConfirm'import { useModalSafeClose } from '../../composables/useModalSafeClose';+import { useWorkspaceStore } from '../../stores/workspace'const notify = useNotificationStore()+const wsStore = useWorkspaceStore()const { confirm } = useConfirm()const webhooks = ref<Webhook[]>([])@@ -134,7 +136,7 @@ const { watchClickStart, confirmClickEnd } = useModalSafeClose(() => {<div><div class="page-header"><h1>Webhooks</h1>- <button class="btn btn-primary" @click="openCreate">Add Webhook</button>+ <button v-if="wsStore.canEdit" class="btn btn-primary" @click="openCreate">Add Webhook</button></div><div v-if="loading" class="loading-page">@@ -174,7 +176,7 @@ const { watchClickStart, confirmClickEnd } = useModalSafeClose(() => {</td><td>{{ formatDate(webhook.created_at) }}</td><td>- <button class="btn btn-danger btn-sm" @click="deleteWebhook(webhook)">Delete</button>+ <button v-if="wsStore.canEdit" class="btn btn-danger btn-sm" @click="deleteWebhook(webhook)">Delete</button></td></tr></tbody>