-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: reactions and new
getCastWithReactions
action
- Loading branch information
Showing
17 changed files
with
423 additions
and
78 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import type { Types } from 'ox' | ||
import type { Cast_fromMessage } from '../../Cast/fromMessage.js' | ||
import type { Cast } from '../../Cast/types.js' | ||
import type { GlobalErrorType } from '../../Errors/error.js' | ||
import type { Reaction } from '../../Reaction/types.js' | ||
import { Actions_Reaction_getReactionsByCast } from '../Reaction/getReactionsByCast.js' | ||
import { Actions_Cast_getCast } from './getCast.js' | ||
|
||
export declare namespace Actions_Cast_GetCastWithReactions { | ||
type ReturnType = { | ||
cast: Cast | ||
recasts: Reaction[] | ||
likes: Reaction[] | ||
} | ||
type ErrorType = Cast_fromMessage.ErrorType | GlobalErrorType | ||
} | ||
export async function Actions_Cast_getCastWithReactions( | ||
...[client, parameters, options]: Parameters<typeof Actions_Cast_getCast> | ||
): Promise<Actions_Cast_GetCastWithReactions.ReturnType> { | ||
const cast = await Actions_Cast_getCast(client, parameters, options) | ||
|
||
const reactions = await (async () => { | ||
const reactions: Reaction[] = [] | ||
let reactionsPageToken: Types.Hex | null = null | ||
do { | ||
const { nextPageToken, messages } = | ||
await Actions_Reaction_getReactionsByCast(client, { | ||
...parameters, | ||
pageToken: reactionsPageToken ? reactionsPageToken : undefined, | ||
}) | ||
reactionsPageToken = nextPageToken as any | ||
reactions.push(...messages) | ||
} while (reactionsPageToken) | ||
return reactions | ||
})() | ||
|
||
const likes = reactions.filter((reaction) => reaction.type === 'like') | ||
const recasts = reactions.filter((reaction) => reaction.type === 'recast') | ||
|
||
return { cast, likes, recasts } | ||
} | ||
|
||
Actions_Cast_getCastWithReactions.parseError = (error: unknown) => | ||
error as Actions_Cast_GetCastWithReactions.ErrorType |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 32 additions & 10 deletions
42
src/Internal/Actions/Reaction/getAllReactionMessagesByFid.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.