Skip to content

Commit

Permalink
update mocks
Browse files Browse the repository at this point in the history
  • Loading branch information
artlu99 committed Nov 1, 2024
1 parent 593fb94 commit 1ae901b
Show file tree
Hide file tree
Showing 4 changed files with 299 additions and 23 deletions.
47 changes: 37 additions & 10 deletions src/api/feed-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,49 +6,62 @@ export interface FeedObject {
export interface CastObject {
hash: string;
timestamp: number;
object: 'cast';
object: 'cast' | 'cast_embedded';
author: {
active_status: 'inactive' | 'active';
active_status?: 'inactive' | 'active';
fid: number;
display_name?: string;
username?: string;
pfp_url?: string;
custody_address?: string;
follower_count?: number;
following_count?: number;
object: 'user' | 'group';
object: 'user' | 'group' | 'user_dehydrated';
verified_addresses?: {
eth_addresses?: string[];
sol_addresses?: string[];
};
verifications?: string[];
verified_accounts?: { platform: string; username: string }[] | null;
power_badge?: boolean;
profile?: {
bio?: {
text?: string;
mentioned_profiles?: UserProfile[];
};
location?: {
address: {
city: string;
country: string;
country_code: string;
state: string;
state_code?: string;
};
latitude: number;
longitude: number;
};
};
viewer_context?: AuthorViewerContext;
};
author_channel_context?: { following: boolean; role: 'moderator' | 'member' };
text: string;
mentioned_profiles: UserProfile[];
mentioned_profiles?: UserProfile[];
parent_author: { fid: number | null };
parent_hash: string | null;
root_parent_url?: string;
root_parent_url?: string | null;
thread_hash?: string;
parent_url?: string;
parent_url?: string | null;
embeds?: EmbedObject[];
frames?: FrameObject[];
channel?: ChannelObject;
channel?: ChannelObject | null;
viewer_context?: CastViewerContext;
reactions: {
reactions?: {
likes: UserDetails[];
likes_count: number;
recasts: UserDetails[];
recasts_count: number;
};
replies: { count: number };
replies?: { count: number };
}

interface AuthorViewerContext {
Expand All @@ -73,6 +86,18 @@ export interface EmbedObject {
fid: number;
hash: string;
};
cast?: CastObject;
metadata?: {
_status: string;
content_length: number | null;
content_type: string;
html?: {
favicon: string;
ogDescription: string;
ogImage: { url: string }[];
ogTitle: string;
};
};
}

export interface FrameObject {
Expand All @@ -82,14 +107,16 @@ export interface FrameObject {
input?: FrameInputObject;
post_url?: string;
state?: FrameStateObject;
image_aspect_ratio?: '1:1' | '16:9';
title?: string;
version?: string;
}

export interface FrameButtonObject {
action_type: 'post' | 'like' | 'recast' | 'comment' | 'share' | 'follow' | 'unfollow' | 'vote';
action_type: 'post' | 'like' | 'recast' | 'comment' | 'share' | 'follow' | 'unfollow' | 'vote' | 'link';
index: number;
title: string;
target?: string;
}

export interface FrameInputObject {
Expand Down
248 changes: 248 additions & 0 deletions src/api/mocks/cronFeed.api.mock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,254 @@ export const transformRawAPIResponse = (obj: RawAPIResponse): FeedObject => ({

const rawCronFeed: RawAPIResponse = {
casts: [
{
author: {
custody_address: '0x73ed37b01877e24e18f229c29588da065ffbd632',
display_name: 'christin',
fid: 15850,
follower_count: 63477,
following_count: 1403,
object: 'user',
pfp_url: 'https://imagedelivery.net/BXluQx4ige9GuW0Ia56BHw/8d4fdcdb-17e1-45e5-0bd8-2edd7eb7e800/original',
power_badge: true,
profile: {
bio: {
text: 'neuroscience phd, healthcare marketer, interfaith chaplain. co-host of the /okbanger show and vibe imagineer for /christin. https://seemore.tv/christin',
},
location: {
address: {
city: 'San Francisco',
country: 'United States of America',
country_code: 'us',
state: 'California',
state_code: 'ca',
},
latitude: 37.77,
longitude: -122.42,
},
},
username: 'christin',
verifications: ['0x2d240c5d58a8445e99dadf3fd41a492dfeaf7e4c'],
verified_accounts: [{ platform: 'x', username: 'Christintweets' }],
verified_addresses: { eth_addresses: ['0x2d240c5d58a8445e99dadf3fd41a492dfeaf7e4c'], sol_addresses: [] },
},
author_channel_context: { following: true, role: 'moderator' },
channel: {
id: 'bcbhshow',
image_url: 'https://imagedelivery.net/BXluQx4ige9GuW0Ia56BHw/90dc6268-931b-44d7-5672-ef5a28009200/original',
name: 'The BeavChris and BArt-Head Show',
object: 'channel_dehydrated',
},
embeds: [],
hash: '0x122fc6df29a8a4c6e062d4f6994c1cb1b09cd2fd',
mentioned_profiles: [],
object: 'cast',
parent_author: { fid: null },
parent_hash: null,
parent_url: 'https://warpcast.com/~/channel/bcbhshow',
reactions: {
likes: [
{ fid: 840349, fname: 'nestedgamer' },
{ fid: 841008, fname: 'gammac2282' },
{ fid: 823917, fname: 'seduc1n' },
{ fid: 825245, fname: 'surami' },
{ fid: 704488, fname: 'dilman' },
],
likes_count: 19,
recasts: [],
recasts_count: 0,
},
replies: { count: 5 },
root_parent_url: 'https://warpcast.com/~/channel/bcbhshow',
text: 'BArt-head is back with a new thing 👁️ 👁️',
thread_hash: '0x122fc6df29a8a4c6e062d4f6994c1cb1b09cd2fd',
timestamp: '2024-10-24T21:36:32.000Z',
},
{
author: {
custody_address: '0x56fe1035663c07960d22d9f908c00170eb21489a',
display_name: 'Dan Romero',
fid: 391262,
follower_count: 289,
following_count: 280,
object: 'user',
pfp_url: 'https://imagedelivery.net/BXluQx4ige9GuW0Ia56BHw/994e1f33-1e40-44d5-eb70-62b39cc58700/original',
power_badge: false,
profile: {
bio: { text: 'welcome to the cacc club 🤝 hurh hurh\n\nhttps://paragraph.xyz/@bcbhshow\n\nbcbhshow.com' },
},
username: 'bcbhshow.eth',
verifications: ['0x8115c76a7dd9bf884b58d8feb384fc9d81f9ccb2'],
verified_accounts: null,
verified_addresses: {
eth_addresses: ['0x8115c76a7dd9bf884b58d8feb384fc9d81f9ccb2'],
sol_addresses: ['2asXbnzhgRSjEeQzSNkv61yDEkcNp6yK9jXQfDEkn8wR'],
},
},
author_channel_context: { following: true, role: 'member' },
channel: {
id: 'bcbhshow',
image_url: 'https://imagedelivery.net/BXluQx4ige9GuW0Ia56BHw/90dc6268-931b-44d7-5672-ef5a28009200/original',
name: 'The BeavChris and BArt-Head Show',
object: 'channel_dehydrated',
},
embeds: [],
hash: '0x84ebc0cf7b4204b4d0020a5fcb4d2b00215ca1e9',
mentioned_profiles: [],
object: 'cast',
parent_author: { fid: null },
parent_hash: null,
parent_url: 'https://warpcast.com/~/channel/bcbhshow',
reactions: {
likes: [
{ fid: 852580, fname: 'poltorashka' },
{ fid: 632764, fname: 'jzj' },
{ fid: 795470, fname: 'uci' },
{ fid: 863298, fname: 'swengh' },
{ fid: 6622, fname: 'frdysk.eth' },
],
likes_count: 12,
recasts: [
{ fid: 863298, fname: 'swengh' },
{ fid: 1606, fname: 'samantha' },
],
recasts_count: 2,
},
replies: { count: 3 },
root_parent_url: 'https://warpcast.com/~/channel/bcbhshow',
text: 'Probably Nothing\n\n44a39e481f1e7d5f8ee734025190dd2ff1e831aaf5acc08e33d1c0790746661d',
thread_hash: '0x84ebc0cf7b4204b4d0020a5fcb4d2b00215ca1e9',
timestamp: '2024-10-07T19:45:15.000Z',
},
{
author: {
custody_address: '0x12f86568a8dad4d5e5796362374ab0ddec0796dd',
display_name: 'Alex A.🦊🎩',
fid: 6945,
follower_count: 2682,
following_count: 660,
object: 'user',
pfp_url: 'https://imagedelivery.net/BXluQx4ige9GuW0Ia56BHw/efaf3d64-9c23-425f-8c2c-b1644809d600/original',
power_badge: true,
profile: {
bio: {
text: 'God’s Son || Building Buenas Noches Farcaster (BNF) /bnfarcaster Podcast || Building NotiCast /noticast || My FID is under 7K',
},
location: {
address: { city: 'Lima Metropolitan Area', country: 'Peru', country_code: 'pe', state: 'Lima' },
latitude: -12.05,
longitude: -77.04,
},
},
username: 'whatsgood-al',
verifications: ['0x9cf7036aef81df2c0e48de0bb2e32270ee3283d5'],
verified_accounts: [{ platform: 'x', username: 'WhatsgoodbigAL' }],
verified_addresses: { eth_addresses: ['0x9cf7036aef81df2c0e48de0bb2e32270ee3283d5'], sol_addresses: [] },
},
author_channel_context: { following: true, role: 'member' },
channel: {
id: 'bcbhshow',
image_url: 'https://imagedelivery.net/BXluQx4ige9GuW0Ia56BHw/90dc6268-931b-44d7-5672-ef5a28009200/original',
name: 'The BeavChris and BArt-Head Show',
object: 'channel_dehydrated',
},
embeds: [
{
metadata: {
_status: 'RESOLVED',
content_length: null,
content_type: 'text/html;charset=utf-8',
html: {
favicon: 'https://zora.co/favicon/favicon.png',
ogDescription:
'Watch a special episode of Buenos Noches Farcaster with BeavChris and BArt-Head\n\nReturning 8/30/24\n\nhttps://www.youtube.com/@BuenasNochesFarcaster/',
ogImage: [
{
url: 'https://media.decentralized-content.com/-/rs:fit:1200:1200/f:png/aHR0cHM6Ly96b3JhLmNvL2FwaS90aHVtYm5haWwvb2cvODQ1My8weGUyMDNjOTQ2NTBmNjBjOWFlM2UyYzM3M2RlOGUxYzdiMGI3ZTFjODUvMTU',
},
],
ogTitle: 'BeavChris and BArt-Head by Miguel Garest',
},
},
url: 'https://zora.co/collect/base:0xe203c94650f60c9ae3e2c373de8e1c7b0b7e1c85/15?referrer=0x9CF7036aef81dF2C0e48De0bb2E32270EE3283D5',
},
],
frames: [
{
buttons: [
{
action_type: 'link',
index: 1,
target: 'https://zora.co/collect/base:0xe203c94650f60c9ae3e2c373de8e1c7b0b7e1c85/15',
title: 'View on Zora',
},
],
frames_url:
'https://zora.co/collect/base:0xe203c94650f60c9ae3e2c373de8e1c7b0b7e1c85/15?referrer=0x9CF7036aef81dF2C0e48De0bb2E32270EE3283D5',
image:
'https://zora.co/api/og-image/post/base:0xe203c94650f60c9ae3e2c373de8e1c7b0b7e1c85/15?v=2\u0026crop=square',
image_aspect_ratio: '1:1',
input: {},
state: {},
title: 'BeavChris and BArt-Head by Miguel Garest',
version: 'vNext',
},
],
hash: '0x98327e415046b098f0a93a1011b401c9fabe85f1',
mentioned_profiles: [
{
custody_address: '0x73ed37b01877e24e18f229c29588da065ffbd632',
display_name: 'christin',
fid: 15850,
follower_count: 63477,
following_count: 1403,
object: 'user',
pfp_url: 'https://imagedelivery.net/BXluQx4ige9GuW0Ia56BHw/8d4fdcdb-17e1-45e5-0bd8-2edd7eb7e800/original',
power_badge: true,
profile: {
bio: {
mentioned_profiles: [],
text: 'neuroscience phd, healthcare marketer, interfaith chaplain. co-host of the /okbanger show and vibe imagineer for /christin. https://seemore.tv/christin',
},
},
username: 'christin',
verifications: ['0x2d240c5d58a8445e99dadf3fd41a492dfeaf7e4c'],
verified_addresses: { eth_addresses: ['0x2d240c5d58a8445e99dadf3fd41a492dfeaf7e4c'], sol_addresses: [] },
},
{
custody_address: '0x21ca9f0f7c0b59f616b1d96325d55b62c9661d6d',
display_name: 'artlu is on lunchbreak!',
fid: 6546,
follower_count: 49804,
following_count: 2640,
object: 'user',
pfp_url: 'https://media.firefly.land/lens/ba033cd8-58e1-4591-a2a3-85689206299c.png',
power_badge: true,
profile: {
bio: {
mentioned_profiles: [],
text: 'https://SassyHash.artlu.xyz/download\n\nJoin my frens in cacc club.\n\nThe Once and Future /arthur /bcbhshow. FOSS at GH:artlu99.\n\nPFP is same across socials',
},
},
username: 'artlu',
verifications: ['0x094f1608960a3cb06346cfd55b10b3cec4f72c78'],
verified_addresses: {
eth_addresses: ['0x094f1608960a3cb06346cfd55b10b3cec4f72c78'],
sol_addresses: ['HgKZky6hf1fiRPuM6tAc2yn9pKvnEeiMmfRGJGWQBTJh'],
},
},
],
object: 'cast',
parent_author: { fid: null },
parent_hash: null,
parent_url: 'https://warpcast.com/~/channel/bcbhshow',
reactions: { likes: [], likes_count: 0, recasts: [], recasts_count: 0 },
replies: { count: 0 },
root_parent_url: 'https://warpcast.com/~/channel/bcbhshow',
text: 'Oh yeah got my /bcbhshow @christin and @artlu s NFT\n\nMinted BeavChris and BArt-Head by Miguel Garest',
thread_hash: '0x98327e415046b098f0a93a1011b401c9fabe85f1',
timestamp: '2024-09-01T03:59:37.000Z',
},
{
author: {
active_status: 'inactive',
Expand Down
15 changes: 8 additions & 7 deletions src/components/apps/channelFeed/ChannelFeed.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import { useEffect, useMemo, useState } from 'react';
const isAllowedInMainFeed = (cast: CastObject, channelModerators: number[]) => {
return (
channelModerators.filter((m) => m === cast.author.fid).length > 0 ||
cast.reactions.likes.filter((l) => channelModerators.filter((m) => m === l.fid).length > 0).length > 0
(cast.reactions?.likes ?? []).filter((l) => channelModerators.filter((m) => m === l.fid).length > 0).length > 0
);
};

Expand Down Expand Up @@ -137,12 +137,12 @@ export const ChannelFeed: React.FC = () => {
avatar={post.author.pfp_url}
parentHash={post.parent_hash}
threadHash={post.thread_hash}
parentUrl={post.parent_url}
replies={post.replies.count}
recasts={post.reactions.recasts_count}
recastooors={post.reactions.recasts.map((r) => r.fid)}
likes={post.reactions.likes_count}
likooors={post.reactions.likes.map((l) => l.fid)}
parentUrl={post.parent_url ?? undefined}
replies={post.replies?.count ?? 0}
recasts={post.reactions?.recasts_count ?? 0}
recastooors={post.reactions?.recasts.map((r) => r.fid) ?? []}
likes={post.reactions?.likes_count ?? 0}
likooors={post.reactions?.likes.map((l) => l.fid) ?? []}
hasPowerBadge={post.authorHasPowerBadge}
botOrNotResult={post.botOrNotResult}
tags={[]}
Expand All @@ -157,6 +157,7 @@ export const ChannelFeed: React.FC = () => {
showMainFeed,
showOnlyFarcaptcha,
showOnlyFollowing,
showOnlySassy,
selectedLabels,
]);

Expand Down
Loading

0 comments on commit 1ae901b

Please sign in to comment.