Adjust tg bot (#8412)

* Remove notification provider func

Signed-off-by: Kristina Fefelova <kristin.fefelova@gmail.com>

* Adjust tg-bot

Signed-off-by: Kristina Fefelova <kristin.fefelova@gmail.com>

* Use global integration

Signed-off-by: Kristina Fefelova <kristin.fefelova@gmail.com>

* Use workspace integration

Signed-off-by: Kristina Fefelova <kristin.fefelova@gmail.com>

* getSocialIdBySocialKey -> findFullSocialIdBySocialKey

Signed-off-by: Kristina Fefelova <kristin.fefelova@gmail.com>

* move findFullSocialIdBySocialKey to service operations

Signed-off-by: Kristina Fefelova <kristin.fefelova@gmail.com>

* use listIntegrations with account token

Signed-off-by: Kristina Fefelova <kristin.fefelova@gmail.com>

* Adjust api

Signed-off-by: Kristina Fefelova <kristin.fefelova@gmail.com>

* Fxi tests

Signed-off-by: Kristina Fefelova <kristin.fefelova@gmail.com>

---------

Signed-off-by: Kristina Fefelova <kristin.fefelova@gmail.com>
This commit is contained in:
Kristina
2025-04-10 12:54:53 +07:00
committed by GitHub
parent 80f67e3d66
commit 2aa8ae5243
59 changed files with 1666 additions and 1183 deletions
@@ -82,10 +82,10 @@ export function isUserEmployeeInFieldValueTypeMatch (
type: NotificationType,
control: TriggerControl
): boolean {
// TODO: check field type and compare with Ref<Person> or PersonId based on that
if (type.field === undefined) return false
const value = (doc as any)[type.field]
if (value == null) return false
if (value === person) return true
if (Array.isArray(value)) {
return includesAny(value, socialIds)
@@ -121,7 +121,7 @@ function escapeRegExp (str: string): string {
export async function shouldNotifyCommon (
control: TriggerControl,
user: PersonId[],
socialIds: PersonId[],
typeId: Ref<CommonNotificationType>,
notificationControl: NotificationProviderControl
): Promise<NotifyResult> {
@@ -135,7 +135,7 @@ export async function shouldNotifyCommon (
const providers = await control.modelDb.findAll(notification.class.NotificationProvider, {})
for (const provider of providers) {
const allowed = isAllowed(control, user, type, provider, notificationControl)
const allowed = isAllowed(control, socialIds, type, provider, notificationControl)
if (allowed) {
const cur = result.get(provider._id) ?? []