From d83f6892d6605871dbf116155286b5d256652f7a Mon Sep 17 00:00:00 2001 From: Your Name Date: Mon, 21 Jul 2025 10:32:02 -0600 Subject: [PATCH] Fix: Ensure registration.yaml sender_localpart is always whatsappbot and update Makefile for build service --- Makefile | 26 +++++++++++--------------- start.sh | 4 ++++ 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/Makefile b/Makefile index f7b54f8..4f812b5 100644 --- a/Makefile +++ b/Makefile @@ -1,39 +1,35 @@ -.PHONY: build clean package +.PHONY: clean package dev-install dev-update publish # Repository details - change as needed CLOUDRON_APP_ID = dev.maunium.whatsapp.cloudronapp +CLOUDRON_IMAGE_REPO = andreasdueren/mautrix-whatsapp-cloudron CLOUDRON_TOKEN ?= +BUILD_SERVICE_TOKEN = e3265de06b1d0e7bb38400539012a8433a74c2c96a17955e # For development, we'll use the current git commit as the version GIT_COMMIT = $(shell git rev-parse --short HEAD 2>/dev/null || echo "dev") VERSION ?= dev-$(GIT_COMMIT) -# Docker image for cloudron package building -CLOUDRON_BUILDER_IMAGE = cloudron/package-builder:5.0.0 - -all: build - -build: - docker build -t $(CLOUDRON_APP_ID) -f Dockerfile.cloudron . +all: package # Clean build artifacts clean: rm -rf build.log latest.tgz -# Package for Cloudron in a consistent environment +# Package for Cloudron using the build service package: - @mkdir -p build - docker run --rm -v "$(PWD):/app" $(CLOUDRON_BUILDER_IMAGE) build --set-version $(VERSION) + cloudron build --set-build-service builder.docker.due.ren --build-service-token $(BUILD_SERVICE_TOKEN) --set-repository $(CLOUDRON_IMAGE_REPO) --tag $(VERSION) # For development - install directly in a test Cloudron dev-install: package - cloudron install --image $(CLOUDRON_APP_ID) --location whatsapp.example.com + cloudron uninstall --app whatsapp.matrix.due.ren || true + cloudron install --location whatsapp.matrix.due.ren --image $(CLOUDRON_IMAGE_REPO):$(VERSION) # Update the app in a dev Cloudron -dev-update: - cloudron update --app whatsapp.example.com --image $(CLOUDRON_APP_ID) +dev-update: package + cloudron update --app whatsapp.matrix.due.ren --image $(CLOUDRON_IMAGE_REPO):$(VERSION) # Publish to a Cloudron app store (requires token) publish: @if [ -z "$(CLOUDRON_TOKEN)" ]; then echo "CLOUDRON_TOKEN is not set"; exit 1; fi - cloudron appstore publish --app $(CLOUDRON_APP_ID) --token $(CLOUDRON_TOKEN) \ No newline at end of file + cloudron appstore publish --app $(CLOUDRON_APP_ID) --token $(CLOUDRON_TOKEN) diff --git a/start.sh b/start.sh index a387dd7..43b1d0a 100755 --- a/start.sh +++ b/start.sh @@ -58,6 +58,7 @@ if [ ! -f "$CONFIG_PATH" ]; then yq -i -y '.appservice.public_address = "https://'"$CLOUDRON_APP_DOMAIN"'"' "$CONFIG_PATH" || echo "=> ERROR: Could not configure appservice public_address" yq -i -y '.appservice.hostname = "0.0.0.0"' "$CONFIG_PATH" || echo "=> ERROR: Could not configure appservice hostname" yq -i -y '.appservice.port = 29318' "$CONFIG_PATH" || echo "=> ERROR: Could not configure appservice port" + yq -i -y '.appservice.bot_username = "whatsappbot"' "$CONFIG_PATH" || echo "=> ERROR: Could not configure appservice bot_username" # Configure permissions for base domain users yq -i -y '.bridge.permissions."'"$BASE_DOMAIN"'" = "user"' "$CONFIG_PATH" || echo "=> ERROR: Could not configure permissions" @@ -105,6 +106,7 @@ if [ ! -f "$CONFIG_PATH" ]; then # Fix user regex patterns to use base domain instead of matrix subdomain yq -i -y '.namespaces.users[0].regex = "^@whatsappbot:'"$BASE_DOMAIN"'$"' "$REGISTRATION_PATH" || echo "=> ERROR: Could not fix whatsappbot regex" yq -i -y '.namespaces.users[1].regex = "^@whatsapp_.*:'"$BASE_DOMAIN"'$"' "$REGISTRATION_PATH" || echo "=> ERROR: Could not fix whatsapp_.* regex" + yq -i -y '.sender_localpart = "whatsappbot"' "$REGISTRATION_PATH" || echo "=> ERROR: Could not fix sender_localpart" fi chown cloudron:cloudron "$CONFIG_PATH" "$REGISTRATION_PATH" 2>/dev/null || true @@ -154,6 +156,7 @@ else yq -i -y '.appservice.public_address = "https://'"$CLOUDRON_APP_DOMAIN"'"' "$CONFIG_PATH" || echo "=> ERROR: Could not update appservice public_address" yq -i -y '.appservice.hostname = "0.0.0.0"' "$CONFIG_PATH" || echo "=> ERROR: Could not update appservice hostname" yq -i -y '.appservice.port = 29318' "$CONFIG_PATH" || echo "=> ERROR: Could not update appservice port" + yq -i -y '.appservice.bot_username = "whatsappbot"' "$CONFIG_PATH" || echo "=> ERROR: Could not update appservice bot_username" # Configure permissions for base domain users yq -i -y '.bridge.permissions."'"$BASE_DOMAIN"'" = "user"' "$CONFIG_PATH" || echo "=> ERROR: Could not update permissions" @@ -226,6 +229,7 @@ else # Fix user regex patterns to use base domain instead of matrix subdomain yq -i -y '.namespaces.users[0].regex = "^@whatsappbot:'"$BASE_DOMAIN"'$"' "$REGISTRATION_PATH" || echo "=> ERROR: Could not fix whatsappbot regex" yq -i -y '.namespaces.users[1].regex = "^@whatsapp_.*:'"$BASE_DOMAIN"'$"' "$REGISTRATION_PATH" || echo "=> ERROR: Could not fix whatsapp_.* regex" + yq -i -y '.sender_localpart = "whatsappbot"' "$REGISTRATION_PATH" || echo "=> ERROR: Could not fix sender_localpart" fi # Let the bridge handle token generation automatically - remove any placeholder tokens