Skip to content

πŸ“¨ The ultimate agentic social media scheduling tool πŸ€–

feat: mobile app iframe

Nevo David88006a761439
diff --git a/apps/backend/src/api/routes/integrations.controller.ts b/apps/backend/src/api/routes/integrations.controller.ts
index 36bdc884d..5bd2f52ef 100644
--- a/apps/backend/src/api/routes/integrations.controller.ts
+++ b/apps/backend/src/api/routes/integrations.controller.ts
@@ -195,6 +195,7 @@ export class IntegrationsController {
@Param('integration') integration: string,
@Query('refresh') refresh: string,
@Query('externalUrl') externalUrl: string,
+ @Query('redirectUrl') redirectUrl: string,
@Query('onboarding') onboarding: string,
@GetOrgFromRequest() org: Organization
) {
@@ -232,6 +233,10 @@ export class IntegrationsController {
await ioRedis.set(`onboarding:${state}`, 'true', 'EX', 3600);
}
+ if (redirectUrl) {
+ await ioRedis.set(`redirect:${state}`, redirectUrl, 'EX', 3600);
+ }
+
await ioRedis.set(`organization:${state}`, org.id, 'EX', 3600);
await ioRedis.set(`login:${state}`, codeVerifier, 'EX', 3600);
await ioRedis.set(
@@ -448,9 +453,7 @@ export class IntegrationsController {
}
@Post('/moltbook/register')
- async moltbookRegister(
- @Body() body: { name: string; description: string }
- ) {
+ async moltbookRegister(@Body() body: { name: string; description: string }) {
try {
const provider = new MoltbookProvider();
const result = await provider.registerAgent(body.name, body.description);
diff --git a/apps/frontend/src/app/(provider)/layout.tsx b/apps/frontend/src/app/(provider)/layout.tsx
index f711e7de6..66c6dae04 100644
--- a/apps/frontend/src/app/(provider)/layout.tsx
+++ b/apps/frontend/src/app/(provider)/layout.tsx
@@ -1,3 +1,5 @@
+import { MantineWrapper } from '@gitroom/react/helpers/mantine.wrapper';
+
export const dynamic = 'force-dynamic';
import '../global.scss';
import 'react-tooltip/dist/react-tooltip.css';
@@ -62,10 +64,12 @@ export default async function AppLayout({ children }: { children: ReactNode }) {
: []
}
>
- <LayoutContext>
- <UtmSaver />
- {children}
- </LayoutContext>
+ <MantineWrapper>
+ <LayoutContext>
+ <UtmSaver />
+ {children}
+ </LayoutContext>
+ </MantineWrapper>
</VariableContextComponent>
</body>
</html>
diff --git a/apps/frontend/src/app/(provider)/provider/add/page.tsx b/apps/frontend/src/app/(provider)/provider/add/page.tsx
new file mode 100644
index 000000000..2610fdc39
--- /dev/null
+++ b/apps/frontend/src/app/(provider)/provider/add/page.tsx
@@ -0,0 +1,6 @@
+import React from 'react';
+import { MobileIntegration } from '@gitroom/frontend/components/new-layout/mobile.integration';
+
+export default async function Page() {
+ return <MobileIntegration />;
+}
diff --git a/apps/frontend/src/components/launches/add.provider.component.tsx b/apps/frontend/src/components/launches/add.provider.component.tsx
index 53de90bdd..96ad25d08 100644
--- a/apps/frontend/src/components/launches/add.provider.component.tsx
+++ b/apps/frontend/src/components/launches/add.provider.component.tsx
@@ -325,7 +325,8 @@ const ChromeExtensionWarning: FC<{
We will store your cookies securely to facilitate the connection.
</li>
<li>
- Postiz does not take responsibility for any issues arising or account termination due to the use of this method.
+ Postiz does not take responsibility for any issues arising or account
+ termination due to the use of this method.
</li>
</ul>
<div className="flex gap-[10px] mt-[8px]">
@@ -380,8 +381,9 @@ export const AddProviderComponent: FC<{
invite: boolean;
update?: () => void;
onboarding?: boolean;
+ isMobile?: boolean;
}> = (props) => {
- const { update, social, article, onboarding } = props;
+ const { update, social, article, onboarding, isMobile } = props;
const { isGeneral, extensionId } = useVariables();
const toaster = useToaster();
const router = useRouter();
@@ -418,26 +420,38 @@ export const AddProviderComponent: FC<{
modal.openModal({
title: `Add ${capitalize(identifier)}`,
withCloseButton: true,
+ ...(isMobile ? { removeLayout: true, fullScreen: true } : {}),
classNames: {
modal: 'bg-transparent text-textColor',
},
children: (
- <Web3Providers
- onComplete={(code, newState) => {
- window.location.href = `/integrations/social/${identifier}?code=${code}&state=${newState}${
- onboarding ? '&onboarding=true' : ''
- }`;
- }}
- nonce={url}
- />
+ <div
+ {...(isMobile ? { className: 'h-full bg-black p-[20px]' } : {})}
+ >
+ <Web3Providers
+ onComplete={(code, newState) => {
+ window.location.href = `/integrations/social/${identifier}?code=${code}&state=${newState}${
+ onboarding ? '&onboarding=true' : ''
+ }`;
+ }}
+ nonce={url}
+ />
+ </div>
),
});
return;
};
const gotoIntegration = async (externalUrl?: string) => {
+ // Mobile WebView: reuse the existing `externalUrl` param to
+ // carry the `postiz://` deep link so the backend redirects
+ // back to the iOS/Android app after OAuth completes, instead
+ // of the default web redirect.
const params = [
- externalUrl ? `externalUrl=${externalUrl}` : '',
+ `externalUrl=${encodeURIComponent(externalUrl)}`,
onboardingParam,
+ isMobile
+ ? `redirectUrl=${encodeURIComponent('postiz://integrations')}`
+ : '',
]
.filter(Boolean)
.join('&');
@@ -467,6 +481,23 @@ export const AddProviderComponent: FC<{
return;
}
+ if (isMobile) {
+ // In the mobile WebView the OAuth provider (Google, Facebook,
+ // etc.) typically refuses in-WebView sign-in. Post the URL
+ // out to React Native so it can open the system browser;
+ // `window.open`/`location.href` aren't reliable here because
+ // RN WebView doesn't always route them through the native
+ // navigation intercept. The backend redirects back to the
+ // app via `postiz://` once OAuth completes.
+ const rn = (window as any).ReactNativeWebView;
+ if (rn && typeof rn.postMessage === 'function') {
+ rn.postMessage(JSON.stringify({ type: 'open-external', url }));
+ return;
+ }
+ window.open(url, '_blank');
+ return;
+ }
+
window.location.href = url;
};
if (isWeb3) {
@@ -577,6 +608,7 @@ export const AddProviderComponent: FC<{
modal.openModal({
title: 'URL',
withCloseButton: true,
+ ...(isMobile ? { removeLayout: true, fullScreen: true } : {}),
classNames: {
modal: 'bg-transparent text-textColor',
},
@@ -588,16 +620,21 @@ export const AddProviderComponent: FC<{
modal.openModal({
title: t('add_provider_title', 'Add Provider'),
withCloseButton: true,
+ ...(isMobile ? { removeLayout: true, fullScreen: true } : {}),
classNames: {
modal: 'bg-transparent text-textColor',
},
children: (
- <CustomVariables
- identifier={identifier}
- gotoUrl={(url: string) => router.push(url)}
- variables={customFields}
- onboarding={onboarding}
- />
+ <div
+ {...(isMobile ? { className: 'h-full bg-black p-[20px]' } : {})}
+ >
+ <CustomVariables
+ identifier={identifier}
+ gotoUrl={(url: string) => router.push(url)}
+ variables={customFields}
+ onboarding={onboarding}
+ />
+ </div>
),
});
return;
@@ -614,8 +651,10 @@ export const AddProviderComponent: FC<{
<div className="flex flex-col">
<div
className={clsx(
- 'grid grid-cols-5 gap-[10px] justify-items-center justify-center',
- onboarding ? 'grid-cols-9' : 'grid-cols-5'
+ isMobile && 'gap-[20px] flex flex-col',
+ !isMobile &&
+ 'grid grid-cols-5 gap-[10px] justify-items-center justify-center',
+ isMobile ? {} : onboarding ? 'grid-cols-9' : 'grid-cols-5'
)}
>
{social
@@ -648,9 +687,12 @@ export const AddProviderComponent: FC<{
'data-tooltip-content': item.toolTip,
}
: {})}
- className={
- 'w-full h-[100px] text-[14px] p-[10px] rounded-[8px] bg-newTableHeader text-textColor relative justify-center items-center flex flex-col gap-[10px] cursor-pointer'
- }
+ className={clsx(
+ isMobile
+ ? 'flex-row h-[72px] p-[16px]'
+ : 'flex-col p-[10px] h-[100px] justify-center',
+ 'w-full text-[14px] rounded-[8px] bg-newTableHeader text-textColor relative items-center flex gap-[10px] cursor-pointer'
+ )}
>
<div>
{item.identifier === 'youtube' ? (
@@ -666,9 +708,14 @@ export const AddProviderComponent: FC<{
/>
)}
</div>
- <div className="whitespace-pre-wrap text-center">
+ <div
+ className={clsx(
+ isMobile ? '' : 'whitespace-pre-wrap',
+ 'text-center'
+ )}
+ >
{item.name}
- {!!item.toolTip && (
+ {!!item.toolTip && !isMobile && (
<svg
width="15"
height="15"
diff --git a/apps/frontend/src/components/new-layout/mobile.integration.tsx b/apps/frontend/src/components/new-layout/mobile.integration.tsx
new file mode 100644
index 000000000..bf3d92e92
--- /dev/null
+++ b/apps/frontend/src/components/new-layout/mobile.integration.tsx
@@ -0,0 +1,31 @@
+'use client';
+
+import { FC, useCallback, useEffect, useState } from 'react';
+import { AddProviderComponent } from '@gitroom/frontend/components/launches/add.provider.component';
+import { useFetch } from '@gitroom/helpers/utils/custom.fetch';
+
+export const MobileIntegration: FC = () => {
+ const [integrations, setIntegrations] = useState(null as any);
+ const fetch = useFetch();
+
+ const loadIntegrations = useCallback(async () => {
+ setIntegrations(await (await fetch('/integrations')).json());
+ }, []);
+
+ useEffect(() => {
+ loadIntegrations();
+ }, []);
+
+ if (!integrations) {
+ return null;
+ }
+
+ return (
+ <AddProviderComponent
+ isMobile={true}
+ invite={false}
+ update={() => {}}
+ {...integrations}
+ />
+ );
+};
diff --git a/apps/frontend/src/components/provider-preview/preview.provider.component.tsx b/apps/frontend/src/components/provider-preview/preview.provider.component.tsx
index 08fe7d894..96a94735d 100644
--- a/apps/frontend/src/components/provider-preview/preview.provider.component.tsx
+++ b/apps/frontend/src/components/provider-preview/preview.provider.component.tsx
@@ -232,7 +232,7 @@ export const ProviderPreviewComponent: FC<ProviderPreviewProps> = ({
return (
<IntegrationContext.Provider value={contextValue}>
<FormProvider {...form}>
- <div className="flex flex-col text-white">
+ <div className="flex flex-col text-white p-[10px]">
{errors && errors.length > 0 && (
<div className="rounded-md border border-red-500/40 bg-red-500/10 p-3 text-sm text-red-300">
<ul className="list-disc ps-5">