voip.ms Messages: Signal-style desktop SMS client
Electron + React app that imports the full voip.ms SMS history into a local SQLite/FTS5 database, polls for new messages, sends SMS, resolves names/photos from GNOME EDS address books, and supports global and per-chat search with jump-to-message. Data lives in ~/Documents/voipms-desktop-data (covered by Deja Dup) with daily consistent snapshots. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
// Phone number helpers. voip.ms uses bare 10-digit NANP numbers, so everything
|
||||
// is normalized to that form where possible (short codes and international
|
||||
// numbers are left as plain digits).
|
||||
|
||||
export function normalizeNumber(raw: string): string {
|
||||
let digits = raw.replace(/\D/g, '')
|
||||
if (digits.length === 11 && digits.startsWith('1')) digits = digits.slice(1)
|
||||
return digits
|
||||
}
|
||||
|
||||
export function formatNumber(n: string): string {
|
||||
const d = normalizeNumber(n)
|
||||
if (d.length === 10) return `(${d.slice(0, 3)}) ${d.slice(3, 6)}-${d.slice(6)}`
|
||||
return n
|
||||
}
|
||||
|
||||
// Split text into voip.ms-sized parts (160 chars max per sendSMS call),
|
||||
// preferring to break on whitespace.
|
||||
export function splitMessage(text: string, max = 160): string[] {
|
||||
const parts: string[] = []
|
||||
let rest = text.trim()
|
||||
while ([...rest].length > max) {
|
||||
const chars = [...rest]
|
||||
let cut = max
|
||||
for (let i = max; i > max * 0.6; i--) {
|
||||
if (/\s/.test(chars[i])) {
|
||||
cut = i
|
||||
break
|
||||
}
|
||||
}
|
||||
parts.push(chars.slice(0, cut).join('').trimEnd())
|
||||
rest = chars.slice(cut).join('').trimStart()
|
||||
}
|
||||
if (rest) parts.push(rest)
|
||||
return parts
|
||||
}
|
||||
Reference in New Issue
Block a user