Skip to content

feat(condo): DOMA-13192 divide voip push types by data#7706

Open
YEgorLu wants to merge 3 commits into
mainfrom
feat/condo/DOMA-13192/divide-voip-push-types-by-data
Open

feat(condo): DOMA-13192 divide voip push types by data#7706
YEgorLu wants to merge 3 commits into
mainfrom
feat/condo/DOMA-13192/divide-voip-push-types-by-data

Conversation

@YEgorLu

@YEgorLu YEgorLu commented Jun 5, 2026

Copy link
Copy Markdown
Contributor

Summary by CodeRabbit

  • New Features

    • Added distinct VoIP intercom call notification types for native and B2C app calls.
    • Added localization support in English, Spanish, and Russian for new notification types.
    • Implemented configurable push notification type switching per app.
  • Tests

    • Added comprehensive test coverage for new VoIP notification functionality.

@YEgorLu YEgorLu changed the title Feat/condo/doma 13192/divide voip push types by data feat(condo): DOMA-13192 divide voip push types by data Jun 5, 2026
@coderabbitai

coderabbitai Bot commented Jun 5, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

This PR introduces distinct VoIP incoming call message types for native and B2C app calls, with per-app push type filtering and multi-message-per-call sending. The service now generates both legacy and type-specific messages per resident, while push delivery is configurable per appId. Localization and tests are added across three languages and comprehensive coverage scenarios.

Changes

VoIP Incoming Call Message Type Support

Layer / File(s) Summary
Message type constants and metadata
apps/condo/domains/notification/constants/constants.js
VOIP_INCOMING_NATIVE_CALL_MESSAGE_TYPE and VOIP_INCOMING_B2C_APP_CALL_MESSAGE_TYPE are added as constants, registered in MESSAGE_META with validation schemas, extended in MESSAGE_DELIVERY_OPTIONS with fast-priority push-only delivery, and exported.
VoIP type selection helper
apps/condo/domains/miniapp/utils/sendVoIPCallMessage.js
New getVoipTypeByData({ callData, customVoIPValues }) helper encapsulates logic to select between native and B2C app call message types, exported for reuse in message-sending pipelines.
Push transport type filtering by app
apps/condo/domains/notification/transports/push.js
Adds PUSH_TYPE_SWITCH_RULES_BY_APP_ID configuration merging per-app and global message type enable/disable rules; removes prior hard-coded rejection and implements filtering to mark disabled message types as failed with "message type disabled by settings" error.
VoIP message sending and result parsing
apps/condo/domains/miniapp/utils/sendVoIPCallMessage.js
Imports new message types and wires them to preparers; simplifies sendMessageToUser return value to send result only; refactors parseSendMessageResults to handle aggregated per-push result objects instead of single consolidated messages.
SendVoIPCallStartMessageService multi-message dispatch
apps/condo/domains/miniapp/schema/SendVoIPCallStartMessageService.js
Imports NATIVE_VOIP_TYPE and getVoipTypeByData; computes voipType and builds pushTypes list per resident; sends one sendMessageToUser call per push type in a loop; collects per-push { result, error } pairs in a results array.
Test helper updates
apps/condo/domains/miniapp/utils/testSchema/index.js
prepareVoIPUser helper now returns userClient in addition to existing user, contact, and resident properties.
Test refactoring and new coverage
apps/condo/domains/miniapp/schema/SendVoIPCallStartMessageService.test.js
Replaces local prepareUser with imported prepareVoIPUser across cache, voipType priority, and custom field tests; adds new "Multiple messages for one call" test verifying both legacy and new message types are created per call variant.
Comprehensive VoIP multi-message spec
apps/condo/domains/miniapp/schema/SendVoIPCallStartMessageService.spec.js
New spec file testing SendVoIPCallStartMessageService across enabled/disabled appIds: provisions B2C app, resident user with push tokens for two appIds, sends native and B2C call data, and asserts expected message types and per-appId delivery success/failure mapping.
Message localization (en/es/ru)
apps/condo/lang/{en,es,ru}/{en,es,ru}.json, apps/condo/lang/{en,es,ru}/messages/VOIP_INCOMING_{NATIVE_CALL_MESSAGE,B2C_APP_CALL_MESSAGE}/*.njk
Localization keys and Nunjucks templates added for VOIP_INCOMING_NATIVE_CALL_MESSAGE and VOIP_INCOMING_B2C_APP_CALL_MESSAGE across English, Spanish, and Russian; templates render message body and address fields.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

  • open-condo-software/condo#7641: Refactors VoIP call-start handling and per-message success/error recording, directly related to changes in sendVoIPCallMessage.js result parsing and SendVoIPCallStartMessageService caching behavior.

Suggested reviewers

  • SavelevMatthew
  • abshnko
  • sitozzz

Poem

🐰 Two message types now bloom, native and B2C,
Per-app filtering guides which ones flow free,
Results stack kindly, per-push they align,
Tests span the spectrum from simple to fine,
Localized greetings in three tongues unite! 📞✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: dividing VoIP push message types based on call data (native vs B2C), which is the core objective reflected across all file modifications.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/condo/DOMA-13192/divide-voip-push-types-by-data

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

ESLint install failed. For unrecoverable errors, disable the tool in CodeRabbit configuration.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: d2d1fd904b

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

}
results.push({ result, error })
}
return { resident, contact, user, results }

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Preserve start message ids in cached call status

When start pushes are now returned as results, parseStartingMessagesIdsByUserIdsByMessageResults still reads promiseResult.value.result?.id, so this new return shape leaves startingMessagesIdsByUserIds empty for every successful call. SendVoIPCallCancelMessageService later uses that cache to fill voipIncomingCallId for cancel pushes, so older mobile clients that rely on the start message id will receive cancel messages without it.

Useful? React with 👍 / 👎.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
apps/condo/domains/miniapp/schema/SendVoIPCallStartMessageService.js (1)

79-93: ⚠️ Potential issue | 🟠 Major | ⚡ Quick win

parseStartingMessagesIdsByUserIdsByMessageResults does not handle the new results array structure.

The function destructures result (singular) on line 86, but the promise now resolves to { resident, contact, user, results } with a plural results array (line 306). This means result?.id on line 87 will always be undefined, and no starting message IDs will be cached for call status tracking.

🐛 Proposed fix
 function parseStartingMessagesIdsByUserIdsByMessageResults ({ sendMessagePromisesResults }) {
     const startingMessagesIdsByUserIds = {}
     for (const promiseResult of sendMessagePromisesResults) {
         if (promiseResult.status !== 'fulfilled') {
             continue
         }

-        const { user, result } = promiseResult.value
-        if (result?.id) {
-            startingMessagesIdsByUserIds[user.id] = result.id
+        const { user, results } = promiseResult.value
+        // Use the first successfully created message ID for call status tracking
+        const firstSuccessfulResult = results?.find(r => r.result?.id)
+        if (firstSuccessfulResult?.result?.id) {
+            startingMessagesIdsByUserIds[user.id] = firstSuccessfulResult.result.id
         }
     }
     
     return startingMessagesIdsByUserIds
 }
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@apps/condo/domains/miniapp/schema/SendVoIPCallStartMessageService.js` around
lines 79 - 93, parseStartingMessagesIdsByUserIdsByMessageResults currently
expects a singular result but the promise value now contains a results array;
update the function to iterate or search promiseResult.value.results (not
promiseResult.value.result) and extract the appropriate message id (e.g. the
first element with an id) and assign it to
startingMessagesIdsByUserIds[user.id]; reference sendMessagePromisesResults,
parseStartingMessagesIdsByUserIdsByMessageResults, promiseResult.value.results
and user.id when making the change.
🧹 Nitpick comments (1)
apps/condo/domains/miniapp/schema/SendVoIPCallStartMessageService.spec.js (1)

11-17: ⚡ Quick win

Make appId behavior explicit in mocked push rules

Current setup configures only one appId, while later assertions assume deterministic behavior for both appIds. Please add explicit rules for APP_ID_DISABLED_VOIP_INCOMING_CALL_MESSAGE to avoid default-dependent/flaky assertions.

Suggested deterministic setup
         return {
             pushTypeSwitchRulesByAppId: { 
                 [APP_ID_ENABLED_VOIP_INCOMING_CALL_MESSAGE]: { 
                     [VOIP_INCOMING_CALL_MESSAGE_TYPE]: 'enabled',
                     [VOIP_INCOMING_NATIVE_CALL_MESSAGE_TYPE]: 'disabled',
                     [VOIP_INCOMING_B2C_APP_CALL_MESSAGE_TYPE]: 'disabled',
                 },
+                [APP_ID_DISABLED_VOIP_INCOMING_CALL_MESSAGE]: {
+                    [VOIP_INCOMING_CALL_MESSAGE_TYPE]: 'disabled',
+                    [VOIP_INCOMING_NATIVE_CALL_MESSAGE_TYPE]: 'enabled',
+                    [VOIP_INCOMING_B2C_APP_CALL_MESSAGE_TYPE]: 'enabled',
+                },
             },
         }
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@apps/condo/domains/miniapp/schema/SendVoIPCallStartMessageService.spec.js`
around lines 11 - 17, The mocked push rules only define
pushTypeSwitchRulesByAppId for APP_ID_ENABLED_VOIP_INCOMING_CALL_MESSAGE but
tests later assume deterministic behavior for both app IDs; add an explicit
entry for APP_ID_DISABLED_VOIP_INCOMING_CALL_MESSAGE inside
pushTypeSwitchRulesByAppId mirroring the enabled app's structure with the
desired 'enabled'/'disabled' values for VOIP_INCOMING_CALL_MESSAGE_TYPE,
VOIP_INCOMING_NATIVE_CALL_MESSAGE_TYPE, and
VOIP_INCOMING_B2C_APP_CALL_MESSAGE_TYPE so assertions no longer rely on defaults
and become deterministic; update the mock in the spec where
pushTypeSwitchRulesByAppId is defined and ensure constants
APP_ID_DISABLED_VOIP_INCOMING_CALL_MESSAGE, VOIP_INCOMING_CALL_MESSAGE_TYPE,
VOIP_INCOMING_NATIVE_CALL_MESSAGE_TYPE, and
VOIP_INCOMING_B2C_APP_CALL_MESSAGE_TYPE are used.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@apps/condo/domains/miniapp/schema/SendVoIPCallStartMessageService.test.js`:
- Around line 873-880: The test assertion for createdNativeMessages incorrectly
expects VOIP_INCOMING_NATIVE_CALL_MESSAGE_TYPE twice; update the expectation to
assert that createdNativeMessages contains one object with type
VOIP_INCOMING_CALL_MESSAGE_TYPE (legacy) and one object with type
VOIP_INCOMING_NATIVE_CALL_MESSAGE_TYPE (native-specific), i.e., change one of
the expect.objectContaining entries to use VOIP_INCOMING_CALL_MESSAGE_TYPE so
the array assertion checks for both message types.

---

Outside diff comments:
In `@apps/condo/domains/miniapp/schema/SendVoIPCallStartMessageService.js`:
- Around line 79-93: parseStartingMessagesIdsByUserIdsByMessageResults currently
expects a singular result but the promise value now contains a results array;
update the function to iterate or search promiseResult.value.results (not
promiseResult.value.result) and extract the appropriate message id (e.g. the
first element with an id) and assign it to
startingMessagesIdsByUserIds[user.id]; reference sendMessagePromisesResults,
parseStartingMessagesIdsByUserIdsByMessageResults, promiseResult.value.results
and user.id when making the change.

---

Nitpick comments:
In `@apps/condo/domains/miniapp/schema/SendVoIPCallStartMessageService.spec.js`:
- Around line 11-17: The mocked push rules only define
pushTypeSwitchRulesByAppId for APP_ID_ENABLED_VOIP_INCOMING_CALL_MESSAGE but
tests later assume deterministic behavior for both app IDs; add an explicit
entry for APP_ID_DISABLED_VOIP_INCOMING_CALL_MESSAGE inside
pushTypeSwitchRulesByAppId mirroring the enabled app's structure with the
desired 'enabled'/'disabled' values for VOIP_INCOMING_CALL_MESSAGE_TYPE,
VOIP_INCOMING_NATIVE_CALL_MESSAGE_TYPE, and
VOIP_INCOMING_B2C_APP_CALL_MESSAGE_TYPE so assertions no longer rely on defaults
and become deterministic; update the mock in the spec where
pushTypeSwitchRulesByAppId is defined and ensure constants
APP_ID_DISABLED_VOIP_INCOMING_CALL_MESSAGE, VOIP_INCOMING_CALL_MESSAGE_TYPE,
VOIP_INCOMING_NATIVE_CALL_MESSAGE_TYPE, and
VOIP_INCOMING_B2C_APP_CALL_MESSAGE_TYPE are used.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 99356129-1530-4a01-9894-ac66e17ce8d2

📥 Commits

Reviewing files that changed from the base of the PR and between 0d406e4 and d2d1fd9.

📒 Files selected for processing (22)
  • apps/condo/domains/miniapp/schema/SendVoIPCallStartMessageService.js
  • apps/condo/domains/miniapp/schema/SendVoIPCallStartMessageService.spec.js
  • apps/condo/domains/miniapp/schema/SendVoIPCallStartMessageService.test.js
  • apps/condo/domains/miniapp/utils/sendVoIPCallMessage.js
  • apps/condo/domains/miniapp/utils/testSchema/index.js
  • apps/condo/domains/notification/constants/constants.js
  • apps/condo/domains/notification/transports/push.js
  • apps/condo/lang/en/en.json
  • apps/condo/lang/en/messages/VOIP_INCOMING_B2C_APP_CALL_MESSAGE/default.njk
  • apps/condo/lang/en/messages/VOIP_INCOMING_B2C_APP_CALL_MESSAGE/push.njk
  • apps/condo/lang/en/messages/VOIP_INCOMING_NATIVE_CALL_MESSAGE/default.njk
  • apps/condo/lang/en/messages/VOIP_INCOMING_NATIVE_CALL_MESSAGE/push.njk
  • apps/condo/lang/es/es.json
  • apps/condo/lang/es/messages/VOIP_INCOMING_B2C_APP_CALL_MESSAGE/default.njk
  • apps/condo/lang/es/messages/VOIP_INCOMING_B2C_APP_CALL_MESSAGE/push.njk
  • apps/condo/lang/es/messages/VOIP_INCOMING_NATIVE_CALL_MESSAGE/default.njk
  • apps/condo/lang/es/messages/VOIP_INCOMING_NATIVE_CALL_MESSAGE/push.njk
  • apps/condo/lang/ru/messages/VOIP_INCOMING_B2C_APP_CALL_MESSAGE/default.njk
  • apps/condo/lang/ru/messages/VOIP_INCOMING_B2C_APP_CALL_MESSAGE/push.njk
  • apps/condo/lang/ru/messages/VOIP_INCOMING_NATIVE_CALL_MESSAGE/default.njk
  • apps/condo/lang/ru/messages/VOIP_INCOMING_NATIVE_CALL_MESSAGE/push.njk
  • apps/condo/lang/ru/ru.json

Comment on lines +873 to +880
expect(createdNativeMessages).toEqual(expect.arrayContaining([
expect.objectContaining({
type: VOIP_INCOMING_NATIVE_CALL_MESSAGE_TYPE,
}),
expect.objectContaining({
type: VOIP_INCOMING_NATIVE_CALL_MESSAGE_TYPE,
}),
]))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Fix native-call message type assertion

Line 878 expects VOIP_INCOMING_NATIVE_CALL_MESSAGE_TYPE twice, but native flow should create one legacy VOIP_INCOMING_CALL_MESSAGE_TYPE plus one native-specific message.

Proposed fix
                 expect(createdNativeMessages).toEqual(expect.arrayContaining([
                     expect.objectContaining({
-                        type: VOIP_INCOMING_NATIVE_CALL_MESSAGE_TYPE,
+                        type: VOIP_INCOMING_CALL_MESSAGE_TYPE,
                     }),
                     expect.objectContaining({
                         type: VOIP_INCOMING_NATIVE_CALL_MESSAGE_TYPE,
                     }),
                 ]))
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
expect(createdNativeMessages).toEqual(expect.arrayContaining([
expect.objectContaining({
type: VOIP_INCOMING_NATIVE_CALL_MESSAGE_TYPE,
}),
expect.objectContaining({
type: VOIP_INCOMING_NATIVE_CALL_MESSAGE_TYPE,
}),
]))
expect(createdNativeMessages).toEqual(expect.arrayContaining([
expect.objectContaining({
type: VOIP_INCOMING_CALL_MESSAGE_TYPE,
}),
expect.objectContaining({
type: VOIP_INCOMING_NATIVE_CALL_MESSAGE_TYPE,
}),
]))
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@apps/condo/domains/miniapp/schema/SendVoIPCallStartMessageService.test.js`
around lines 873 - 880, The test assertion for createdNativeMessages incorrectly
expects VOIP_INCOMING_NATIVE_CALL_MESSAGE_TYPE twice; update the expectation to
assert that createdNativeMessages contains one object with type
VOIP_INCOMING_CALL_MESSAGE_TYPE (legacy) and one object with type
VOIP_INCOMING_NATIVE_CALL_MESSAGE_TYPE (native-specific), i.e., change one of
the expect.objectContaining entries to use VOIP_INCOMING_CALL_MESSAGE_TYPE so
the array assertion checks for both message types.

@sonarqubecloud

sonarqubecloud Bot commented Jun 5, 2026

Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant