Skip to content

Commit 52e3746

Browse files
authored
Merge pull request #335 from gitroomhq/feat/fix-variables
Fix variables injections when building a docker
2 parents 68af7c5 + b818e58 commit 52e3746

File tree

8 files changed

+16
-8
lines changed

8 files changed

+16
-8
lines changed

apps/backend/src/api/routes/integrations.controller.ts

+1
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ export class IntegrationsController {
6060
identifier: p.providerIdentifier,
6161
inBetweenSteps: p.inBetweenSteps,
6262
refreshNeeded: p.refreshNeeded,
63+
display: p.profile,
6364
type: p.type,
6465
time: JSON.parse(p.postingTimes),
6566
changeProfilePicture: !!findIntegration?.changeProfilePicture,

apps/frontend/src/app/layout.tsx

+1
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ export default async function AppLayout({ children }: { children: ReactNode }) {
2525
</head>
2626
<body className={clsx(chakra.className, 'text-primary dark')}>
2727
<VariableContextComponent
28+
storageProvider={process.env.NEXT_PUBLIC_STORAGE_PROVIDER! as 'local' | 'cloudflare'}
2829
backendUrl={process.env.NEXT_PUBLIC_BACKEND_URL!}
2930
plontoKey={process.env.NEXT_PUBLIC_POLOTNO!}
3031
billingEnabled={!!process.env.STRIPE_PUBLISHABLE_KEY}

apps/frontend/src/components/launches/calendar.context.tsx

+1
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ export interface Integrations {
5454
id: string;
5555
disabled?: boolean;
5656
inBetweenSteps: boolean;
57+
display: string;
5758
identifier: string;
5859
type: string;
5960
picture: string;

apps/frontend/src/components/launches/general.preview.component.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ export const GeneralPreviewComponent: FC<{maximumCharacters?: number}> = (props)
5959
</svg>
6060
</div>
6161
<div className="text-[15px] font-[400] text-customColor27 ml-[4px]">
62-
@username
62+
{integration?.display || '@username'}
6363
</div>
6464
</div>
6565
<pre className={clsx('text-wrap', chakra.className)} dangerouslySetInnerHTML={{__html: value.text}} />

apps/frontend/src/components/media/new.uploader.tsx

+3-2
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import { FileInput, ProgressBar } from '@uppy/react';
99
// Uppy styles
1010
import '@uppy/core/dist/style.min.css';
1111
import '@uppy/dashboard/dist/style.min.css';
12+
import { useVariables } from '@gitroom/react/helpers/variable.context';
1213

1314
export function MultipartFileUploader({
1415
onUploadSuccess,
@@ -58,7 +59,7 @@ export function MultipartFileUploaderAfter({
5859
onUploadSuccess: (result: UploadResult) => void;
5960
allowedFileTypes: string;
6061
}) {
61-
const storageProvider = process.env.NEXT_PUBLIC_STORAGE_PROVIDER || "local";
62+
const {storageProvider, backendUrl} = useVariables();
6263
const fetch = useFetch();
6364

6465
const uppy = useMemo(() => {
@@ -71,7 +72,7 @@ export function MultipartFileUploaderAfter({
7172
},
7273
});
7374

74-
const { plugin, options } = getUppyUploadPlugin(storageProvider, fetch)
75+
const { plugin, options } = getUppyUploadPlugin(storageProvider, fetch, backendUrl)
7576
uppy2.use(plugin, options)
7677
// Set additional metadata when a file is added
7778
uppy2.on('file-added', (file) => {

libraries/nestjs-libraries/src/integrations/social/tiktok.provider.ts

+5-3
Original file line numberDiff line numberDiff line change
@@ -115,11 +115,11 @@ export class TiktokProvider extends SocialAbstract implements SocialProvider {
115115

116116
const {
117117
data: {
118-
user: { avatar_url, display_name, open_id },
118+
user: { avatar_url, display_name, open_id, username },
119119
},
120120
} = await (
121121
await fetch(
122-
'https://open.tiktokapis.com/v2/user/info/?fields=open_id,avatar_url,display_name',
122+
'https://open.tiktokapis.com/v2/user/info/?fields=open_id,avatar_url,display_name,union_id',
123123
{
124124
method: 'GET',
125125
headers: {
@@ -129,14 +129,16 @@ export class TiktokProvider extends SocialAbstract implements SocialProvider {
129129
)
130130
).json();
131131

132+
console.log(username);
133+
132134
return {
133135
id: open_id.replace(/-/g, ''),
134136
name: display_name,
135137
accessToken: access_token,
136138
refreshToken: refresh_token,
137139
expiresIn: dayjs().add(23, 'hours').unix() - dayjs().unix(),
138140
picture: avatar_url,
139-
username: display_name.toLowerCase(),
141+
username: display_name,
140142
};
141143
}
142144

libraries/react-shared-libraries/src/helpers/uppy.upload.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ const fetchUploadApiEndpoint = async (
1919
};
2020

2121
// Define the factory to return appropriate Uppy configuration
22-
export const getUppyUploadPlugin = (provider: string, fetch: any) => {
22+
export const getUppyUploadPlugin = (provider: string, fetch: any, backendUrl: string) => {
2323
switch (provider) {
2424
case 'cloudflare':
2525
return {
@@ -56,7 +56,7 @@ export const getUppyUploadPlugin = (provider: string, fetch: any) => {
5656
return {
5757
plugin: XHRUpload,
5858
options: {
59-
endpoint: `${process.env.NEXT_PUBLIC_BACKEND_URL}/media/upload-server`,
59+
endpoint: `${backendUrl}/media/upload-server`,
6060
withCredentials: true,
6161
},
6262
};

libraries/react-shared-libraries/src/helpers/variable.context.tsx

+2
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ interface VariableContextInterface {
77
isGeneral: boolean;
88
frontEndUrl: string;
99
plontoKey: string;
10+
storageProvider: 'local' | 'cloudflare',
1011
backendUrl: string;
1112
discordUrl: string;
1213
uploadDirectory: string;
@@ -15,6 +16,7 @@ const VariableContext = createContext({
1516
billingEnabled: false,
1617
isGeneral: true,
1718
frontEndUrl: '',
19+
storageProvider: 'local',
1820
plontoKey: '',
1921
backendUrl: '',
2022
discordUrl: '',

0 commit comments

Comments
 (0)