menfess

package
v0.0.0-...-b2e696f Latest Latest
Warning

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

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

Documentation

Overview

Package menfess stores consent and routing for private anonymous conversations. Phone identities are internal routing data and must never be included in relay text.

Index

Constants

View Source
const (
	InvitationTTL = 15 * time.Minute
	SessionTTL    = 24 * time.Hour
)

Variables

View Source
var (
	ErrSession  = errors.New("Sesi tidak ditemukan, sudah berakhir, atau bukan milikmu.")
	ErrBlocked  = errors.New("Undangan tidak dapat dikirim ke tujuan ini.")
	ErrBusy     = errors.New("Salah satu peserta masih memiliki undangan atau sesi Menfess. Selesaikan sesi sebelumnya dahulu.")
	ErrLimit    = errors.New("Batas undangan tercapai. Maksimal 3 per jam untuk pengirim dan 5 per hari untuk penerima.")
	ErrPending  = errors.New("Penerima belum menyetujui undangan Menfess.")
	ErrCooldown = errors.New("Tunggu 5 detik sebelum mengirim balasan berikutnya.")
)

Functions

func IsRejection

func IsRejection(err error) bool

IsRejection distinguishes expected refusals from storage failures.

func SetDefault

func SetDefault(s *Service)

func ValidateAlias

func ValidateAlias(alias string) error

func ValidateText

func ValidateText(text string) error

Types

type Relay

type Relay struct{ Code, To, Alias, Text, Notify string }

type Service

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

func Default

func Default() *Service

func New

func New(ctx context.Context, db *sqlx.DB) (*Service, error)

func (*Service) Accept

func (s *Service) Accept(ctx context.Context, actor, code string) (Relay, error)

Accept is recipient-only and releases the initial message once. Message text is removed from storage after acceptance; subsequent replies are never stored.

func (*Service) Block

func (s *Service) Block(ctx context.Context, actor string, blocked bool) error

Blocking closes existing invitations/conversations and rejects all new invites.

func (*Service) Invite

func (s *Service) Invite(ctx context.Context, sender, recipient, alias, text string) (Session, error)

func (*Service) Prune

func (s *Service) Prune(ctx context.Context) error

func (*Service) Reply

func (s *Service) Reply(ctx context.Context, actor, code, text string) (Relay, error)

func (*Service) Stop

func (s *Service) Stop(ctx context.Context, actor, code string) error

type Session

type Session struct {
	Code          string `db:"code"`
	Sender        string `db:"sender"`
	Recipient     string `db:"recipient"`
	Alias         string `db:"alias"`
	Initial       string `db:"initial_text"`
	State         string `db:"state"`
	Created       int64  `db:"created_at"`
	Expires       int64  `db:"expires_at"`
	LastSender    int64  `db:"last_sender"`
	LastRecipient int64  `db:"last_recipient"`
}

Jump to

Keyboard shortcuts

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