smsmap

package
v0.19.6 Latest Latest
Warning

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

Go to latest
Published: Jun 13, 2026 License: MIT Imports: 6 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

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

func BodyShortHash(body string) string

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

func MapSMS(addr, body string, dateMs int64, typ int, contactName string) model.Document

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)

func ShortHash

func ShortHash(s string) string

ShortHash returns a 16-character hex string that is the first 8 bytes of SHA-256(s). Used to hash PII (phone numbers/addresses) in SourceIDs so they are not logged downstream. Exported for use in tests that need to compute expected SourceIDs.

Types

This section is empty.

Jump to

Keyboard shortcuts

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