Whatsapp unlink WIP #1
This commit is contained in:
parent
12b72a727c
commit
48165db6a2
9 changed files with 120 additions and 3 deletions
|
|
@ -0,0 +1 @@
|
|||
export { relinkBot as POST } from "@link-stack/bridge-ui";
|
||||
|
|
@ -286,8 +286,30 @@ export default class WhatsappService extends Service {
|
|||
}
|
||||
|
||||
async unverify(botID: string): Promise<void> {
|
||||
// Step 1: Close and remove the active connection if it exists
|
||||
const connection = this.connections[botID];
|
||||
if (connection?.socket) {
|
||||
try {
|
||||
// Properly close the WebSocket connection
|
||||
await connection.socket.logout();
|
||||
} catch (error) {
|
||||
logger.warn({ botID, error }, "Error during logout, forcing disconnect");
|
||||
try {
|
||||
connection.socket.end(undefined);
|
||||
} catch (endError) {
|
||||
logger.warn({ botID, endError }, "Error ending socket connection");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Step 2: Remove from in-memory connections
|
||||
delete this.connections[botID];
|
||||
|
||||
// Step 3: Remove the bot directory (auth state, QR code, verified marker)
|
||||
const botDirectory = this.getBotDirectory(botID);
|
||||
fs.rmSync(botDirectory, { recursive: true, force: true });
|
||||
if (fs.existsSync(botDirectory)) {
|
||||
fs.rmSync(botDirectory, { recursive: true, force: true });
|
||||
}
|
||||
}
|
||||
|
||||
async register(
|
||||
|
|
|
|||
|
|
@ -182,7 +182,7 @@ const sendSignalMessageTask = async ({
|
|||
{
|
||||
number,
|
||||
recipients: [finalTo],
|
||||
message: message.substring(0, 50) + "...",
|
||||
messageLength: message?.length,
|
||||
hasQuoteParams: !!(quoteMessage && quoteAuthor && quoteTimestamp),
|
||||
},
|
||||
"Message data being sent",
|
||||
|
|
@ -197,7 +197,7 @@ const sendSignalMessageTask = async ({
|
|||
logger.debug(
|
||||
{
|
||||
quoteAuthor,
|
||||
quoteMessage: quoteMessage.substring(0, 50) + "...",
|
||||
quoteMessageLength: quoteMessage?.length,
|
||||
quoteTimestamp,
|
||||
},
|
||||
"Including quote in message",
|
||||
|
|
|
|||
1
apps/link/app/api/[service]/bots/[token]/relink/route.ts
Normal file
1
apps/link/app/api/[service]/bots/[token]/relink/route.ts
Normal file
|
|
@ -0,0 +1 @@
|
|||
export { relinkBot as POST } from "@link-stack/bridge-ui";
|
||||
Loading…
Add table
Add a link
Reference in a new issue