The open alternative to Salesforce, designed for AI.
TypeScript crmcrm-systemcustomergood-first-issuegraphqlhacktoberfestjavascriptmarketingmonoreponestjsopen-sourcepostgresqlreactreactjssalestypescriptweb
Call recorder: fill the workspace logo plate (#29536)
nitin2e102fa6199d
diff --git a/packages/twenty-apps/public/call-recorder/package.json b/packages/twenty-apps/public/call-recorder/package.jsonindex f64edc555d5..aab1a18bb85 100644--- a/packages/twenty-apps/public/call-recorder/package.json+++ b/packages/twenty-apps/public/call-recorder/package.json@@ -1,6 +1,6 @@{"name": "@twentyhq/call-recorder",- "version": "1.20.0",+ "version": "1.20.1","license": "MIT","engines": {"node": "^24.5.0",diff --git a/packages/twenty-apps/public/call-recorder/public/camera-tile/previews/workspace.jpg b/packages/twenty-apps/public/call-recorder/public/camera-tile/previews/workspace.jpgindex 9cd5568a0f3..30ebe02c71d 100644Binary files a/packages/twenty-apps/public/call-recorder/public/camera-tile/previews/workspace.jpg and b/packages/twenty-apps/public/call-recorder/public/camera-tile/previews/workspace.jpg differdiff --git a/packages/twenty-apps/public/call-recorder/src/logic-functions/constants/camera-tile-config.ts b/packages/twenty-apps/public/call-recorder/src/logic-functions/constants/camera-tile-config.tsindex 0341b3a025c..b383001697b 100644--- a/packages/twenty-apps/public/call-recorder/src/logic-functions/constants/camera-tile-config.ts+++ b/packages/twenty-apps/public/call-recorder/src/logic-functions/constants/camera-tile-config.ts@@ -8,7 +8,6 @@ export const CAMERA_TILE_PLATE_SIZE = 200;export const CAMERA_TILE_PLATE_RADIUS = 48;export const CAMERA_TILE_PLATE_COLOR = '#ffffff';export const CAMERA_TILE_PLATE_STROKE_COLOR = '#2e2e2e';-export const CAMERA_TILE_LOGO_BOX_SIZE = 132;export const CAMERA_TILE_INITIAL_COLOR = '#333333';export const CAMERA_TILE_INITIAL_FONT_SIZE = 96;diff --git a/packages/twenty-apps/public/call-recorder/src/logic-functions/domain/__tests__/render-camera-tile-logo.test.ts b/packages/twenty-apps/public/call-recorder/src/logic-functions/domain/__tests__/render-camera-tile-logo.test.tsnew file mode 100644index 00000000000..0672c5f3a8f--- /dev/null+++ b/packages/twenty-apps/public/call-recorder/src/logic-functions/domain/__tests__/render-camera-tile-logo.test.ts@@ -0,0 +1,81 @@+import sharp from 'sharp';+import { afterEach, assert, describe, expect, it, vi } from 'vitest';++import {+ CAMERA_TILE_PLATE_SIZE,+ CAMERA_TILE_PLATE_TOP,+} from 'src/logic-functions/constants/camera-tile-config';+import { RECALL_BOT_IMAGE_WIDTH } from 'src/logic-functions/constants/recall-bot-image-config';+import { renderCameraTileLogo } from 'src/logic-functions/domain/render-camera-tile-logo.util';++const readPixel = async ({+ image,+ x,+ y,+}: {+ image: Buffer;+ x: number;+ y: number;+}) => {+ const { data, info } = await sharp(image)+ .raw()+ .toBuffer({ resolveWithObject: true });+ const offset = (y * info.width + x) * info.channels;++ return Array.from(data.subarray(offset, offset + info.channels));+};++describe('renderCameraTileLogo', () => {+ afterEach(() => {+ vi.restoreAllMocks();+ });++ it('covers the plate with the center of a wide logo and clips it to the rounded corners', async () => {+ const wideLogo = await sharp({+ create: { width: 400, height: 150, channels: 3, background: '#f00' },+ })+ .composite([+ {+ input: {+ create: {+ width: 200,+ height: 150,+ channels: 3,+ background: '#000',+ },+ },+ left: 100,+ top: 0,+ },+ ])+ .png()+ .toBuffer();++ const overlay = await renderCameraTileLogo({ sharp, logo: wideLogo });+ const image = overlay?.input;++ assert(Buffer.isBuffer(image));++ expect(overlay).toMatchObject({+ left: (RECALL_BOT_IMAGE_WIDTH - CAMERA_TILE_PLATE_SIZE) / 2,+ top: CAMERA_TILE_PLATE_TOP,+ });+ expect(await sharp(image).metadata()).toMatchObject({+ width: CAMERA_TILE_PLATE_SIZE,+ height: CAMERA_TILE_PLATE_SIZE,+ hasAlpha: true,+ });+ expect(await readPixel({ image, x: 100, y: 5 })).toEqual([0, 0, 0, 255]);+ expect(await readPixel({ image, x: 10, y: 100 })).toEqual([0, 0, 0, 255]);+ expect(await readPixel({ image, x: 190, y: 100 })).toEqual([0, 0, 0, 255]);+ expect((await readPixel({ image, x: 0, y: 0 }))[3]).toBe(0);+ });++ it('drops a logo that cannot be decoded', async () => {+ vi.spyOn(console, 'warn').mockImplementation(() => {});++ expect(+ await renderCameraTileLogo({ sharp, logo: Buffer.from('not an image') }),+ ).toBeUndefined();+ });+});diff --git a/packages/twenty-apps/public/call-recorder/src/logic-functions/domain/render-camera-tile-logo.util.ts b/packages/twenty-apps/public/call-recorder/src/logic-functions/domain/render-camera-tile-logo.util.tsindex 023c1b9a31f..499dee08027 100644--- a/packages/twenty-apps/public/call-recorder/src/logic-functions/domain/render-camera-tile-logo.util.ts+++ b/packages/twenty-apps/public/call-recorder/src/logic-functions/domain/render-camera-tile-logo.util.ts@@ -1,13 +1,17 @@import { type OverlayOptions } from 'sharp';import {- CAMERA_TILE_LOGO_BOX_SIZE,+ CAMERA_TILE_PLATE_RADIUS,CAMERA_TILE_PLATE_SIZE,CAMERA_TILE_PLATE_TOP,} from 'src/logic-functions/constants/camera-tile-config';import { centerCameraTileItem } from 'src/logic-functions/domain/center-camera-tile-item.util';import { type SharpFactory } from 'src/logic-functions/utils/load-sharp.util';+const PLATE_MASK = Buffer.from(+ `<svg xmlns="http://www.w3.org/2000/svg" width="${CAMERA_TILE_PLATE_SIZE}" height="${CAMERA_TILE_PLATE_SIZE}"><rect width="${CAMERA_TILE_PLATE_SIZE}" height="${CAMERA_TILE_PLATE_SIZE}" rx="${CAMERA_TILE_PLATE_RADIUS}" fill="#fff"/></svg>`,+);+export const renderCameraTileLogo = async ({sharp,logo,@@ -16,16 +20,16 @@ export const renderCameraTileLogo = async ({logo: Buffer;}): Promise<OverlayOptions | undefined> => {try {- const { data, info } = await sharp(logo)- .resize(CAMERA_TILE_LOGO_BOX_SIZE, CAMERA_TILE_LOGO_BOX_SIZE, {- fit: 'inside',- })+ const plateLogo = await sharp(logo)+ .resize(CAMERA_TILE_PLATE_SIZE, CAMERA_TILE_PLATE_SIZE, { fit: 'cover' })+ .ensureAlpha()+ .composite([{ input: PLATE_MASK, blend: 'dest-in' }]).png()- .toBuffer({ resolveWithObject: true });+ .toBuffer();return centerCameraTileItem({- item: { input: data, width: info.width },- top: CAMERA_TILE_PLATE_TOP + (CAMERA_TILE_PLATE_SIZE - info.height) / 2,+ item: { input: plateLogo, width: CAMERA_TILE_PLATE_SIZE },+ top: CAMERA_TILE_PLATE_TOP,});} catch (error) {console.warn(