Compare commits
4 commits
main
...
3.4.0-beta
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
797ed112c6 | ||
|
|
a2fc38db25 | ||
|
|
0c287e38d3 | ||
|
|
8d3eeee1d9 |
25 changed files with 1023 additions and 936 deletions
|
|
@ -20,13 +20,11 @@ build-all:
|
|||
- turbo build
|
||||
|
||||
.docker-build:
|
||||
image: registry.gitlab.com/digiresilience/link/link-stack/buildx:main
|
||||
image: registry.gitlab.com/digiresilience/link/link-stack/buildx:${CI_COMMIT_REF_NAME}
|
||||
services:
|
||||
- docker:dind
|
||||
stage: docker-build
|
||||
variables:
|
||||
DOCKER_HOST: tcp://docker:2375
|
||||
DOCKER_TLS_CERTDIR: ""
|
||||
DOCKER_TAG: ${CI_COMMIT_SHORT_SHA}
|
||||
BUILD_CONTEXT: .
|
||||
only:
|
||||
|
|
@ -39,13 +37,11 @@ build-all:
|
|||
- docker push ${DOCKER_NS}:${DOCKER_TAG}
|
||||
|
||||
.docker-release:
|
||||
image: registry.gitlab.com/digiresilience/link/link-stack/buildx:main
|
||||
image: registry.gitlab.com/digiresilience/link/link-stack/buildx:${CI_COMMIT_REF_NAME}
|
||||
services:
|
||||
- docker:dind
|
||||
stage: docker-release
|
||||
variables:
|
||||
DOCKER_HOST: tcp://docker:2375
|
||||
DOCKER_TLS_CERTDIR: ""
|
||||
DOCKER_TAG: ${CI_COMMIT_SHORT_SHA}
|
||||
DOCKER_TAG_NEW: ${CI_COMMIT_REF_NAME}
|
||||
only:
|
||||
|
|
@ -199,8 +195,8 @@ zammad-docker-build:
|
|||
PNPM_HOME: "/pnpm"
|
||||
before_script:
|
||||
- export PATH="$PNPM_HOME:$PATH"
|
||||
- corepack enable && corepack prepare pnpm@9.15.4 --activate
|
||||
script:
|
||||
- corepack enable && corepack prepare pnpm@9.15.4 --activate
|
||||
- pnpm add -g turbo
|
||||
- pnpm install --frozen-lockfile
|
||||
- turbo build --force --filter @link-stack/zammad-addon-*
|
||||
|
|
@ -222,8 +218,8 @@ zammad-standalone-docker-build:
|
|||
PNPM_HOME: "/pnpm"
|
||||
before_script:
|
||||
- export PATH="$PNPM_HOME:$PATH"
|
||||
- corepack enable && corepack prepare pnpm@9.15.4 --activate
|
||||
script:
|
||||
- corepack enable && corepack prepare pnpm@9.15.4 --activate
|
||||
- pnpm add -g turbo
|
||||
- pnpm install --frozen-lockfile
|
||||
- turbo build --force --filter @link-stack/zammad-addon-*
|
||||
|
|
|
|||
2
.nvmrc
2
.nvmrc
|
|
@ -1 +1 @@
|
|||
v22.18.0
|
||||
v24
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "@link-stack/bridge-frontend",
|
||||
"version": "3.3.5",
|
||||
"version": "3.4.0-beta.1",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"dev": "next dev",
|
||||
|
|
@ -20,7 +20,7 @@
|
|||
"@mui/x-license": "^7",
|
||||
"@link-stack/bridge-common": "workspace:*",
|
||||
"@link-stack/bridge-ui": "workspace:*",
|
||||
"next": "15.5.9",
|
||||
"next": "15.5.4",
|
||||
"next-auth": "^4.24.11",
|
||||
"react": "19.2.0",
|
||||
"react-dom": "19.2.0",
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "@link-stack/bridge-migrations",
|
||||
"version": "3.3.5",
|
||||
"version": "3.4.0-beta.1",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"migrate:up:all": "tsx migrate.ts up:all",
|
||||
|
|
|
|||
|
|
@ -1,33 +1,29 @@
|
|||
{
|
||||
"name": "@link-stack/bridge-whatsapp",
|
||||
"version": "3.3.5",
|
||||
"version": "3.4.0-beta.1",
|
||||
"type": "module",
|
||||
"main": "build/main/index.js",
|
||||
"author": "Darren Clarke <darren@redaranj.com>",
|
||||
"license": "AGPL-3.0-or-later",
|
||||
"dependencies": {
|
||||
"@adiwajshing/keyed-db": "0.2.4",
|
||||
"@hapi/hapi": "^21.4.3",
|
||||
"@hapipal/schmervice": "^3.0.0",
|
||||
"@hapipal/toys": "^4.0.0",
|
||||
"@link-stack/bridge-common": "workspace:*",
|
||||
"@link-stack/logger": "workspace:*",
|
||||
"@whiskeysockets/baileys": "6.7.21",
|
||||
"hapi-pino": "^13.0.0",
|
||||
"link-preview-js": "^3.1.0"
|
||||
"@whiskeysockets/baileys": "7.0.0-rc.9",
|
||||
"hapi-pino": "^13.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@link-stack/eslint-config": "workspace:*",
|
||||
"@link-stack/jest-config": "workspace:*",
|
||||
"@link-stack/typescript-config": "workspace:*",
|
||||
"@types/long": "^5",
|
||||
"@types/node": "*",
|
||||
"dotenv-cli": "^10.0.0",
|
||||
"tsx": "^4.20.6",
|
||||
"typescript": "^5.9.3"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "tsc -p tsconfig.json",
|
||||
"dev": "dotenv -- tsx src/index.ts",
|
||||
"dev": "node --env-file=.env --experimental-transform-types src/index.ts",
|
||||
"start": "node build/main/index.js"
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,17 +1,17 @@
|
|||
import * as Hapi from "@hapi/hapi";
|
||||
import hapiPino from "hapi-pino";
|
||||
import Schmervice from "@hapipal/schmervice";
|
||||
import WhatsappService from "./service.js";
|
||||
import WhatsappService from "./service.ts";
|
||||
import {
|
||||
RegisterBotRoute,
|
||||
UnverifyBotRoute,
|
||||
GetBotRoute,
|
||||
SendMessageRoute,
|
||||
ReceiveMessageRoute,
|
||||
} from "./routes.js";
|
||||
} from "./routes.ts";
|
||||
import { createLogger } from "@link-stack/logger";
|
||||
|
||||
const logger = createLogger('bridge-whatsapp-index');
|
||||
const logger = createLogger("bridge-whatsapp-index");
|
||||
|
||||
const server = Hapi.server({ port: 5000 });
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import * as Hapi from "@hapi/hapi";
|
||||
import Toys from "@hapipal/toys";
|
||||
import WhatsappService from "./service";
|
||||
import WhatsappService from "./service.ts";
|
||||
|
||||
const withDefaults = Toys.withRouteDefaults({
|
||||
options: {
|
||||
|
|
@ -27,15 +27,9 @@ export const SendMessageRoute = withDefaults({
|
|||
description: "Send a message",
|
||||
async handler(request: Hapi.Request, _h: Hapi.ResponseToolkit) {
|
||||
const { id } = request.params;
|
||||
const { phoneNumber, message, attachments } =
|
||||
request.payload as MessageRequest;
|
||||
const { phoneNumber, message, attachments } = request.payload as MessageRequest;
|
||||
const whatsappService = getService(request);
|
||||
await whatsappService.send(
|
||||
id,
|
||||
phoneNumber,
|
||||
message as string,
|
||||
attachments,
|
||||
);
|
||||
await whatsappService.send(id, phoneNumber, message as string, attachments);
|
||||
request.logger.info(
|
||||
{
|
||||
id,
|
||||
|
|
|
|||
|
|
@ -4,12 +4,13 @@ import makeWASocket, {
|
|||
DisconnectReason,
|
||||
proto,
|
||||
downloadContentFromMessage,
|
||||
MediaType,
|
||||
fetchLatestBaileysVersion,
|
||||
isJidBroadcast,
|
||||
isJidStatusBroadcast,
|
||||
useMultiFileAuthState,
|
||||
} from "@whiskeysockets/baileys";
|
||||
|
||||
type MediaType = "audio" | "document" | "image" | "video" | "sticker";
|
||||
import fs from "fs";
|
||||
import { createLogger } from "@link-stack/logger";
|
||||
import {
|
||||
|
|
@ -97,6 +98,7 @@ export default class WhatsappService extends Service {
|
|||
...options,
|
||||
auth: state,
|
||||
generateHighQualityLinkPreview: false,
|
||||
syncFullHistory: true,
|
||||
msgRetryCounterMap,
|
||||
shouldIgnoreJid: (jid) => isJidBroadcast(jid) || isJidStatusBroadcast(jid),
|
||||
});
|
||||
|
|
@ -147,6 +149,17 @@ export default class WhatsappService extends Service {
|
|||
await this.queueUnreadMessages(botID, messages);
|
||||
}
|
||||
}
|
||||
|
||||
if (events["messaging-history.set"]) {
|
||||
const { messages, isLatest } = events["messaging-history.set"];
|
||||
logger.info(
|
||||
{ messageCount: messages.length, isLatest },
|
||||
"received message history on connection",
|
||||
);
|
||||
if (messages.length > 0) {
|
||||
await this.queueUnreadMessages(botID, messages);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
this.connections[botID] = { socket, msgRetryCounterMap };
|
||||
|
|
@ -167,7 +180,6 @@ export default class WhatsappService extends Service {
|
|||
|
||||
await this.createConnection(botID, this.server, {
|
||||
browser: WhatsappService.browserDescription,
|
||||
printQRInTerminal: true,
|
||||
version,
|
||||
});
|
||||
}
|
||||
|
|
@ -175,11 +187,12 @@ export default class WhatsappService extends Service {
|
|||
}
|
||||
|
||||
private async queueMessage(botID: string, webMessageInfo: proto.IWebMessageInfo) {
|
||||
const {
|
||||
key: { id, fromMe, remoteJid },
|
||||
message,
|
||||
messageTimestamp,
|
||||
} = webMessageInfo;
|
||||
const { key, message, messageTimestamp } = webMessageInfo;
|
||||
if (!key) {
|
||||
logger.warn("Message missing key, skipping");
|
||||
return;
|
||||
}
|
||||
const { id, fromMe, remoteJid } = key;
|
||||
logger.info("Message type debug");
|
||||
for (const key in message) {
|
||||
logger.info(
|
||||
|
|
@ -330,10 +343,7 @@ export default class WhatsappService extends Service {
|
|||
attachments?: Array<{ data: string; filename: string; mime_type: string }>,
|
||||
): Promise<void> {
|
||||
const connection = this.connections[botID]?.socket;
|
||||
const digits = phoneNumber.replace(/\D+/g, "");
|
||||
// LIDs are 15+ digits, phone numbers with country code are typically 10-14 digits
|
||||
const suffix = digits.length > 14 ? "@lid" : "@s.whatsapp.net";
|
||||
const recipient = `${digits}${suffix}`;
|
||||
const recipient = `${phoneNumber.replace(/\D+/g, "")}@s.whatsapp.net`;
|
||||
|
||||
// Send text message if provided
|
||||
if (message) {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import type WhatsappService from "./service.js";
|
||||
import type WhatsappService from "./service.ts";
|
||||
|
||||
declare module "@hapipal/schmervice" {
|
||||
interface SchmerviceDecorator {
|
||||
|
|
|
|||
|
|
@ -1,16 +1,17 @@
|
|||
{
|
||||
"extends": "@link-stack/typescript-config/tsconfig.node.json",
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"target": "es2018",
|
||||
"module": "NodeNext",
|
||||
"target": "es2022",
|
||||
"esModuleInterop": true,
|
||||
"moduleResolution": "node",
|
||||
"moduleResolution": "NodeNext",
|
||||
"outDir": "build/main",
|
||||
"rootDir": "src",
|
||||
"skipLibCheck": true,
|
||||
"types": ["node"],
|
||||
"lib": ["es2020", "DOM"],
|
||||
"composite": true
|
||||
"lib": ["es2022", "DOM"],
|
||||
"composite": true,
|
||||
"rewriteRelativeImportExtensions": true
|
||||
},
|
||||
"include": ["src/**/*.ts", "src/**/.*.ts"],
|
||||
"exclude": ["node_modules/**"]
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "@link-stack/bridge-worker",
|
||||
"version": "3.3.5",
|
||||
"version": "3.4.0-beta.1",
|
||||
"type": "module",
|
||||
"main": "build/main/index.js",
|
||||
"author": "Darren Clarke <darren@redaranj.com>",
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "@link-stack/link",
|
||||
"version": "3.3.5",
|
||||
"version": "3.4.0-beta.1",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"dev": "next dev -H 0.0.0.0",
|
||||
|
|
@ -31,7 +31,7 @@
|
|||
"graphql-request": "^7.2.0",
|
||||
"ioredis": "^5.8.1",
|
||||
"mui-chips-input": "^6.0.0",
|
||||
"next": "15.5.9",
|
||||
"next": "15.5.4",
|
||||
"next-auth": "^4.24.11",
|
||||
"react": "19.2.0",
|
||||
"react-cookie": "^8.0.1",
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "@link-stack",
|
||||
"version": "3.3.5",
|
||||
"version": "3.4.0-beta.1",
|
||||
"description": "Link from the Center for Digital Resilience",
|
||||
"scripts": {
|
||||
"dev": "dotenv -- turbo dev",
|
||||
|
|
@ -49,7 +49,7 @@
|
|||
"react": "19.2.0",
|
||||
"react-dom": "19.2.0",
|
||||
"ts-node": "^10.9.2",
|
||||
"turbo": "^2.5.8",
|
||||
"turbo": "^2.6.0",
|
||||
"typescript": "latest"
|
||||
},
|
||||
"pnpm": {
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "@link-stack/bridge-common",
|
||||
"version": "3.3.5",
|
||||
"version": "3.4.0-beta.1",
|
||||
"main": "build/main/index.js",
|
||||
"type": "module",
|
||||
"author": "Darren Clarke <darren@redaranj.com>",
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "@link-stack/bridge-ui",
|
||||
"version": "3.3.5",
|
||||
"version": "3.4.0-beta.1",
|
||||
"scripts": {
|
||||
"build": "tsc -p tsconfig.json"
|
||||
},
|
||||
|
|
@ -11,7 +11,7 @@
|
|||
"@mui/material": "^6",
|
||||
"@mui/x-data-grid-pro": "^7",
|
||||
"kysely": "0.27.5",
|
||||
"next": "15.5.9",
|
||||
"next": "15.5.4",
|
||||
"react": "19.2.0",
|
||||
"react-dom": "19.2.0",
|
||||
"react-qr-code": "^2.0.18"
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "@link-stack/eslint-config",
|
||||
"version": "3.3.5",
|
||||
"version": "3.4.0-beta.1",
|
||||
"description": "amigo's eslint config",
|
||||
"main": "index.js",
|
||||
"author": "Abel Luck <abel@guardianproject.info>",
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "@link-stack/jest-config",
|
||||
"version": "3.3.5",
|
||||
"version": "3.4.0-beta.1",
|
||||
"description": "",
|
||||
"main": "index.js",
|
||||
"author": "Abel Luck <abel@guardianproject.info>",
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "@link-stack/logger",
|
||||
"version": "3.3.5",
|
||||
"version": "3.4.0-beta.1",
|
||||
"description": "Shared logging utility for Link Stack monorepo",
|
||||
"main": "./dist/index.js",
|
||||
"module": "./dist/index.mjs",
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "@link-stack/signal-api",
|
||||
"version": "3.3.5",
|
||||
"version": "3.4.0-beta.1",
|
||||
"type": "module",
|
||||
"main": "build/index.js",
|
||||
"exports": {
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "@link-stack/typescript-config",
|
||||
"version": "3.3.5",
|
||||
"version": "3.4.0-beta.1",
|
||||
"description": "Shared TypeScript config",
|
||||
"license": "AGPL-3.0-or-later",
|
||||
"author": "Abel Luck <abel@guardianproject.info>",
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "@link-stack/ui",
|
||||
"version": "3.3.5",
|
||||
"version": "3.4.0-beta.1",
|
||||
"description": "",
|
||||
"scripts": {
|
||||
"build": "tsc -p tsconfig.json"
|
||||
|
|
@ -11,7 +11,7 @@
|
|||
"@mui/material": "^6",
|
||||
"@mui/x-data-grid-pro": "^7",
|
||||
"@mui/x-license": "^7",
|
||||
"next": "15.5.9",
|
||||
"next": "15.5.4",
|
||||
"react": "19.2.0",
|
||||
"react-dom": "19.2.0"
|
||||
},
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"name": "@link-stack/zammad-addon-bridge",
|
||||
"displayName": "Bridge",
|
||||
"version": "3.3.5",
|
||||
"version": "3.4.0-beta.1",
|
||||
"description": "An addon that adds CDR Bridge channels to Zammad.",
|
||||
"scripts": {
|
||||
"build": "node '../zammad-addon-common/dist/build.js'",
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "@link-stack/zammad-addon-common",
|
||||
"version": "3.3.5",
|
||||
"version": "3.4.0-beta.1",
|
||||
"description": "",
|
||||
"bin": {
|
||||
"zpm-build": "./dist/build.js",
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"name": "@link-stack/zammad-addon-hardening",
|
||||
"displayName": "Hardening",
|
||||
"version": "3.3.5",
|
||||
"version": "3.4.0-beta.1",
|
||||
"description": "A Zammad addon that hardens a Zammad instance according to CDR's needs.",
|
||||
"scripts": {
|
||||
"build": "node '../zammad-addon-common/dist/build.js'",
|
||||
|
|
|
|||
1826
pnpm-lock.yaml
generated
1826
pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load diff
Loading…
Add table
Add a link
Reference in a new issue