message

package
v1.2.3 Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2026 License: MIT Imports: 24 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidPayload       = errors.New("payload inválido")
	ErrInstanceNotConnected = errors.New("instância não conectada")
	ErrInvalidJID           = errors.New("JID inválido")
	ErrUnsupportedMediaType = errors.New("tipo de mídia não suportado")
	ErrSessionUnavailable   = errors.New("sessão indisponível")
	// ErrContactReachoutLocked: the contact recently returned 463 (reach-out timelock) on this
	// connection and hasn't replied yet. Terminal send failure — released on the contact's inbound.
	ErrContactReachoutLocked = errors.New("contato com restrição de reach-out (463); aguardando o contato iniciar conversa")
	// ErrRecipientLookupUnavailable: the number could not be checked because the socket was down
	// (whatsmeow's usync query needs the websocket). The request is fine and the number may well
	// exist — only the lookup failed, so this is a RETRYABLE 503, not a 500.
	ErrRecipientLookupUnavailable = errors.New("não foi possível validar o destinatário: conexão indisponível")
)
View Source
var (
	// ErrStickerNotWebP is returned for any container that is not RIFF/WEBP. WhatsApp takes WebP
	// only: PNG, JPEG and GIF are refused, so converting is the caller's job, not ours.
	ErrStickerNotWebP = errors.New("figurinha deve ser WebP")
	// ErrStickerTooLarge guards the 500 KB ceiling.
	ErrStickerTooLarge = errors.New("figurinha deve ter no máximo 500 KB")
	// ErrStickerDimensions guards the mandatory 512x512.
	ErrStickerDimensions = errors.New("figurinha deve ser 512x512")
)

Functions

func ForgetInstancePresence added in v1.2.0

func ForgetInstancePresence(instanceID string)

ForgetInstancePresence clears the state on connect/disconnect: after reconnecting, nothing signaled on the previous session still holds on the other side.

func ReleaseReachoutOnInbound added in v1.2.0

func ReleaseReachoutOnInbound(instanceID, chatJID string)

ReleaseReachoutOnInbound is the public entry point called by the webhook layer when an inbound message arrives: it unblocks this instance for the contact (the chatJID is normalized to the same device-less key used on send). No-op if nothing was blocked.

func TrackInbound added in v1.1.0

func TrackInbound(instanceID, chatJID, messageID, senderJID string)

TrackInbound stores the last inbound message ID for a given chat. Called by the event handler when a message is received. The Send function uses this to auto-mark messages as read before sending.

Types

type ContactEntry added in v1.1.0

type ContactEntry struct {
	DisplayName string `json:"displayName"`
	Vcard       string `json:"vcard"`
}

type EnqueueInput

type EnqueueInput struct {
	InstanceID string
	To         string
	Type       string
	Payload    string
}

type OutboxWorker added in v1.0.10

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

func NewOutboxWorker added in v1.0.10

func NewOutboxWorker(service *Service, q queue.Queue, log *zap.Logger, numWorkers int) *OutboxWorker

func (*OutboxWorker) Start added in v1.0.10

func (w *OutboxWorker) Start(ctx context.Context)

func (*OutboxWorker) Stop added in v1.0.10

func (w *OutboxWorker) Stop()

type SendInput

type SendInput struct {
	InstanceID  string
	To          string
	Type        string
	Text        string
	MediaData   []byte
	MediaType   string
	Caption     string
	FileName    string
	Seconds     int
	PTT         bool
	MessageID   string
	Quoted      string
	Participant string
	QuotedText  string
	// QuotedFromMe: the quoted message was sent by US. The caller cannot build the right
	// Participant, since on 1:1 whatsmeow swaps the target for LID and signs with our LID, so the
	// instance phone number does not work. With this flag ownJIDForChat resolves it here.
	QuotedFromMe      bool
	MentionedJids     []string
	MarkReadMessageID string
	MarkReadSender    string
	DisplayName       string
	Vcard             string
	Contacts          []ContactEntry
	Latitude          float64
	Longitude         float64
	// Status post styling. A text status is an ExtendedTextMessage carrying a background, and the
	// official app always sets one, so these have defaults rather than being optional in practice.
	BackgroundArgb uint32
	TextArgb       uint32
	Font           string
	LocationName   string
	Address        string
}

type Service

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

func NewServiceWithSession

func NewServiceWithSession(repo storage.MessageRepository, sessionMgr SessionManager, instanceRepo storage.InstanceRepository, contactRepo storage.ContactRepository, eventLogRepo storage.EventLogRepository, q queue.Queue, webhookQueue queue.Queue, cfg config.WhatsAppConfig, log *zap.Logger) *Service

func (*Service) ConfirmJID added in v1.2.0

func (s *Service) ConfirmJID(ctx context.Context, jid types.JID)

ConfirmJID invalidates the negative cache and persists the positive mapping based on a real event (message, receipt, presence) that proves the number is on WhatsApp. It only accepts JIDs from the s.whatsapp.net server.

func (*Service) Enqueue

func (s *Service) Enqueue(ctx context.Context, input EnqueueInput) (model.Message, error)

func (*Service) List

func (s *Service) List(ctx context.Context, instanceID string) ([]model.Message, error)

func (*Service) ResolveJID added in v1.0.11

func (s *Service) ResolveJID(ctx context.Context, client *whatsmeow.Client, phone string) (types.JID, error)

func (*Service) Send

func (s *Service) Send(ctx context.Context, input SendInput) (model.Message, error)

type SessionManager

type SessionManager interface {
	GetClient(instanceID string) (*whatsmeow.Client, error)
	IsSessionReady(instanceID string) bool
	HasSession(instanceID string, jid types.JID) (bool, error)
	GetPreKeyCount(instanceID string) (int, error)
	GetConnectedAt(instanceID string) time.Time
	CacheOutgoingMessage(id string, msg *waE2E.Message)
}

Jump to

Keyboard shortcuts

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