Documentation
¶
Overview ¶
Package smsmap provides pure functions that map raw SMS and call-log fields to model.Document. It is shared by SMSCollector (XML backup parser) and the POST /api/v1/ingest/messages HTTP handler so that both sources produce structurally identical documents from the same input.
All functions are stateless and safe for concurrent use.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BodyShortHash ¶
BodyShortHash returns an 8-character hex string of SHA-256(body) used to disambiguate SourceIDs when two messages share the same address and millisecond timestamp. Exported for use in tests that need to compute expected SourceIDs.
func MapCall ¶
func MapCall(number string, dateMs int64, durationSec int, typ int, contactName string) model.Document
MapCall maps raw call-log fields to a model.Document.
SourceID format: call-log:{dateMs}:{sha256(number)[:16]}:{sha256(durationStr)[:8]} Phone numbers (number) are hashed so raw PII is not stored in the SourceID. OccurredAt is time.UnixMilli(dateMs).UTC().
Parameters mirror the SMS Backup & Restore XML <call> element attributes and the POST /api/v1/ingest/messages JSON schema:
- number: phone number (will be hashed in SourceID)
- dateMs: Unix millisecond timestamp of the call
- durationSec: call duration in seconds
- typ: SMS Backup & Restore call type code (1=incoming, 2=outgoing, 3=missed, 4=voicemail, 5=rejected, 6=blocked)
- contactName: display name of the contact (may be empty; falls back to number)
func MapSMS ¶
MapSMS maps raw SMS fields to a model.Document.
SourceID format: sms:{dateMs}:{sha256(addr)[:16]}:{sha256(body)[:8]} Phone numbers (addr) are hashed so raw PII is not stored in the SourceID. Auth-like bodies have their OTP digit runs replaced with [REDACTED]. OccurredAt is time.UnixMilli(dateMs).UTC().
Parameters mirror the SMS Backup & Restore XML <sms> element attributes and the POST /api/v1/ingest/messages JSON schema:
- addr: phone number / address (will be hashed in SourceID)
- body: message body (auth OTPs are redacted)
- dateMs: Unix millisecond timestamp of the message
- typ: SMS Backup & Restore type code (1=received, 2=sent, 3=draft, 4=outbox, 5=failed, 6=queued)
- contactName: display name of the contact (may be empty; falls back to addr)
Types ¶
This section is empty.