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,39 @@
|
||||
// The typed bridge exposed to the renderer as window.api.
|
||||
import type { ContactInfo, Conversation, Credentials, Did, Message, SearchHit, Settings, SyncStatus } from './types'
|
||||
|
||||
export interface AppState {
|
||||
configured: boolean
|
||||
username?: string
|
||||
settings: Settings
|
||||
dataDir: string
|
||||
dids: Did[]
|
||||
keyringBackend: string
|
||||
}
|
||||
|
||||
export interface Api {
|
||||
getState(): Promise<AppState>
|
||||
testCredentials(creds: Credentials): Promise<Did[]>
|
||||
saveSetup(creds: Credentials, settings: Settings): Promise<void>
|
||||
updateSettings(settings: Settings): Promise<void>
|
||||
signOut(): Promise<void>
|
||||
|
||||
listContacts(): Promise<ContactInfo[]>
|
||||
listConversations(): Promise<Conversation[]>
|
||||
getMessages(did: string, contact: string): Promise<Message[]>
|
||||
markRead(did: string, contact: string): Promise<void>
|
||||
search(query: string, scope?: { did: string; contact: string }): Promise<SearchHit[]>
|
||||
send(did: string, contact: string, text: string): Promise<void>
|
||||
deleteFailed(id: number): Promise<void>
|
||||
retryFailed(id: number): Promise<void>
|
||||
|
||||
syncStatus(): Promise<SyncStatus>
|
||||
pollNow(): Promise<void>
|
||||
openDataFolder(): Promise<void>
|
||||
snapshotNow(): Promise<string>
|
||||
chooseDataDir(): Promise<string | undefined>
|
||||
|
||||
onMessages(cb: (msgs: Message[]) => void): () => void
|
||||
onConversationsChanged(cb: () => void): () => void
|
||||
onSyncStatus(cb: (s: SyncStatus) => void): () => void
|
||||
onContactsChanged(cb: () => void): () => void
|
||||
}
|
||||
@@ -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
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
// Types shared between the main process, preload bridge and renderer.
|
||||
|
||||
export type Direction = 'in' | 'out'
|
||||
export type MessageStatus = 'delivered' | 'pending' | 'failed'
|
||||
|
||||
export interface Message {
|
||||
id: number
|
||||
did: string
|
||||
contact: string
|
||||
direction: Direction
|
||||
body: string
|
||||
ts: number // epoch ms, UTC
|
||||
kind: 'sms' | 'mms'
|
||||
status: MessageStatus
|
||||
}
|
||||
|
||||
export interface Conversation {
|
||||
did: string
|
||||
contact: string
|
||||
lastBody: string
|
||||
lastTs: number
|
||||
lastDirection: Direction
|
||||
unread: number
|
||||
}
|
||||
|
||||
export interface ContactInfo {
|
||||
name: string
|
||||
number: string // normalized
|
||||
label?: string // e.g. "cell", "work"
|
||||
photo?: string // data: URL
|
||||
book: string
|
||||
}
|
||||
|
||||
export interface SearchHit {
|
||||
id: number
|
||||
did: string
|
||||
contact: string
|
||||
ts: number
|
||||
direction: Direction
|
||||
snippet: string // contains / markers around matched text
|
||||
}
|
||||
|
||||
export interface Did {
|
||||
did: string
|
||||
description: string
|
||||
smsEnabled: boolean
|
||||
}
|
||||
|
||||
export interface SyncStatus {
|
||||
phase: 'idle' | 'backfill' | 'polling' | 'error' | 'unconfigured'
|
||||
backfillCursor?: string // YYYY-MM-DD the backfill has reached
|
||||
backfillDone: boolean
|
||||
lastPoll?: number
|
||||
error?: string
|
||||
total: number
|
||||
}
|
||||
|
||||
export interface Settings {
|
||||
pollSeconds: number
|
||||
dids: string[] // DIDs to sync; empty = all SMS-enabled
|
||||
defaultDid?: string
|
||||
backfillFloor: string // YYYY-MM-DD, stop backfill here
|
||||
}
|
||||
|
||||
export interface Credentials {
|
||||
username: string
|
||||
password: string
|
||||
}
|
||||
|
||||
export const SNIPPET_START = ''
|
||||
export const SNIPPET_END = ''
|
||||
Reference in New Issue
Block a user