Skip to content

Commit

Permalink
Merge pull request #335 from gitroomhq/feat/fix-variables
Browse files Browse the repository at this point in the history
Fix variables injections when building a docker
  • Loading branch information
nevo-david authored Oct 7, 2024
2 parents 68af7c5 + b818e58 commit 52e3746
Show file tree
Hide file tree
Showing 8 changed files with 16 additions and 8 deletions.
1 change: 1 addition & 0 deletions apps/backend/src/api/routes/integrations.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ export class IntegrationsController {
identifier: p.providerIdentifier,
inBetweenSteps: p.inBetweenSteps,
refreshNeeded: p.refreshNeeded,
display: p.profile,
type: p.type,
time: JSON.parse(p.postingTimes),
changeProfilePicture: !!findIntegration?.changeProfilePicture,
Expand Down
1 change: 1 addition & 0 deletions apps/frontend/src/app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export default async function AppLayout({ children }: { children: ReactNode }) {
</head>
<body className={clsx(chakra.className, 'text-primary dark')}>
<VariableContextComponent
storageProvider={process.env.NEXT_PUBLIC_STORAGE_PROVIDER! as 'local' | 'cloudflare'}
backendUrl={process.env.NEXT_PUBLIC_BACKEND_URL!}
plontoKey={process.env.NEXT_PUBLIC_POLOTNO!}
billingEnabled={!!process.env.STRIPE_PUBLISHABLE_KEY}
Expand Down
1 change: 1 addition & 0 deletions apps/frontend/src/components/launches/calendar.context.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ export interface Integrations {
id: string;
disabled?: boolean;
inBetweenSteps: boolean;
display: string;
identifier: string;
type: string;
picture: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export const GeneralPreviewComponent: FC<{maximumCharacters?: number}> = (props)
</svg>
</div>
<div className="text-[15px] font-[400] text-customColor27 ml-[4px]">
@username
{integration?.display || '@username'}
</div>
</div>
<pre className={clsx('text-wrap', chakra.className)} dangerouslySetInnerHTML={{__html: value.text}} />
Expand Down
5 changes: 3 additions & 2 deletions apps/frontend/src/components/media/new.uploader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { FileInput, ProgressBar } from '@uppy/react';
// Uppy styles
import '@uppy/core/dist/style.min.css';
import '@uppy/dashboard/dist/style.min.css';
import { useVariables } from '@gitroom/react/helpers/variable.context';

export function MultipartFileUploader({
onUploadSuccess,
Expand Down Expand Up @@ -58,7 +59,7 @@ export function MultipartFileUploaderAfter({
onUploadSuccess: (result: UploadResult) => void;
allowedFileTypes: string;
}) {
const storageProvider = process.env.NEXT_PUBLIC_STORAGE_PROVIDER || "local";
const {storageProvider, backendUrl} = useVariables();
const fetch = useFetch();

const uppy = useMemo(() => {
Expand All @@ -71,7 +72,7 @@ export function MultipartFileUploaderAfter({
},
});

const { plugin, options } = getUppyUploadPlugin(storageProvider, fetch)
const { plugin, options } = getUppyUploadPlugin(storageProvider, fetch, backendUrl)
uppy2.use(plugin, options)
// Set additional metadata when a file is added
uppy2.on('file-added', (file) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,11 +115,11 @@ export class TiktokProvider extends SocialAbstract implements SocialProvider {

const {
data: {
user: { avatar_url, display_name, open_id },
user: { avatar_url, display_name, open_id, username },
},
} = await (
await fetch(
'https://open.tiktokapis.com/v2/user/info/?fields=open_id,avatar_url,display_name',
'https://open.tiktokapis.com/v2/user/info/?fields=open_id,avatar_url,display_name,union_id',
{
method: 'GET',
headers: {
Expand All @@ -129,14 +129,16 @@ export class TiktokProvider extends SocialAbstract implements SocialProvider {
)
).json();

console.log(username);

return {
id: open_id.replace(/-/g, ''),
name: display_name,
accessToken: access_token,
refreshToken: refresh_token,
expiresIn: dayjs().add(23, 'hours').unix() - dayjs().unix(),
picture: avatar_url,
username: display_name.toLowerCase(),
username: display_name,
};
}

Expand Down
4 changes: 2 additions & 2 deletions libraries/react-shared-libraries/src/helpers/uppy.upload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const fetchUploadApiEndpoint = async (
};

// Define the factory to return appropriate Uppy configuration
export const getUppyUploadPlugin = (provider: string, fetch: any) => {
export const getUppyUploadPlugin = (provider: string, fetch: any, backendUrl: string) => {
switch (provider) {
case 'cloudflare':
return {
Expand Down Expand Up @@ -56,7 +56,7 @@ export const getUppyUploadPlugin = (provider: string, fetch: any) => {
return {
plugin: XHRUpload,
options: {
endpoint: `${process.env.NEXT_PUBLIC_BACKEND_URL}/media/upload-server`,
endpoint: `${backendUrl}/media/upload-server`,
withCredentials: true,
},
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ interface VariableContextInterface {
isGeneral: boolean;
frontEndUrl: string;
plontoKey: string;
storageProvider: 'local' | 'cloudflare',
backendUrl: string;
discordUrl: string;
uploadDirectory: string;
Expand All @@ -15,6 +16,7 @@ const VariableContext = createContext({
billingEnabled: false,
isGeneral: true,
frontEndUrl: '',
storageProvider: 'local',
plontoKey: '',
backendUrl: '',
discordUrl: '',
Expand Down

0 comments on commit 52e3746

Please sign in to comment.