Skip to content

Commit 1a2ebe1

Browse files
feat(condo): DOMA-13296 add webhook transport (#7750)
* feat(condo): DOMA-13296 add messanger transport * feat(condo): DOMA-13299 add template and fix api * feat(condo): DOMA-13296 add webhook transport * feat(condo): DOMA-13296 add webhook transport * feat(condo): DOMA-13296 fix bot name * feat(condo): DOMA-13296 undo delete telegram * feat(condo): DOMA-13296 fix naming * feat(condo): DOMA-13296 review fixes * feat(condo): DOMA-13296 review fixes * feat(condo): DOMA-13296 review fixes * feat(condo): DOMA-13296 fix work with webhook render * feat(condo): DOMA-13296 review fix * feat(condo): DOMA-13296 update submodules * feat(condo): DOMA-13296 review fix * feat(condo): DOMA-13296 fix build * feat(condo): DOMA-13296 review fix * feat(condo): DOMA-13296 fix translations * feat(condo): DOMA-13296 update submodules * feat(condo): DOMA-13296 undo changes * feat(condo): DOMA-13296 undo changes * feat(condo): DOMA-13296 update submodules * feat(condo): DOMA-13296 update submodules * feat(condo): DOMA-13296 fix conflict * feat(condo): DOMA-13296 fix build * feat(condo): DOMA-13296 add nosemgrep --------- Co-authored-by: Profitro1ka <189228262+Alexander-Turkin@users.noreply.github.com>
1 parent 77b26e0 commit 1a2ebe1

6 files changed

Lines changed: 26 additions & 11 deletions

File tree

.helm

Submodule .helm updated from 4758b33 to d89da62

apps/condo/domains/notification/tasks/deliverMessage.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ const {
1414
SMS_TRANSPORT,
1515
EMAIL_TRANSPORT,
1616
PUSH_TRANSPORT,
17-
TELEGRAM_TRANSPORT,
1817
MESSAGE_SENDING_STATUS,
1918
MESSAGE_RESENDING_STATUS,
2019
MESSAGE_PROCESSING_STATUS,
@@ -24,6 +23,7 @@ const {
2423
MESSAGE_DISABLED_BY_USER_STATUS,
2524
MESSAGE_DELIVERY_STRATEGY_AT_LEAST_ONE_TRANSPORT,
2625
MESSAGE_THROTTLED_STATUS,
26+
TELEGRAM_TRANSPORT,
2727
} = require('@condo/domains/notification/constants/constants')
2828
const { ONE_MESSAGE_PER_THROTTLING_PERIOD_FOR_USER } = require('@condo/domains/notification/constants/errors')
2929
const emailAdapter = require('@condo/domains/notification/transports/email')

apps/condo/domains/notification/templates.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ function normalizeSMSText (text) {
209209
function substituteTranslations (item, locale) {
210210
if (isArray(item)) return item.map(itemValue => substituteTranslations(itemValue, locale))
211211
if (isObject(item)) return translateObjectItems(item, locale)
212-
212+
213213
return getLocalized(locale, item)
214214
}
215215

@@ -316,16 +316,16 @@ function emailRenderer ({ message, env }) {
316316
function pushRenderer ({ message, env, additionalParams }) {
317317
const { lang: locale, type } = message
318318
const messageTranslated = substituteTranslations(message, locale)
319-
319+
320320
const appId = additionalParams?.appId
321321
const overridesForAppId = PUSH_MESSAGE_OVERRIDES?.[appId]
322322

323323
const titleKey = translationStringKeyForPushTitle(type)
324324
const bodyKey = translationStringKeyForPushBody(type)
325-
325+
326326
let renderedTitle
327327
let renderedBody
328-
328+
329329
if (appId && overridesForAppId) {
330330
const overrides = overridesForAppId[locale]
331331
const titleTemplate = overrides?.[titleKey]

apps/condo/domains/notification/transports/push.js

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ const logger = getLogger()
4545

4646
/** @type {PushAdapterSettings} */
4747
const PUSH_ADAPTER_SETTINGS = JSON.parse(conf.PUSH_ADAPTER_SETTINGS || '{}')
48+
const DISABLED_TYPES_EXCEPTIONS_BY_APP_ID = JSON.parse(conf.DISABLED_TYPES_EXCEPTIONS_BY_APP_ID || '[]')
4849

4950
const PUSH_DATA_VALIDATORS_BY_APP_ID = Object.fromEntries(
5051
Object.entries(PUSH_ADAPTER_SETTINGS.pushDataValidatorsByAppId || {})
@@ -323,11 +324,23 @@ async function send ({ notification, message, data, user, remoteClient } = {}, i
323324
const userId = get(user, 'id')
324325
const remoteClientId = get(remoteClient, 'id')
325326

326-
if (TEMPORARY_DISABLED_TYPES_FOR_PUSH_NOTIFICATIONS.includes(get(message, 'type'))) {
327-
return [false, { error: 'Disabled type for push transport' }]
327+
let pushTokens = await getTokens(userId, remoteClientId, isVoIP, PUSH_ADAPTER_SETTINGS.transportPriorityByAppId)
328+
329+
const messageType = get(message, 'type')
330+
if (TEMPORARY_DISABLED_TYPES_FOR_PUSH_NOTIFICATIONS.includes(messageType)) {
331+
const allowedAppIds = DISABLED_TYPES_EXCEPTIONS_BY_APP_ID?.[messageType] || []
332+
333+
if (allowedAppIds.length > 0) {
334+
pushTokens = pushTokens.filter(token => allowedAppIds.includes(token.appId))
335+
336+
if (pushTokens.length === 0) {
337+
return [false, { error: 'Disabled type for push transport (no allowed appIds found)' }]
338+
}
339+
} else {
340+
return [false, { error: 'Disabled type for push transport' }]
341+
}
328342
}
329343

330-
let pushTokens = await getTokens(userId, remoteClientId, isVoIP, PUSH_ADAPTER_SETTINGS.transportPriorityByAppId)
331344
// NOTE: For some message types with push transport, you need to override the push type for all push tokens.
332345
// If the message has a preferred push type, it takes priority over the value from the remote client.
333346
const preferredPushTypeForMessage = getPreferredPushTypeByMessageType(get(message, 'type'))

apps/employee-bot

yarn.lock

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1080,18 +1080,20 @@ __metadata:
10801080
"@employee-bot/domains": "link:./domains"
10811081
"@graphql-tools/graphql-file-loader": "npm:^7.5.17"
10821082
"@graphql-tools/load": "npm:^8.1.0"
1083+
"@maxhub/max-bot-api": "npm:^0.2.2"
10831084
"@open-condo/cli": "workspace:^"
10841085
"@open-condo/codegen": "workspace:^"
10851086
"@open-condo/config": "workspace:^"
1087+
"@open-condo/featureflags": "workspace:^"
10861088
"@open-condo/keystone": "workspace:^"
10871089
"@types/node": "npm:^24"
1088-
axios: "npm:^1.15.0"
10891090
commander: "npm:14.0.1"
10901091
express: "npm:^4.17.1"
10911092
graphql: "npm:^16.10.0"
10921093
https-proxy-agent: "npm:^7.0.1"
10931094
jest: "npm:^29.7.0"
10941095
jest-jasmine2: "npm:^29.7.0"
1096+
jsonwebtoken: "npm:^9.0.0"
10951097
lodash: "npm:^4.17.21"
10961098
node-telegram-bot-api: "npm:^0.66.0"
10971099
openid-client: "npm:5.7.1"

0 commit comments

Comments
 (0)