Skip to content

Commit d1e10d4

Browse files
committed
feat(shared): add unified DeepLinkResolver with polymorphic fallback chain
1 parent 42ee1ac commit d1e10d4

7 files changed

Lines changed: 423 additions & 154 deletions

File tree

apps/backend/src/routes/follow.ts

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import type { FastifyInstance, FastifyRequest, FastifyReply } from 'fastify';
22
import { decrypt } from '../utils/encryption.js';
33
import { getErrorMessage } from '../utils/error.util.js';
4-
import { getPlatform, getProfileUrl, getWebViewUrl } from '@devcard/shared';
4+
import { getPlatform, getProfileUrl, getWebViewUrl, resolveDeepLink } from '@devcard/shared';
55
import { followLogSchema } from '../validations/follow.validation.js';
66

77
export async function followRoutes(app: FastifyInstance) {
@@ -35,14 +35,16 @@ export async function followRoutes(app: FastifyInstance) {
3535
},
3636
});
3737

38-
// Use WebView follow strategy if configured for the platform (e.g. LinkedIn, Twitter/X)
38+
// Use WebView follow strategy if resolved for the platform (e.g. LinkedIn, Twitter/X)
3939
const platformDef = getPlatform(platform);
40-
if (platformDef?.followStrategy === 'webview') {
41-
const url = getWebViewUrl(platform, targetUsername) || getProfileUrl(platform, targetUsername);
42-
return reply.send({
43-
strategy: 'webview',
44-
url,
45-
});
40+
if (platformDef) {
41+
const resolved = resolveDeepLink(platform, targetUsername, { isMobile: false });
42+
if (resolved.strategy === 'webview') {
43+
return reply.send({
44+
strategy: 'webview',
45+
url: resolved.url,
46+
});
47+
}
4648
}
4749

4850
if (!oauthToken) {

0 commit comments

Comments
 (0)