Initial commit: Open sourcing all of the Maple Open Technologies code.
This commit is contained in:
commit
755d54a99d
2010 changed files with 448675 additions and 0 deletions
|
|
@ -0,0 +1,36 @@
|
|||
// Package inviteemailratelimit provides rate limiting for invitation emails
|
||||
// using Cassandra counter tables.
|
||||
package inviteemailratelimit
|
||||
|
||||
import (
|
||||
"context"
|
||||
"time"
|
||||
|
||||
"github.com/gocql/gocql"
|
||||
"go.uber.org/zap"
|
||||
|
||||
"codeberg.org/mapleopentech/monorepo/cloud/maplefile-backend/config"
|
||||
)
|
||||
|
||||
// Repository defines the interface for invite email rate limiting
|
||||
type Repository interface {
|
||||
// GetDailyEmailCount returns the number of invitation emails sent by a user today
|
||||
GetDailyEmailCount(ctx context.Context, userID gocql.UUID, date time.Time) (int, error)
|
||||
// IncrementDailyEmailCount increments the counter for emails sent today
|
||||
IncrementDailyEmailCount(ctx context.Context, userID gocql.UUID, date time.Time) error
|
||||
}
|
||||
|
||||
type repositoryImpl struct {
|
||||
logger *zap.Logger
|
||||
session *gocql.Session
|
||||
}
|
||||
|
||||
// NewRepository creates a new invite email rate limit repository
|
||||
func NewRepository(appCfg *config.Configuration, session *gocql.Session, logger *zap.Logger) Repository {
|
||||
logger = logger.Named("InviteEmailRateLimitRepository")
|
||||
|
||||
return &repositoryImpl{
|
||||
logger: logger,
|
||||
session: session,
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue