Remove image sending capabilities - cant be tested

This commit is contained in:
fat-operator
2026-03-06 23:48:54 +00:00
parent fdd161d7b2
commit 8c25897532
4 changed files with 1371 additions and 44 deletions

1362
bridge/package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -12,13 +12,6 @@ interface SendCommand {
text: string;
}
interface SendImageCommand {
type: 'send_image';
to: string;
imagePath: string;
caption?: string;
}
interface BridgeMessage {
type: 'message' | 'status' | 'qr' | 'error';
[key: string]: unknown;
@@ -79,7 +72,7 @@ export class BridgeServer {
ws.on('message', async (data) => {
try {
const cmd = JSON.parse(data.toString()) as SendCommand | SendImageCommand;
const cmd = JSON.parse(data.toString()) as SendCommand;
await this.handleCommand(cmd);
ws.send(JSON.stringify({ type: 'sent', to: cmd.to }));
} catch (error) {
@@ -99,11 +92,9 @@ export class BridgeServer {
});
}
private async handleCommand(cmd: SendCommand | SendImageCommand): Promise<void> {
private async handleCommand(cmd: SendCommand): Promise<void> {
if (cmd.type === 'send' && this.wa) {
await this.wa.sendMessage(cmd.to, cmd.text);
} else if (cmd.type === 'send_image' && this.wa) {
await this.wa.sendImage(cmd.to, cmd.imagePath, cmd.caption);
}
}

View File

@@ -16,7 +16,7 @@ import makeWASocket, {
import { Boom } from '@hapi/boom';
import qrcode from 'qrcode-terminal';
import pino from 'pino';
import { writeFile, mkdir, readFile } from 'fs/promises';
import { writeFile, mkdir } from 'fs/promises';
import { join } from 'path';
import { homedir } from 'os';
import { randomBytes } from 'crypto';
@@ -217,18 +217,6 @@ export class WhatsAppClient {
await this.sock.sendMessage(to, { text });
}
async sendImage(to: string, imagePath: string, caption?: string): Promise<void> {
if (!this.sock) {
throw new Error('Not connected');
}
const buffer = await readFile(imagePath);
await this.sock.sendMessage(to, {
image: buffer,
caption: caption || undefined,
});
}
async disconnect(): Promise<void> {
if (this.sock) {
this.sock.end(undefined);

View File

@@ -83,20 +83,6 @@ class WhatsAppChannel(BaseChannel):
return
try:
# Send media files first
for media_path in (msg.media or []):
try:
payload = {
"type": "send_image",
"to": msg.chat_id,
"imagePath": media_path,
}
await self._ws.send(json.dumps(payload, ensure_ascii=False))
except Exception as e:
logger.error("Error sending WhatsApp media {}: {}", media_path, e)
# Send text message if there's content
if msg.content:
payload = {
"type": "send",
"to": msg.chat_id,