-
Notifications
You must be signed in to change notification settings - Fork 115
feat(condo): DOMA-12905 add mutation to send voip start message to all verified residents on address + unit #7204
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
494ef04
dc4f8b5
eec97df
b4df992
d87acf0
65e18c4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| const { throwAuthenticationError } = require('@open-condo/keystone/apolloErrorFormatter') | ||
|
|
||
| const { canExecuteServiceAsB2CAppServiceUser } = require('@condo/domains/miniapp/utils/b2cAppServiceUserAccess/server.utils') | ||
| const { SERVICE } = require('@condo/domains/user/constants/common') | ||
|
|
||
| async function canSendVoIPStartMessage (args) { | ||
| const { authentication: { item: user } } = args | ||
|
|
||
| if (!user) return throwAuthenticationError() | ||
| if (user.deletedAt) return false | ||
| if (user.isAdmin) return true | ||
|
|
||
| if (user.type === SERVICE) { | ||
| return await canExecuteServiceAsB2CAppServiceUser(args) | ||
| } | ||
|
|
||
| return false | ||
| } | ||
|
|
||
| module.exports = { | ||
| canSendVoIPStartMessage, | ||
| } | ||
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -4,20 +4,22 @@ | |||||||||||||
|
|
||||||||||||||
| const { faker } = require('@faker-js/faker') | ||||||||||||||
|
|
||||||||||||||
| const { makeLoggedInAdminClient, makeClient, UUID_RE } = require('@open-condo/keystone/test.utils') | ||||||||||||||
| const { makeLoggedInAdminClient, makeClient, UUID_RE, expectToThrowAccessDeniedErrorToResult } = require('@open-condo/keystone/test.utils') | ||||||||||||||
| const { | ||||||||||||||
| expectToThrowAuthenticationErrorToObj, expectToThrowAuthenticationErrorToObjects, | ||||||||||||||
| expectToThrowAccessDeniedErrorToObj, expectToThrowAccessDeniedErrorToObjects, | ||||||||||||||
| } = require('@open-condo/keystone/test.utils') | ||||||||||||||
|
|
||||||||||||||
|
|
||||||||||||||
|
|
||||||||||||||
| const { B2CAppAccessRightSet, createTestB2CAppAccessRightSet, updateTestB2CAppAccessRightSet, createTestB2CAppProperty, updateTestB2CAppProperty, B2CAppProperty } = require('@condo/domains/miniapp/utils/testSchema') | ||||||||||||||
| const { B2CAppAccessRightSet, createTestB2CAppAccessRightSet, updateTestB2CAppAccessRightSet, createTestB2CAppProperty, updateTestB2CAppProperty, B2CAppProperty, sendVoIPStartMessageByTestClient, updateTestB2CAppAccessRight } = require('@condo/domains/miniapp/utils/testSchema') | ||||||||||||||
| const { createTestB2CApp, createTestB2CAppAccessRight } = require('@condo/domains/miniapp/utils/testSchema') | ||||||||||||||
| const { FLAT_UNIT_TYPE } = require('@condo/domains/property/constants/common') | ||||||||||||||
| const { buildFakeAddressAndMeta } = require('@condo/domains/property/utils/testSchema/factories') | ||||||||||||||
| const { makeClientWithNewRegisteredAndLoggedInUser, makeClientWithSupportUser } = require('@condo/domains/user/utils/testSchema') | ||||||||||||||
| const { makeClientWithServiceUser } = require('@condo/domains/user/utils/testSchema') | ||||||||||||||
|
|
||||||||||||||
|
|
||||||||||||||
| describe('B2CAppAccessRightSet', () => { | ||||||||||||||
| let admin | ||||||||||||||
|
|
||||||||||||||
|
|
@@ -304,13 +306,14 @@ describe('B2CAppAccessRightSet', () => { | |||||||||||||
| let user | ||||||||||||||
| let b2cApp | ||||||||||||||
| let serviceUser | ||||||||||||||
| let b2cAccessRight | ||||||||||||||
|
|
||||||||||||||
| beforeEach(async () => { | ||||||||||||||
| support = await makeClientWithSupportUser() | ||||||||||||||
| user = await makeClientWithNewRegisteredAndLoggedInUser() | ||||||||||||||
| serviceUser = await makeClientWithServiceUser(); | ||||||||||||||
| [b2cApp] = await createTestB2CApp(admin) | ||||||||||||||
| await createTestB2CAppAccessRight(admin, serviceUser.user, b2cApp) | ||||||||||||||
| [b2cApp] = await createTestB2CApp(admin); | ||||||||||||||
|
Comment on lines
314
to
+315
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remove semicolons from the changed setup lines. These two lines violate the repo’s JavaScript style rule. Style fix- serviceUser = await makeClientWithServiceUser();
- [b2cApp] = await createTestB2CApp(admin);
+ serviceUser = await makeClientWithServiceUser()
+ [b2cApp] = await createTestB2CApp(admin)As per coding guidelines, 📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||
| [b2cAccessRight] = await createTestB2CAppAccessRight(admin, serviceUser.user, b2cApp) | ||||||||||||||
| }) | ||||||||||||||
|
|
||||||||||||||
| test('B2CAppAccessRightSet', async () => { | ||||||||||||||
|
|
@@ -418,6 +421,57 @@ describe('B2CAppAccessRightSet', () => { | |||||||||||||
| expect(foundB2CAppProperty.id).toEqual(createdB2CAppProperty.id) | ||||||||||||||
|
|
||||||||||||||
| }) | ||||||||||||||
|
|
||||||||||||||
| test('SendVoIPStartMessageService', async () => { | ||||||||||||||
| const args = { | ||||||||||||||
| app: { id: b2cApp.id }, | ||||||||||||||
| addressKey: faker.datatype.uuid(), | ||||||||||||||
| unitName: faker.random.alphaNumeric(8), | ||||||||||||||
| unitType: FLAT_UNIT_TYPE, | ||||||||||||||
| callData: { | ||||||||||||||
| callId: faker.random.alphaNumeric(8), | ||||||||||||||
| b2cAppCallData: { | ||||||||||||||
| B2CAppContext: faker.random.alphaNumeric(8), | ||||||||||||||
| }, | ||||||||||||||
| }, | ||||||||||||||
| } | ||||||||||||||
|
|
||||||||||||||
| // Can't without access right set | ||||||||||||||
| await expectToThrowAccessDeniedErrorToResult(async () => { | ||||||||||||||
| await sendVoIPStartMessageByTestClient(serviceUser, args) | ||||||||||||||
| }) | ||||||||||||||
|
|
||||||||||||||
| // Can't with access right set and without b2c app property | ||||||||||||||
| const [rightSet] = await createTestB2CAppAccessRightSet(support, b2cApp, { canExecuteSendVoIPStartMessage: true }) | ||||||||||||||
| await updateTestB2CAppAccessRight(support, b2cAccessRight.id, { accessRightSet: { connect: { id: rightSet.id } } }) | ||||||||||||||
| await expectToThrowAccessDeniedErrorToResult(async () => { | ||||||||||||||
| await sendVoIPStartMessageByTestClient(serviceUser, args) | ||||||||||||||
| }) | ||||||||||||||
|
|
||||||||||||||
| // Can with access right set and b2c app property | ||||||||||||||
| const [b2cAppProperty] = await createTestB2CAppProperty(serviceUser, b2cApp) | ||||||||||||||
| args.addressKey = b2cAppProperty.addressKey | ||||||||||||||
| const [result] = await sendVoIPStartMessageByTestClient(serviceUser, args) | ||||||||||||||
| expect(result).toEqual(expect.objectContaining({ | ||||||||||||||
| verifiedContactsCount: expect.any(Number), | ||||||||||||||
| createdMessagesCount: expect.any(Number), | ||||||||||||||
| erroredMessagesCount: expect.any(Number), | ||||||||||||||
| })) | ||||||||||||||
|
|
||||||||||||||
| // Can't with access right and another b2c app proeprty | ||||||||||||||
| const [anotherB2CApp] = await createTestB2CApp(admin) | ||||||||||||||
| const [anotherB2CAppProperty] = await createTestB2CAppProperty(admin, anotherB2CApp) | ||||||||||||||
| args.addressKey = anotherB2CAppProperty.addressKey | ||||||||||||||
| await expectToThrowAccessDeniedErrorToResult(async () => { | ||||||||||||||
| await sendVoIPStartMessageByTestClient(serviceUser, args) | ||||||||||||||
| }) | ||||||||||||||
|
|
||||||||||||||
| // Can't for another app | ||||||||||||||
| args.app.id = anotherB2CApp.id | ||||||||||||||
| await expectToThrowAccessDeniedErrorToResult(async () => { | ||||||||||||||
| await sendVoIPStartMessageByTestClient(serviceUser, args) | ||||||||||||||
| }) | ||||||||||||||
| }) | ||||||||||||||
| }) | ||||||||||||||
|
|
||||||||||||||
| }) | ||||||||||||||
|
|
||||||||||||||
Uh oh!
There was an error while loading. Please reload this page.