Documentation
¶
Index ¶
- Variables
- func ForgetInstancePresence(instanceID string)
- func ReleaseReachoutOnInbound(instanceID, chatJID string)
- func TrackInbound(instanceID, chatJID, messageID, senderJID string)
- type ContactEntry
- type EnqueueInput
- type OutboxWorker
- type SendInput
- type Service
- func (s *Service) ConfirmJID(ctx context.Context, jid types.JID)
- func (s *Service) Enqueue(ctx context.Context, input EnqueueInput) (model.Message, error)
- func (s *Service) List(ctx context.Context, instanceID string) ([]model.Message, error)
- func (s *Service) ResolveJID(ctx context.Context, client *whatsmeow.Client, phone string) (types.JID, error)
- func (s *Service) Send(ctx context.Context, input SendInput) (model.Message, error)
- type SessionManager
Constants ¶
This section is empty.
Variables ¶
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") // 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") // (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") )
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 EnqueueInput ¶
type OutboxWorker ¶ added in v1.0.10
type OutboxWorker struct {
// contains filtered or unexported fields
}
func NewOutboxWorker ¶ added in v1.0.10
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 NewService ¶
func NewService(repo storage.MessageRepository, q queue.Queue, cfg config.WhatsAppConfig, log *zap.Logger) *Service
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
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) ResolveJID ¶ added in v1.0.11
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)
}