Help us shape the future of Go! Take the 2026 Go Developer Survey

invitation

package
v0.5.13 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2025 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Overview

Package invitation provides local invitation cache management for Prism v0.5.11+

This file implements a local cache for storing received invitation tokens, allowing users to manage multiple invitations without dealing with long tokens.

Package invitation provides invitation management for Prism v0.5.11+

This package implements the user invitation system enabling project owners to invite collaborators with role-based permissions.

Package invitation provides file parsing utilities for bulk invitations

This file implements CSV and plain text parsing for bulk invitation operations, supporting both simple email lists and structured CSV formats with roles and messages.

Package invitation provides shared token management for Prism v0.5.13+

This file implements the shared token system for workshop and conference scenarios where a single token code can be redeemed by multiple users up to a limit.

Index

Constants

View Source
const DefaultExpirationDays = 7

DefaultExpirationDays is the default invitation expiration in days

Variables

This section is empty.

Functions

func FormatSummary

func FormatSummary(response *types.BulkInvitationResponse) string

FormatSummary formats bulk invitation results as a human-readable summary

func ParseCSV

func ParseCSV(reader io.Reader) ([]types.BulkInvitationEntry, error)

ParseCSV parses a CSV file with format: email,role,message First row is treated as header if it contains "email" Role and message columns are optional

func ParseInlineEmails

func ParseInlineEmails(emailList string) ([]types.BulkInvitationEntry, error)

ParseInlineEmails parses a comma-separated or whitespace-separated list of emails Useful for CLI inline email lists: "alice@example.com, bob@example.com"

func ParseInvitationFile

func ParseInvitationFile(filePath string) ([]types.BulkInvitationEntry, error)

ParseInvitationFile parses a file containing invitation data Automatically detects format (CSV or plain text) based on file extension

func ParsePlainText

func ParsePlainText(reader io.Reader) ([]types.BulkInvitationEntry, error)

ParsePlainText parses a plain text file with one email per line Lines starting with # are treated as comments Empty lines are ignored

func ValidateRoles

func ValidateRoles(entries []types.BulkInvitationEntry) error

ValidateRoles checks if all roles in entries are valid

Types

type CachedInvitation

type CachedInvitation struct {
	// Token is the full invitation token
	Token string `json:"token"`

	// Decoded invitation details (from token or API)
	InvitationID string                 `json:"invitation_id"`
	ProjectID    string                 `json:"project_id"`
	ProjectName  string                 `json:"project_name"`
	Email        string                 `json:"email"`
	Role         types.ProjectRole      `json:"role"`
	InvitedBy    string                 `json:"invited_by"`
	InvitedAt    time.Time              `json:"invited_at"`
	ExpiresAt    time.Time              `json:"expires_at"`
	Status       types.InvitationStatus `json:"status"`
	Message      string                 `json:"message,omitempty"`

	// Cache metadata
	AddedAt time.Time `json:"added_at"`
}

CachedInvitation represents a cached invitation with token and metadata

type CreateInvitationRequest

type CreateInvitationRequest struct {
	ProjectID string            `json:"project_id"`
	Email     string            `json:"email"`
	Role      types.ProjectRole `json:"role"`
	InvitedBy string            `json:"invited_by"`
	Message   string            `json:"message,omitempty"`
	ExpiresAt *time.Time        `json:"expires_at,omitempty"`
}

CreateInvitationRequest is a request to create an invitation

func (*CreateInvitationRequest) Validate

func (r *CreateInvitationRequest) Validate() error

Validate validates the create invitation request

type EmailSender

type EmailSender interface {
	SendInvitation(ctx context.Context, invitation *types.Invitation, project *types.Project, inviter string) error
	SendAcceptanceConfirmation(ctx context.Context, invitation *types.Invitation, project *types.Project) error
}

EmailSender defines the interface for sending invitation emails

type InvitationCache

type InvitationCache struct {
	// contains filtered or unexported fields
}

InvitationCache manages locally cached invitations

func NewInvitationCache

func NewInvitationCache() (*InvitationCache, error)

NewInvitationCache creates a new invitation cache

func (*InvitationCache) Add

func (c *InvitationCache) Add(ctx context.Context, token string, invitation *types.Invitation, projectName string) error

Add adds an invitation token to the cache

func (*InvitationCache) CleanupExpired

func (c *InvitationCache) CleanupExpired() (int, error)

CleanupExpired removes expired invitations from cache

func (*InvitationCache) Clear

func (c *InvitationCache) Clear() error

Clear removes all cached invitations

func (*InvitationCache) Get

func (c *InvitationCache) Get(projectName string) (*CachedInvitation, error)

Get retrieves a cached invitation by project name

func (*InvitationCache) GetSummary

func (c *InvitationCache) GetSummary() (total, pending, accepted, declined, expired int)

GetSummary returns a summary of cached invitations

func (*InvitationCache) List

func (c *InvitationCache) List() ([]*CachedInvitation, error)

List returns all cached invitations

func (*InvitationCache) Remove

func (c *InvitationCache) Remove(projectName string) error

Remove removes a cached invitation by project name

func (*InvitationCache) Size

func (c *InvitationCache) Size() int

Size returns the number of cached invitations

func (*InvitationCache) UpdateStatus

func (c *InvitationCache) UpdateStatus(projectName string, status types.InvitationStatus) error

UpdateStatus updates the status of a cached invitation

type Manager

type Manager struct {
	// contains filtered or unexported fields
}

Manager handles invitation lifecycle

func NewManager

func NewManager(emailSender EmailSender) (*Manager, error)

NewManager creates a new invitation manager

func (*Manager) AcceptInvitation

func (m *Manager) AcceptInvitation(ctx context.Context, token string) (*types.Invitation, error)

AcceptInvitation accepts an invitation

func (*Manager) CleanupExpired

func (m *Manager) CleanupExpired(ctx context.Context) (int, error)

CleanupExpired marks expired invitations as expired

func (*Manager) CreateBulkInvitations

func (m *Manager) CreateBulkInvitations(ctx context.Context, projectID string, invitedBy string, bulkReq *types.BulkInvitationRequest) (*types.BulkInvitationResponse, error)

CreateBulkInvitations creates multiple invitations concurrently

func (*Manager) CreateInvitation

func (m *Manager) CreateInvitation(ctx context.Context, req *CreateInvitationRequest) (*types.Invitation, error)

CreateInvitation creates a new invitation

func (*Manager) DeclineInvitation

func (m *Manager) DeclineInvitation(ctx context.Context, token string, reason string) (*types.Invitation, error)

DeclineInvitation declines an invitation

func (*Manager) GetInvitation

func (m *Manager) GetInvitation(ctx context.Context, invitationID string) (*types.Invitation, error)

GetInvitation retrieves an invitation by ID

func (*Manager) GetInvitationByToken

func (m *Manager) GetInvitationByToken(ctx context.Context, token string) (*types.Invitation, error)

GetInvitationByToken retrieves an invitation by token

func (*Manager) GetProjectSummary

func (m *Manager) GetProjectSummary(ctx context.Context, projectID string) (*types.InvitationSummary, error)

GetProjectSummary gets invitation summary for a project

func (*Manager) ListInvitations

func (m *Manager) ListInvitations(ctx context.Context, filter *types.InvitationFilter) ([]*types.Invitation, error)

ListInvitations lists invitations with optional filtering

func (*Manager) ResendInvitation

func (m *Manager) ResendInvitation(ctx context.Context, invitationID string) error

ResendInvitation resends an invitation email

func (*Manager) RevokeInvitation

func (m *Manager) RevokeInvitation(ctx context.Context, invitationID string) error

RevokeInvitation revokes a pending invitation

type SharedTokenManager

type SharedTokenManager struct {
	// contains filtered or unexported fields
}

SharedTokenManager manages shared invitation tokens

func NewSharedTokenManager

func NewSharedTokenManager() *SharedTokenManager

NewSharedTokenManager creates a new shared token manager

func (*SharedTokenManager) CreateSharedToken

CreateSharedToken creates a new shared invitation token

func (*SharedTokenManager) ExtendExpiration

func (m *SharedTokenManager) ExtendExpiration(ctx context.Context, tokenCode string, duration time.Duration) error

ExtendExpiration extends the expiration of a shared token

func (*SharedTokenManager) GetSharedToken

func (m *SharedTokenManager) GetSharedToken(ctx context.Context, tokenCode string) (*types.SharedInvitationToken, error)

GetSharedToken retrieves a shared token by code

func (*SharedTokenManager) ListSharedTokens

func (m *SharedTokenManager) ListSharedTokens(ctx context.Context, projectID string) ([]*types.SharedInvitationToken, error)

ListSharedTokens lists all shared tokens for a project

func (*SharedTokenManager) RedeemToken

RedeemToken redeems a shared token (atomic operation)

func (*SharedTokenManager) RevokeSharedToken

func (m *SharedTokenManager) RevokeSharedToken(ctx context.Context, tokenCode string) error

RevokeSharedToken revokes a shared token

Jump to

Keyboard shortcuts

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