From 77bb2b2c717f00f239c5800a9ca165283e8642cd Mon Sep 17 00:00:00 2001 From: Nevo David Date: Wed, 29 Jan 2025 00:49:54 +0700 Subject: [PATCH] feat: bluesky refresh + allow for any username --- .../src/api/routes/integrations.controller.ts | 59 ++++++++++--------- .../src/components/launches/menu/menu.tsx | 59 +++++++++++++++++-- .../integrations/social/bluesky.provider.ts | 2 +- 3 files changed, 88 insertions(+), 32 deletions(-) diff --git a/apps/backend/src/api/routes/integrations.controller.ts b/apps/backend/src/api/routes/integrations.controller.ts index e2999098..f623162a 100644 --- a/apps/backend/src/api/routes/integrations.controller.ts +++ b/apps/backend/src/api/routes/integrations.controller.ts @@ -86,30 +86,37 @@ export class IntegrationsController { @Get('/list') async getIntegrationList(@GetOrgFromRequest() org: Organization) { return { - integrations: ( - await this._integrationService.getIntegrationsList(org.id) - ).map((p) => { - const findIntegration = this._integrationManager.getSocialIntegration( - p.providerIdentifier - ); - return { - name: p.name, - id: p.id, - internalId: p.internalId, - disabled: p.disabled, - picture: p.picture || '/no-picture.jpg', - identifier: p.providerIdentifier, - inBetweenSteps: p.inBetweenSteps, - refreshNeeded: p.refreshNeeded, - display: p.profile, - type: p.type, - time: JSON.parse(p.postingTimes), - changeProfilePicture: !!findIntegration?.changeProfilePicture, - changeNickName: !!findIntegration?.changeNickname, - customer: p.customer, - additionalSettings: p.additionalSettings || '[]', - }; - }), + integrations: await Promise.all( + (await this._integrationService.getIntegrationsList(org.id)).map( + async (p) => { + const findIntegration = + this._integrationManager.getSocialIntegration( + p.providerIdentifier + ); + return { + name: p.name, + id: p.id, + internalId: p.internalId, + disabled: p.disabled, + picture: p.picture || '/no-picture.jpg', + identifier: p.providerIdentifier, + inBetweenSteps: p.inBetweenSteps, + refreshNeeded: p.refreshNeeded, + isCustomFields: !!findIntegration.customFields, + ...(findIntegration.customFields + ? { customFields: await findIntegration.customFields() } + : {}), + display: p.profile, + type: p.type, + time: JSON.parse(p.postingTimes), + changeProfilePicture: !!findIntegration?.changeProfilePicture, + changeNickName: !!findIntegration?.changeNickname, + customer: p.customer, + additionalSettings: p.additionalSettings || '[]', + }; + } + ) + ), }; } @@ -612,9 +619,7 @@ export class IntegrationsController { } @Get('/telegram/updates') - async getUpdates( - @Query() query: { word: string; id?: number }, - ) { + async getUpdates(@Query() query: { word: string; id?: number }) { return new TelegramProvider().getBotId(query); } } diff --git a/apps/frontend/src/components/launches/menu/menu.tsx b/apps/frontend/src/components/launches/menu/menu.tsx index 0b8d8036..ab8de037 100644 --- a/apps/frontend/src/components/launches/menu/menu.tsx +++ b/apps/frontend/src/components/launches/menu/menu.tsx @@ -1,4 +1,10 @@ -import { FC, MouseEventHandler, useCallback, useMemo, useState } from 'react'; +import React, { + FC, + MouseEventHandler, + useCallback, + useMemo, + useState, +} from 'react'; import { useClickOutside } from '@mantine/hooks'; import { useFetch } from '@gitroom/helpers/utils/custom.fetch'; import { deleteDialog } from '@gitroom/react/helpers/delete.dialog'; @@ -11,6 +17,9 @@ import { BotPicture } from '@gitroom/frontend/components/launches/bot.picture'; import { CustomerModal } from '@gitroom/frontend/components/launches/customer.modal'; import { Integration } from '@prisma/client'; import { SettingsModal } from '@gitroom/frontend/components/launches/settings.modal'; +import { string } from 'yup'; +import { CustomVariables } from '@gitroom/frontend/components/launches/add.provider.component'; +import { useRouter } from 'next/navigation'; export const Menu: FC<{ canEnable: boolean; @@ -35,6 +44,7 @@ export const Menu: FC<{ refreshChannel, } = props; const fetch = useFetch(); + const router = useRouter(); const { integrations } = useCalendar(); const toast = useToaster(); const modal = useModals(); @@ -209,6 +219,23 @@ export const Menu: FC<{ setShow(false); }, [integrations]); + const updateCredentials = useCallback(() => { + modal.openModal({ + title: '', + withCloseButton: false, + classNames: { + modal: 'bg-transparent text-textColor', + }, + children: ( + router.push(url + '&refresh=true')} + variables={findIntegration.customFields} + /> + ), + }); + }, []); + return (
e.stopPropagation()} className={`absolute top-[100%] left-0 p-[8px] px-[20px] bg-fifth flex flex-col gap-[16px] z-[100] rounded-[8px] border border-tableBorder ${interClass} text-nowrap`} > - {canDisable && findIntegration?.refreshNeeded && ( + {canDisable && + findIntegration?.refreshNeeded && + !findIntegration.customFields && ( +
+
+ + + +
+
Reconnect channel
+
+ )} + {!!findIntegration?.isCustomFields && (
-
Reconnect channel
+
Update Credentials
)} {findIntegration?.additionalSettings !== '[]' && ( diff --git a/libraries/nestjs-libraries/src/integrations/social/bluesky.provider.ts b/libraries/nestjs-libraries/src/integrations/social/bluesky.provider.ts index 36194910..61a5fe6b 100644 --- a/libraries/nestjs-libraries/src/integrations/social/bluesky.provider.ts +++ b/libraries/nestjs-libraries/src/integrations/social/bluesky.provider.ts @@ -69,7 +69,7 @@ export class BlueskyProvider extends SocialAbstract implements SocialProvider { { key: 'identifier', label: 'Identifier', - validation: `/^.{3,}$/`, + validation: `/^.+$/`, type: 'text' as const, }, {