Documentation
¶
Index ¶
- Variables
- func AuthMiddleware(next echo.HandlerFunc) echo.HandlerFunc
- func CleanExpiredSessions() error
- func ClearUploadProgress()
- func CustomCORSMiddleware() echo.MiddlewareFunc
- func DeleteSession(sessionID string) error
- func GenerateSessionID() (string, error)
- func GetDateRange(userDB *sql.DB) (time.Time, time.Time, error)
- func GetMessageMedia(userDB *sql.DB, messageID string) ([]byte, string, error)
- func GetUserDB(userID string, username string) (*sql.DB, error)
- func GetUsernameByID(userID string) (string, error)
- func HandleActivity(c echo.Context) error
- func HandleAnalytics(c echo.Context) error
- func HandleCalls(c echo.Context) error
- func HandleChangePassword(c echo.Context) error
- func HandleConversations(c echo.Context) error
- func HandleDateRange(c echo.Context) error
- func HandleGetSettings(c echo.Context) error
- func HandleLogin(c echo.Context) error
- func HandleLogout(c echo.Context) error
- func HandleMe(c echo.Context) error
- func HandleMedia(c echo.Context) error
- func HandleMediaItems(c echo.Context) error
- func HandleMessages(c echo.Context) error
- func HandleProgress(c echo.Context) error
- func HandleRegister(c echo.Context) error
- func HandleSearch(c echo.Context) error
- func HandleUpdateSettings(c echo.Context) error
- func HandleUpload(c echo.Context) error
- func HandleVersion(c echo.Context) error
- func InitAuthDB(filepath string) error
- func InitDB(filepath string) error
- func InitUserDB(userID string, filepath string) error
- func InsertCallLog(userDB *sql.DB, call *CallLog) error
- func InsertCallLogBatch(userDB *sql.DB, calls []CallLog) error
- func InsertMessage(userDB *sql.DB, msg *Message) error
- func NoCacheMiddleware(next echo.HandlerFunc) echo.HandlerFunc
- func ParseSMSBackupStreaming(userDB *sql.DB, r io.Reader, batchSize int) (int, int, error)
- func ProcessUploadedFile(userID string, username string, filePath string)
- func SanitizeUsername(username string) string
- func SaveUploadedFile(file io.Reader, filename string) (string, error)
- func SaveUserSettings(userID string, settings Settings) error
- func SetUploadProgress(total, processed int, status string)
- func UpdateCallProgress(processed int)
- func UpdateMessageProgress(processed int)
- func UpdatePassword(userID string, newPassword string) error
- func VerifyPassword(user *User, password string) bool
- type ActivityItem
- type AnalyticsResponse
- type AuthResponse
- type AutoImportService
- type CallEntry
- type CallLog
- type ChangePasswordRequest
- type Conversation
- type ConversationSettings
- type DailyCount
- type HourlyDistribution
- type LoginRequest
- type MMSAddr
- type MMSEntry
- type MMSPart
- type Message
- type ParseResult
- type RegisterRequest
- type SMSBackup
- type SMSEntry
- type SearchResult
- type Session
- type Settings
- type TopContact
- type UploadProgress
- type UploadResponse
- type User
Constants ¶
This section is empty.
Variables ¶
var UseWALMode bool
UseWALMode controls whether WAL journal mode is enabled for databases
Functions ¶
func AuthMiddleware ¶
func AuthMiddleware(next echo.HandlerFunc) echo.HandlerFunc
AuthMiddleware checks for a valid session cookie
func CleanExpiredSessions ¶
func CleanExpiredSessions() error
CleanExpiredSessions removes all expired sessions
func ClearUploadProgress ¶
func ClearUploadProgress()
ClearUploadProgress clears the upload progress
func CustomCORSMiddleware ¶
func CustomCORSMiddleware() echo.MiddlewareFunc
CustomCORSMiddleware creates a custom CORS middleware that properly handles credentials
func DeleteSession ¶
DeleteSession deletes a session by ID
func GenerateSessionID ¶
GenerateSessionID generates a random session ID
func GetMessageMedia ¶
func GetUserDB ¶
GetUserDB retrieves the database connection for a specific user, creating it if it doesn't exist
func GetUsernameByID ¶ added in v0.1.8
GetUsernameByID retrieves username by user ID
func HandleActivity ¶
func HandleAnalytics ¶ added in v0.1.9
HandleAnalytics returns analytics data for the Summary tab
func HandleCalls ¶ added in v0.1.3
func HandleChangePassword ¶
func HandleConversations ¶
func HandleDateRange ¶
func HandleGetSettings ¶ added in v0.1.7
HandleGetSettings handles GET /api/settings
func HandleLogin ¶
func HandleLogout ¶
func HandleMedia ¶
func HandleMediaItems ¶ added in v0.1.7
HandleMediaItems returns only media (images/videos) for a conversation
func HandleMessages ¶
func HandleProgress ¶
func HandleRegister ¶
func HandleSearch ¶
func HandleUpdateSettings ¶ added in v0.1.7
HandleUpdateSettings handles PUT /api/settings
func HandleUpload ¶
func HandleVersion ¶ added in v0.1.5
HandleVersion returns the application version
func InitAuthDB ¶
InitAuthDB initializes the authentication database
func InitUserDB ¶
InitUserDB initializes a database for a specific user
func InsertCallLogBatch ¶
InsertCallLogBatch inserts multiple call logs in a single transaction for better performance
func NoCacheMiddleware ¶
func NoCacheMiddleware(next echo.HandlerFunc) echo.HandlerFunc
NoCacheMiddleware adds cache control headers to prevent browser caching This ensures that dynamic API responses are always fetched fresh from the server
func ParseSMSBackupStreaming ¶
ParseSMSBackupStreaming parses SMS backup file with streaming to reduce memory usage Each message is inserted immediately and memory is freed aggressively
func ProcessUploadedFile ¶
ProcessUploadedFile processes the uploaded file in the background
func SanitizeUsername ¶
SanitizeUsername converts a username to a safe filesystem name
func SaveUploadedFile ¶
SaveUploadedFile saves the uploaded file to a temporary location
func SaveUserSettings ¶ added in v0.1.7
SaveUserSettings saves settings for a user
func SetUploadProgress ¶
SetUploadProgress initializes or updates the upload progress
func UpdateCallProgress ¶
func UpdateCallProgress(processed int)
UpdateCallProgress updates the progress for calls
func UpdateMessageProgress ¶
func UpdateMessageProgress(processed int)
UpdateMessageProgress updates the progress for messages
func UpdatePassword ¶
UpdatePassword updates a user's password
func VerifyPassword ¶
VerifyPassword checks if the provided password matches the user's password hash
Types ¶
type ActivityItem ¶
type ActivityItem struct {
Type string `json:"type"` // "message" or "call"
Date time.Time `json:"date"`
Address string `json:"address"`
ContactName string `json:"contact_name,omitempty"`
// Message-specific fields
Message *Message `json:"message,omitempty"`
// Call-specific fields
Call *CallLog `json:"call,omitempty"`
}
func GetActivity ¶
func GetActivityByAddress ¶
type AnalyticsResponse ¶ added in v0.1.9
type AnalyticsResponse struct {
TotalMessages int `json:"total_messages"`
TotalSMS int `json:"total_sms"`
TotalMMS int `json:"total_mms"`
TotalCalls int `json:"total_calls"`
TotalSent int `json:"total_sent"`
TotalReceived int `json:"total_received"`
IncomingCalls int `json:"incoming_calls"`
OutgoingCalls int `json:"outgoing_calls"`
MissedCalls int `json:"missed_calls"`
TotalCallDuration int `json:"total_call_duration"`
AvgMessageLength float64 `json:"avg_message_length"`
TopContacts []TopContact `json:"top_contacts"`
HourlyDistribution []HourlyDistribution `json:"hourly_distribution"`
DailyTrend []DailyCount `json:"daily_trend"`
}
func GetAnalytics ¶ added in v0.1.9
func GetAnalytics(userDB *sql.DB, startDate, endDate *time.Time, topN int, tzOffsetMinutes int) (*AnalyticsResponse, error)
GetAnalytics retrieves analytics data for the Summary tab
type AuthResponse ¶
type AutoImportService ¶ added in v0.1.8
type AutoImportService struct {
// contains filtered or unexported fields
}
AutoImportService manages automatic file imports for all users
func NewAutoImportService ¶ added in v0.1.8
func NewAutoImportService(dataDir string) *AutoImportService
NewAutoImportService creates a new auto-import service
func (*AutoImportService) Start ¶ added in v0.1.8
func (s *AutoImportService) Start()
Start begins the auto-import background job
func (*AutoImportService) Stop ¶ added in v0.1.8
func (s *AutoImportService) Stop()
Stop gracefully stops the auto-import service
type CallEntry ¶
type CallEntry struct {
Number string `xml:"number,attr"`
Duration string `xml:"duration,attr"`
Date string `xml:"date,attr"`
Type string `xml:"type,attr"`
Presentation string `xml:"presentation,attr"`
SubscriptionID string `xml:"subscription_id,attr"`
ReadableDate string `xml:"readable_date,attr"`
ContactName string `xml:"contact_name,attr"`
}
type CallLog ¶
type CallLog struct {
ID int64 `json:"id"`
Number string `json:"number"`
Duration int `json:"duration"` // in seconds
Date time.Time `json:"date"`
Type int `json:"type"` // 1 = incoming, 2 = outgoing, 3 = missed, 4 = voicemail, 5 = rejected, 6 = refused
Presentation int `json:"presentation,omitempty"` // 1 = allowed, 2 = restricted, 3 = unknown, 4 = payphone
SubscriptionID string `json:"subscription_id,omitempty"`
ContactName string `json:"contact_name,omitempty"`
}
func GetAllCalls ¶ added in v0.1.3
type ChangePasswordRequest ¶
type Conversation ¶
type Conversation struct {
Address string `json:"address"`
ContactName string `json:"contact_name,omitempty"`
Subject string `json:"subject,omitempty"`
LastMessage string `json:"last_message"`
LastDate time.Time `json:"last_date"`
MessageCount int `json:"message_count"`
Type string `json:"type"` // "sms", "mms", or "call"
}
func GetConversations ¶
type ConversationSettings ¶ added in v0.1.7
type ConversationSettings struct {
ShowCalls bool `json:"show_calls"`
}
ConversationSettings contains settings for the conversation view
type DailyCount ¶ added in v0.1.9
type HourlyDistribution ¶ added in v0.1.9
type LoginRequest ¶
type MMSEntry ¶
type MMSEntry struct {
Address string `xml:"address,attr"`
Date string `xml:"date,attr"`
Type string `xml:"msg_box,attr"`
Read string `xml:"read,attr"`
ThreadID string `xml:"thread_id,attr"`
Subject string `xml:"sub,attr"`
TrID string `xml:"tr_id,attr"`
ContentType string `xml:"ct_t,attr"`
ReadReport string `xml:"rr,attr"`
ReadStatus string `xml:"read_status,attr"`
MessageID string `xml:"m_id,attr"`
MessageSize string `xml:"m_size,attr"`
MessageType string `xml:"m_type,attr"`
SimSlot string `xml:"sim_slot,attr"`
ReadableDate string `xml:"readable_date,attr"`
ContactName string `xml:"contact_name,attr"`
Parts []MMSPart `xml:"parts>part"`
Addrs []MMSAddr `xml:"addrs>addr"`
Body string `xml:"body,attr"`
}
type Message ¶
type Message struct {
ID int64 `json:"id"`
Address string `json:"address"`
Body string `json:"body"`
Type int `json:"type"` // 1 = received, 2 = sent, 3 = draft, 4 = outbox, 5 = failed, 6 = queued
Date time.Time `json:"date"`
Read bool `json:"read"`
ThreadID int `json:"thread_id"`
Subject string `json:"subject,omitempty"`
MediaType string `json:"media_type,omitempty"`
MediaData []byte `json:"-"`
MediaBase64 string `json:"media_base64,omitempty"`
// Additional SMS fields
Protocol int `json:"protocol,omitempty"`
Status int `json:"status,omitempty"` // -1 = none, 0 = complete, 32 = pending, 64 = failed
ServiceCenter string `json:"service_center,omitempty"`
SubID int `json:"sub_id,omitempty"`
ContactName string `json:"contact_name,omitempty"`
Sender string `json:"sender,omitempty"` // Sender phone number for received messages
// Additional MMS fields
ContentType string `json:"content_type,omitempty"` // ct_t field
ReadReport int `json:"read_report,omitempty"` // rr field
ReadStatus int `json:"read_status,omitempty"`
MessageID string `json:"message_id,omitempty"` // m_id field
MessageSize int `json:"message_size,omitempty"` // m_size field
MessageType int `json:"message_type,omitempty"` // m_type field
SimSlot int `json:"sim_slot,omitempty"`
Addresses []string `json:"addresses,omitempty"` // All phone numbers in conversation (for MMS)
}
type ParseResult ¶
func ParseSMSBackup ¶
func ParseSMSBackup(r io.Reader) (ParseResult, error)
type RegisterRequest ¶
type SMSEntry ¶
type SMSEntry struct {
Address string `xml:"address,attr"`
Date string `xml:"date,attr"`
Type string `xml:"type,attr"`
Body string `xml:"body,attr"`
Read string `xml:"read,attr"`
ThreadID string `xml:"thread_id,attr"`
Subject string `xml:"subject,attr"`
Protocol string `xml:"protocol,attr"`
TOA string `xml:"toa,attr"`
SCTOA string `xml:"sc_toa,attr"`
ServiceCenter string `xml:"service_center,attr"`
Status string `xml:"status,attr"`
SubID string `xml:"sub_id,attr"`
ReadableDate string `xml:"readable_date,attr"`
ContactName string `xml:"contact_name,attr"`
}
type SearchResult ¶
type SearchResult struct {
MessageID int64 `json:"message_id"`
Address string `json:"address"`
ContactName string `json:"contact_name"`
Body string `json:"body"`
Date time.Time `json:"date"`
Snippet string `json:"snippet"`
}
SearchResult represents a message search result
func SearchMessages ¶
SearchMessages performs full-text search on message contents
type Session ¶
type Session struct {
ID string `json:"id"`
UserID string `json:"user_id"`
Username string `json:"username"`
CreatedAt time.Time `json:"created_at"`
ExpiresAt time.Time `json:"expires_at"`
}
func CreateSession ¶
CreateSession creates a new session for a user
func GetSession ¶
GetSession retrieves a session by ID
type Settings ¶ added in v0.1.7
type Settings struct {
Conversations ConversationSettings `json:"conversations"`
}
Settings represents user settings stored as JSON
func GetDefaultSettings ¶ added in v0.1.7
func GetDefaultSettings() Settings
GetDefaultSettings returns the default settings
func GetUserSettings ¶ added in v0.1.7
GetUserSettings retrieves settings for a user
type TopContact ¶ added in v0.1.9
type UploadProgress ¶
type UploadProgress struct {
TotalMessages int `json:"total_messages"`
ProcessedMessages int `json:"processed_messages"`
TotalCalls int `json:"total_calls"`
ProcessedCalls int `json:"processed_calls"`
Status string `json:"status"` // "parsing", "importing", "completed", "error"
ErrorMessage string `json:"error_message,omitempty"`
StartTime time.Time `json:"start_time"`
// contains filtered or unexported fields
}
UploadProgress tracks the progress of an ongoing upload
func GetUploadProgress ¶
func GetUploadProgress() *UploadProgress
GetUploadProgress returns the current upload progress
type UploadResponse ¶
type User ¶
type User struct {
ID string `json:"id"`
Username string `json:"username"`
PasswordHash string `json:"-"` // Never send password hash to client
CreatedAt time.Time `json:"created_at"`
}
func CreateUser ¶
CreateUser creates a new user with hashed password
func GetUserByUsername ¶
GetUserByUsername retrieves a user by username