Skip to content

feat: Unix socket IPC for send while sync is running#20

Open
sergi039 wants to merge 2 commits intosteipete:mainfrom
sergi039:fix/socket-ipc-for-send
Open

feat: Unix socket IPC for send while sync is running#20
sergi039 wants to merge 2 commits intosteipete:mainfrom
sergi039:fix/socket-ipc-for-send

Conversation

@sergi039
Copy link

Problem

wacli send cannot work while sync --follow is running because both commands need an exclusive lock on the store directory. This makes it impossible to send messages programmatically while maintaining a sync session.

Solution

sync --follow now starts a Unix socket server that accepts send commands from other wacli processes.

How it works:

  1. sync --follow starts an IPC server at ~/.wacli/wacli.sock
  2. send checks if the socket exists and tries IPC first
  3. If IPC succeeds, message is sent through the running sync daemon
  4. If IPC fails or socket doesn't exist, falls back to direct mode

Changes

  • internal/ipc/ipc.go: New IPC server/client using Unix sockets
  • cmd/wacli/sync.go: Start IPC server in --follow mode (--enable-ipc=true by default)
  • cmd/wacli/send.go: Try IPC first, fallback to direct if unavailable

Usage

# Terminal 1: Start sync daemon
wacli sync --follow

# Terminal 2: Send messages (routes through daemon automatically)
wacli send text --to 1234567890 --message 'Hello!'
# Output: Sent to 1234567890@s.whatsapp.net (id XXX) via daemon

New Flags

  • sync --enable-ipc=false - disable IPC server
  • send --no-ipc - skip IPC, use direct mode only

Testing

Successfully tested sending messages via IPC while sync was running.

Problem: wacli send cannot work while sync --follow is running because
both commands need an exclusive lock on the store directory.

Solution: sync --follow now starts a Unix socket server that accepts
send commands from other wacli processes.

Changes:
- internal/ipc/ipc.go: New IPC server/client using Unix sockets
- cmd/wacli/sync.go: Start IPC server in --follow mode (--enable-ipc=true by default)
- cmd/wacli/send.go: Try IPC first, fallback to direct if unavailable

Usage:
  Terminal 1: wacli sync --follow
  Terminal 2: wacli send text --to 1234567890 --message 'Hello!'

The send command will detect the running sync daemon and route the
message through the IPC socket instead of trying to acquire the lock.

Flags:
  sync --enable-ipc=false  # disable IPC server
  send --no-ipc            # skip IPC, use direct mode only

Tested: Successfully sent messages via IPC while sync was running.
Adds wacli delete message command to revoke/delete sent messages.

Changes:
- cmd/wacli/delete.go: New delete command with IPC support
- internal/wa/client.go: Add RevokeMessage and OwnJID methods
- internal/ipc/ipc.go: Add delete_message IPC command
- cmd/wacli/sync.go: Add DeleteMessage handler

Usage:
  wacli delete message --chat 1234567890@s.whatsapp.net --id <msg-id>

Also supports IPC when sync daemon is running.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant