MCPcopy Create free account
hub / github.com/FxEmbed/FxEmbed / handleActivity

Function handleActivity

src/embed/activity.ts:369–673  ·  view source on GitHub ↗
(
  c: Context,
  snowcode: string,
  provider: DataProvider
)

Source from the content-addressed store, hash-verified

367};
368
369export const handleActivity = async (
370 c: Context,
371 snowcode: string,
372 provider: DataProvider
373): Promise<Response> => {
374 let language: string | null = null;
375 let authorHandle: string | null = null;
376 let mediaNumber: number | null = null;
377 let textOnly = false;
378 let forceMosaic = false;
379 const decoded = decodeSnowcode(snowcode);
380 const statusId = decoded.i;
381 if (decoded.l) {
382 language = decoded.l;
383 }
384 if (decoded.h) {
385 authorHandle = decoded.h;
386 }
387 if (decoded.t) {
388 textOnly = true;
389 }
390 if (decoded.m) {
391 forceMosaic = true;
392 }
393 if (decoded.n) {
394 mediaNumber = decoded.n;
395 }
396
397 const preferredProxyServiceHost =
398 typeof decoded.p === 'string' && decoded.p.length > 0 ? decoded.p : undefined;
399
400 console.log('snowcode params', JSON.stringify(decoded));
401
402 let thread: SocialThread;
403 if (provider === DataProvider.Twitter) {
404 thread = await constructTwitterThread(
405 statusId,
406 false,
407 twitterBuildHostFromContext(c),
408 language ?? undefined,
409 false
410 );
411 } else if (provider === DataProvider.Bluesky) {
412 thread = await constructBlueskyThread(
413 statusId,
414 authorHandle ?? '',
415 false,
416 blueskyBuildHostFromContext(c),
417 language ?? undefined,
418 preferredProxyServiceHost ? { preferredProxyServiceHost } : undefined
419 );
420 } else if (provider === DataProvider.TikTok) {
421 // Get proxy base URL from the current request for TikTok video proxy
422 const requestUrl = new URL(c.req.url);
423 const proxyBase = `${requestUrl.protocol}//${requestUrl.host}`;
424 thread = await constructTikTokVideo(statusId, proxyBase);
425 } else {
426 return returnError(c, Strings.ERROR_API_FAIL);

Callers 3

activityRequestFunction · 0.90
activityRequestFunction · 0.90
activityRequestFunction · 0.90

Calls 15

decodeSnowcodeFunction · 0.90
constructTwitterThreadFunction · 0.90
constructBlueskyThreadFunction · 0.90
constructTikTokVideoFunction · 0.90
returnErrorFunction · 0.90
isTombstoneFunction · 0.90
normalizeLanguageFunction · 0.90
shouldTranscodeGifFunction · 0.90
experimentCheckFunction · 0.90

Tested by

no test coverage detected