📈 Open source, privacy-first web analytics — a cookie-less Google Analytics alternative with built-in error tracking and performance monitoring. Self-host it or use our cloud. Get started for free!
TypeScript chartsclickhousedockergdprgoogle-analyticsmetricsmonitoringmysqlnestjsprivacyredisself-hostedselfhostedstatisticstailwindcssweb-analyticswebanalyticswebsite
fix: broken unsubscribe urls
Blue Mouseef11e1c04b53
diff --git a/backend/apps/cloud/src/project/project.service.ts b/backend/apps/cloud/src/project/project.service.tsindex 0450ec722..68d98e254 100644--- a/backend/apps/cloud/src/project/project.service.ts+++ b/backend/apps/cloud/src/project/project.service.ts@@ -1464,19 +1464,23 @@ export class ProjectService implements OnModuleDestroy {}createUnsubscribeKey(subscriberId: string): string {- return encodeURIComponent(- CryptoJS.Rabbit.encrypt(- subscriberId,- EMAIL_ACTION_ENCRYPTION_KEY,- ).toString(),- )+ const base64 = CryptoJS.Rabbit.encrypt(+ subscriberId,+ EMAIL_ACTION_ENCRYPTION_KEY,+ ).toString()+ // Convert to URL-safe base64 (base64url)+ return base64.replace(/\+/g, '-').replace(/\//g, '_').replace(/=+$/, '')}decryptUnsubscribeKey(token: string): string {- const bytes = CryptoJS.Rabbit.decrypt(- decodeURIComponent(token),- EMAIL_ACTION_ENCRYPTION_KEY,- )+ let base64 = token.replace(/-/g, '+').replace(/_/g, '/')++ const padding = base64.length % 4+ if (padding) {+ base64 += '='.repeat(4 - padding)+ }++ const bytes = CryptoJS.Rabbit.decrypt(base64, EMAIL_ACTION_ENCRYPTION_KEY)return bytes.toString(CryptoJS.enc.Utf8)}diff --git a/backend/apps/cloud/src/user/user.service.ts b/backend/apps/cloud/src/user/user.service.tsindex 430824fc0..7deadd686 100644--- a/backend/apps/cloud/src/user/user.service.ts+++ b/backend/apps/cloud/src/user/user.service.ts@@ -514,16 +514,23 @@ export class UserService {}createUnsubscribeKey(userId: string): string {- return encodeURIComponent(- CryptoJS.Rabbit.encrypt(userId, EMAIL_ACTION_ENCRYPTION_KEY).toString(),- )+ const base64 = CryptoJS.Rabbit.encrypt(+ userId,+ EMAIL_ACTION_ENCRYPTION_KEY,+ ).toString()+ // Convert to URL-safe base64 (base64url)+ return base64.replace(/\+/g, '-').replace(/\//g, '_').replace(/=+$/, '')}decryptUnsubscribeKey(token: string): string {- const bytes = CryptoJS.Rabbit.decrypt(- decodeURIComponent(token),- EMAIL_ACTION_ENCRYPTION_KEY,- )+ let base64 = token.replace(/-/g, '+').replace(/_/g, '/')++ const padding = base64.length % 4+ if (padding) {+ base64 += '='.repeat(4 - padding)+ }++ const bytes = CryptoJS.Rabbit.decrypt(base64, EMAIL_ACTION_ENCRYPTION_KEY)return bytes.toString(CryptoJS.enc.Utf8)}