models

package
v0.1.0-rc.8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 12, 2025 License: AGPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ValidPurchaseTypes = []string{
	"REVENUE_CAT",
}

ValidPurchaseTypes is used in validators.go

Functions

func RegisterValidators

func RegisterValidators()

RegisterValidators registers custom validators for the models

func ValidatePurchaseType

func ValidatePurchaseType(fl validator.FieldLevel) bool

ValidatePurchaseType checks if the purchase type is in the allowed list

Types

type Attribute

type Attribute struct {
	UpdatedAtMs int64  `json:"updated_at_ms"`
	Value       string `json:"value"`
}

Attribute represents a subscriber attribute in RevenueCat

type EncryptionKey

type EncryptionKey struct {
	UserKey      string `json:"userKey" bson:"user_key"`
	BackupKey    string `json:"backupKey" bson:"backup_key"`
	Salt         string `json:"salt" bson:"salt"`
	MnemonicSalt string `json:"mnemonicSalt" bson:"mnemonic_salt"`
}

EncryptionKey represents the structure for encryption keys for a user

type Folder

type Folder struct {
	ID        *primitive.ObjectID `bson:"_id" json:"id"`
	Name      string              `bson:"name" json:"name" binding:"required"`
	Color     *string             `bson:"color" json:"color"`
	ParentID  *primitive.ObjectID `bson:"parent_id" json:"parentId"`
	UserID    primitive.ObjectID  `bson:"user_id" json:"userId"`
	Emoji     *string             `bson:"emoji" json:"emoji"`
	CreatedAt *primitive.DateTime `bson:"created_at,omitempty" json:"createdAt,omitempty"`
	UpdatedAt *primitive.DateTime `bson:"updated_at,omitempty" json:"updatedAt,omitempty"`
}

Folder represents a folder in the application

type Mail

type Mail struct {
	ID             *primitive.ObjectID `bson:"_id,omitempty" json:"id,omitempty"`
	UserID         primitive.ObjectID  `bson:"user_id" json:"user_id"`
	Headers        interface{}         `bson:"headers" json:"headers"`
	TextContent    string              `bson:"text_content" json:"text_content"`
	HTMLContent    string              `bson:"html_content" json:"html_content"`
	Attachments    []MailAttachment    `bson:"attachments,omitempty" json:"attachments,omitempty"`
	Archived       *bool               `bson:"archived,omitempty" json:"archived,omitempty"`
	Trashed        *bool               `bson:"trashed,omitempty" json:"trashed,omitempty"`
	Greylisted     *bool               `bson:"graylisted,omitempty" json:"graylisted,omitempty"`
	Rejected       *bool               `bson:"rejected,omitempty" json:"rejected,omitempty"`
	RewriteSubject *bool               `bson:"rewrite_subject,omitempty" json:"rewrite_subject,omitempty"`
	CreatedAt      *primitive.DateTime `bson:"created_at,omitempty" json:"created_at,omitempty"`
	UpdatedAt      *primitive.DateTime `bson:"updated_at,omitempty" json:"updated_at,omitempty"`
}

Mail represents a mail message

func (*Mail) Encrypt

func (s *Mail) Encrypt(publicKey string) (*Mail, error)

Encrypt encrypts the mail data

type MailAttachment

type MailAttachment struct {
	Filename    string `bson:"filename" json:"filename"`
	ContentType string `bson:"content_type" json:"content_type"`
	StoragePath string `bson:"storage_path" json:"storage_path"` // S3 storage key/reference
	StorageType string `bson:"storage_type" json:"storage_type"` // S3, MongoDB, etc.
	Size        int64  `bson:"size" json:"size"`                 // File size in bytes
}

MailAttachment represents a file attachment

type PurchaseEntity

type PurchaseEntity struct {
	ID           primitive.ObjectID     `json:"id" bson:"_id,omitempty"`
	Type         *string                `json:"type" bson:"type" binding:"required,validPurchaseType"`
	PurchaseData RevenueCatPurchaseData `json:"purchaseData" bson:"purchase_data"`
	CreatedAt    primitive.DateTime     `json:"createdAt" bson:"created_at"`
	UpdatedAt    primitive.DateTime     `json:"updatedAt" bson:"updated_at"`
}

PurchaseEntity represents a generic purchase record

func NewRevenueCatPurchase

func NewRevenueCatPurchase(rcData RevenueCatPurchaseData) PurchaseEntity

NewRevenueCatPurchase creates a new PurchaseEntity with RevenueCat data

type RawAttachment

type RawAttachment struct {
	Filename    string
	ContentType string
	Data        []byte
}

RawAttachment represents a file attachment

type RawMail

type RawMail struct {
	Headers        map[string]interface{} `json:"headers" binding:"required"`
	TextContent    string                 `json:"text_content"`
	HTMLContent    string                 `json:"html_content"`
	Attachments    []RawAttachment        `json:"attachments"`
	Rejected       bool                   `json:"rejected"`
	RewriteSubject bool                   `json:"rewrite_subject"`
	Greylisted     bool                   `json:"graylisted"`
}

RawMail represents the collected content from an email

func (*RawMail) Encrypt

func (m *RawMail) Encrypt(publicKey string) (*RawMail, error)

Encrypt encrypts the content using the age encryption library

func (*RawMail) ToMailEntity

func (m *RawMail) ToMailEntity() *Mail

ToMailEntity converts a RawMail to a Mail entity

func (*RawMail) ToMessageEntity

func (m *RawMail) ToMessageEntity() (*message.Entity, error)

ToMessageEntity creates a proper email message using go-message library

type RevenueCatPayload

type RevenueCatPayload struct {
	APIVersion string                 `json:"api_version"`
	Event      RevenueCatPurchaseData `json:"event"`
}

RevenueCatPayload represents the structure of a RevenueCat webhook payload

type RevenueCatPurchaseData

type RevenueCatPurchaseData struct {
	Aliases                  []string             `json:"aliases"`
	AppID                    string               `json:"app_id"`
	AppUserID                string               `json:"app_user_id"`
	CommissionPercentage     float64              `json:"commission_percentage"`
	CountryCode              string               `json:"country_code"`
	Currency                 string               `json:"currency"`
	EntitlementID            string               `json:"entitlement_id"`
	EntitlementIDs           []string             `json:"entitlement_ids"`
	Environment              string               `json:"environment"`
	EventTimestampMs         int64                `json:"event_timestamp_ms"`
	ExpirationAtMs           int64                `json:"expiration_at_ms"`
	ID                       string               `json:"id"`
	IsFamilyShare            bool                 `json:"is_family_share"`
	OfferCode                string               `json:"offer_code"`
	OriginalAppUserID        string               `json:"original_app_user_id"`
	OriginalTransactionID    string               `json:"original_transaction_id"`
	PeriodType               string               `json:"period_type"`
	PresentedOfferingID      string               `json:"presented_offering_id"`
	Price                    float64              `json:"price"`
	PriceInPurchasedCurrency float64              `json:"price_in_purchased_currency"`
	ProductID                string               `json:"product_id"`
	PurchasedAtMs            int64                `json:"purchased_at_ms"`
	Store                    string               `json:"store"`
	SubscriberAttributes     map[string]Attribute `json:"subscriber_attributes"`
	TakehomePercentage       float64              `json:"takehome_percentage"`
	TaxPercentage            float64              `json:"tax_percentage"`
	TransactionID            string               `json:"transaction_id"`
	Type                     string               `json:"type"`
}

RevenueCatPurchaseData represents RevenueCat specific purchase data

type SendMail

type SendMail struct {
	ID            primitive.ObjectID  `bson:"_id" json:"id"`
	Mail          *Mail               `bson:"mail" json:"mail"`
	SendStatus    SendStatus          `bson:"send_status" json:"send_status"`
	RetryCounter  *int                `bson:"retry_counter" json:"retry_counter"`
	FailureReason *string             `bson:"failure_reason" json:"failure_reason"`
	FailedAt      *primitive.DateTime `bson:"failed_at" json:"failed_at"`
	Trashed       bool                `bson:"trashed" json:"trashed"`
	CreatedAt     *primitive.DateTime `bson:"created_at" json:"created_at"`
	UpdatedAt     *primitive.DateTime `bson:"updated_at" json:"updated_at"`
}

SendMail represents a mail that has been sent or is queued to be sent

type SendStatus

type SendStatus string

SendStatus represents the status of a sent mail

const (
	// SendStatusPending represents a mail that is pending to be sent
	SendStatusPending SendStatus = "pending"
	// SendStatusSent represents a mail that has been sent
	SendStatusSent SendStatus = "sent"
	// SendStatusFailed represents a mail that has failed to be sent
	SendStatusFailed SendStatus = "failed"
	// SendStatusRetry represents a mail that has failed to be sent and is being retried
	SendStatusRetry SendStatus = "retry"
)

type Tag

type Tag struct {
	ID        *primitive.ObjectID `json:"id" bson:"_id,omitempty"`
	UserID    *primitive.ObjectID `json:"userId" bson:"user_id,omitempty"`
	Name      string              `json:"name" bson:"name" binding:"required"`
	Color     *string             `json:"color" bson:"color"`
	CreatedAt *primitive.DateTime `json:"createdAt" bson:"created_at"`
	UpdatedAt *primitive.DateTime `json:"updatedAt" bson:"updated_at"`
}

Tag represents a tag associated with a task

type UserDevice

type UserDevice struct {
	DeviceID       string  `json:"deviceId" bson:"device_id" binding:"required"`
	DeviceName     string  `json:"deviceName" bson:"device_name" binding:"required"`
	FcmToken       string  `json:"fcmToken" bson:"fcm_token" binding:"required"`
	DeviceTimezone *string `json:"deviceTimezone" bson:"device_timezone"`
}

UserDevice represents a user's device information for push notifications.

type UserEntity

type UserEntity struct {
	ID                *primitive.ObjectID   `json:"id" bson:"_id"`
	Email             *string               `json:"email" bson:"email" binding:"required"`
	Password          *string               `json:"password,omitempty" bson:"password" binding:"required"`
	KeySet            *EncryptionKey        `json:"keySet,omitempty" bson:"key_set" binding:"required"`
	RoleIds           []*primitive.ObjectID `json:"-" bson:"role_ids"`
	Roles             []*UserRoleEntity     `json:"roles" bson:"roles,omitempty"`
	ResetPasswordCode *string               `json:"resetPasswordCode,omitempty" bson:"reset_password_code"`
	Devices           []*UserDevice         `json:"devices" bson:"devices,omitempty"`
	Purchases         []*PurchaseEntity     `json:"purchases" bson:"purchases,omitempty"`
	CreatedAt         *primitive.DateTime   `json:"createdAt" bson:"created_at"`
	UpdatedAt         *primitive.DateTime   `json:"updatedAt" bson:"updated_at"`
}

UserEntity represents a user in the system @Summary User entity @Description Represents a user in the system

type UserRoleEntity

type UserRoleEntity struct {
	ID        *primitive.ObjectID `json:"id" bson:"_id"`
	Name      string              `json:"name" bson:"name" binding:"required"`
	CreatedAt *primitive.DateTime `json:"createdAt" bson:"created_at"`
	UpdatedAt *primitive.DateTime `json:"updatedAt" bson:"updated_at"`
}

UserRoleEntity represents a user role in the system @Summary User role entity @Description Represents a user role in the system

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL